I have been trying to figure out how to do a fairly basic repeated measures analysis using linear mixed effects in R, and then analysing it using post-hoc tests. The problem is that I'm not sure whether the output I get is statistically sound?
The response variable:
weighted- an index of habitat preference (prop. individuals on habitatA / prop. of total habitat that is A). A value above 1 indicates the habitat is being used more than what you would expect from its availability. this was repeatedly measured on the same colony through time over several weeks
Type - habitat type (live/dead),
weeks - the time variable
colony - because each measurement of colony violates independence assumption.
Here's what the data loss like plotted over time (orange=live habitat, blue=dead habitat):
i run the analysis using the
lmer() function from the
results_full=lmer(weighted~type*weeks+(weeks|colony), data=Pos, REML=F)
My reasoning is that i have no reason to expect a random intercept, they should all start on 1 at time 0, and then individuals will start avoiding the dead habitat and favouring the live habitat. The
(weeks|colony) term allows the slope of each colony to be random across time?
So to my question:
I compare the likelihood of two models with each other, in a likelihood ratio test to get p-values of the fixed effects using a reduced model:
results_null=lmer(weighted~type+weeks+ (weeks|colony), data=Pos, REML=F) anova(results_null, results_full)
But what I'm really interested in is at what time point (week) do the individuals start avoiding the dead habitat. as you can see from the figure this happens at week 1 so comparing live-dead habitat week by week "should" generate a n/s result at week 0 and sig result from then on (I'm not trying to force a statistically significant result, but the fig is pretty clear...)
I tried converting the weeks into a factor, and then performing
But it didn't generate anything that seemed meaningful, the output didn't make sense in relation to the data.
Does anyone have any thoughts on A) whether my model and test is appropriate to this data, and B) how I can perform a post hoc test to compare habitat type over time?
Would it be appropriate to use a Dunetts post hoc test to compare preferences to a reference value (=1) rather than to each other?
Grateful for any ideas or pointers!