Incorporating time series into a mixed effects model in R (using lme4) -
i've had search similar questions , come short apologies if there related questions i've missed.
i'm looking @ amount of time spent on feeders (dependent variable) across various conditions each subject visiting feeders 30 times.
subjects exposed feeders of 1 type have different combination of being scented/unscented, having visual patterns/being blank, , having these visual or scented patterns presented in 1 of 2 spatial arrangements.
so far model is:
mod<-lmer(timeonfeeder ~ scent_yes_no + visual_yes_no + pattern_one_or_two + (1|subject), data=data)
how can incorporate visit numbers model see if these factors have effect on time spent on feeders on time?
you have variety of choices (this question might marginally better crossvalidated).
as @dominix suggests, can allow linear increase or decrease in time on feeder on time. makes sense allow change vary across birds:
timeonfeeder ~ time + ... + (time|subject)
you could allow arbitrary pattern of change on time (i.e. not linear):
timeonfeeder ~ factor(time) + ... + (1|subject)
this doesn't make sense in case, because have large number of observations, require many parameters (it more sensible if had, say, 3 time points per individual)
you allow more complex pattern of change on time via additive model, i.e. modeling change on time cubic spline. example:
library(mgcv) gamm(timeonfeeder ~ s(time) + ... , random = ~1|subject
(1) assumes temporal pattern same across subjects; (2) because
gamm()
useslme
ratherlmer
under hood have specify random effect separate argument. (you usegamm4
package, useslmer
under hood.)you might want allow temporal autocorrelation. example,
lme(timeonfeeder ~ time + ... , random = ~ time|subject, correlation = corar1(form= ~time|subject) , ...)
Comments
Post a Comment