0
$\begingroup$

I have a large data wth numerical response and two categorical factors: date and site. There are about 350 dates and 25 sites, but not all sites have observations on every single date (most have only a few dates active). Other than that there are multiple observations at a site on a given date so that such observed interactions are estimable. I fitted a nested lm model:

resp~site/date

and thought that it would only estimate these interactions which occur in teh date (this is how I understood nested models: levels of date are ONLY sensible within levels of site), but no, the model matrix includes columns for every possible combination - and the unestimable ones are returned by lm as NA. The model fits but takes a very long time because of this.

Is there another formula construct that would let lm (or aov) only estimate interaction effects for dates actually ocuring with each site?

$\endgroup$

1 Answer 1

1
$\begingroup$

Probably too late, but you can use interaction(date,site) to create a single factor whose levels are the combinations of the two factors that actually occur in the dataset.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.