[R-sig-ME] time delayed response as a covariate in lme4
marKo
mtoncic at ffri.hr
Tue Jan 20 14:24:31 CET 2015
I have a dataset which have a continuous outcome variable and a time
(chron) covariate for 99 subjects (id). To get an idea:
> str(dataframe)
'data.frame': 36352 obs. of 9 variables:
$ response : int 100 79 63 50 71 73 62 72 76 77 ...
$ id : Factor w/ 99 levels "g1_1","g1_12",..: 2 2 2 2 2 2 2 2 2 2 ...
$ time :Classes 'chron', 'dates', 'times' atomic [1:36352] 15875
15875 15875 15875 15875 ...
.. ..- attr(*, "format")= Named chr [1:2] "m/d/y" "h:m:s"
.. .. ..- attr(*, "names")= chr [1:2] "dates" "times"
.. ..- attr(*, "origin")= Named num [1:3] 1 1 1970
.. .. ..- attr(*, "names")= chr [1:3] "month" "day" "year"
I would like to use the time delayed response as a predictor/covariate.
Lets say a would like to use response at time-1 as a covariate. How can
this be done?
Something like (conceptually):
model<-lmer(response~poly(time, n) + response(time -1) + (poly(time,
n)|id, data=dataframe)
I suppose that I could use some correlation structure for this (in nlme,
because I think that lme4 do not support this a this stage), although
I'd rather do this in lme4.
Any ideas?
Cheers (and thanks),
Marko
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list