[R-sig-ME] lme4:glmer with nested and longitudinal data?

hijita at gmx.net hijita at gmx.net
Mon Nov 14 17:47:19 CET 2011


Dear all,

I am a beginner in R, and got stuck with this problem:
I have the following dataset with results from an experiment with individual bats that performed two tasks related to prey capture under different conditions:

X variables:
indiv - 5 individual bats used in the experiment; all of which performed both tasks
task - 2 tasks that each individual bat had to perform
dist - 5 repeated measures of individual bats at 5 different distances from the object

all x variables I treat as categorical factors with levels

Y - I have 8 dependent variables related to the structure of ultrasound calls emitted by bats when performing each task. I know I can use them together in the same model with the function “cbind()” but each variable behaves a bit differently. Thus, I guess it would be better to build 8 separate models. 

I believe "indiv" should be a random effect in the model; "dist" and "task" should be fixed effects.

I´d like to use the “glmer” (lme4) function to test two hypotheses:

Main hypothesis:
There are differences in Y measurements between tasks, which are related also to distance from the object.

Secondary hypothesis:
Differences in Y measurements between tasks do not depend on the individual.

I guess the simplest model for an AIC model selection would be:
print(Model.01<-glmer(y~task*dist+(1|indiv))
 - so any model that provides more details should have a lower (better)  AIC score.
I’m not sure if I’m coding the models including more details correctly. I just want them to test my hypothesis properly . 

Literature suggests to get rid of the pseudo-replication: my repeated measures (“dist”) seem to behave like longitudinal data (as it is basically a time series). This way, "indiv" would be nested in "dist". Furthermore, "dist" levels have different variance, so it would be good to group the data and somehow tell the model, that it should ignore differences in variance.
(1|dist:indiv) or (dist|indiv)?
I am still wondering if the “weights=” argument would apply here?

2- “dist” is nested in “task”, as for both tasks I have the same distances measured.
According to the description of the package “lme4”, I should write:
print(Model.02<-glmer(y~task*dist+(1|indiv)+(1|task:dist))

3- according to the text -book “The R book” I understand that I should do the following:
rename factor levels to unique labels:
taskdist<-task:dist
taskdistindiv<-task:dist:indiv
print(Model.03<-glmer(y~task+(1|taskdist)+(1|taskdistindiv)))

Or, pooling 1 and 3 together myself I would end up with:
print(Model.04<-glmer(y~dist*task+(1|indiv)+(1|task:dist)+(1|dist:indiv))

I was not able to extract this type of information from the threads provided online.

Thank you for your attention and for any help you may provide.

--




More information about the R-sig-mixed-models mailing list