[R-sig-ME] Specifying block-level variables for a complete block design with glmer
Thomas Levine
tkl22 at cornell.edu
Wed May 18 22:51:45 CEST 2011
I administered a questionnaire a bunch of people people. The
questionnaire asked about demographics, which I would like to model as
random effects, and a bunch of related questions that could be thought
of as a factorial layout, which I would like to model as fixed
effects. I currently have a model where person is the only random
effect, and I would like to include the demographics in the model.
I administered a questionnaire to 173 people, with a different "id"
value assigned to each person. This posture included questions on
demographics and 12 questions that can be thought of as a 2x2x3
factorial layout. I thus have 2076=173*12 experimental units. The
demographics are all categorical except for "height" and "age". Here
are the first six of those experimental units.
> head(posture.df)
id school county building your_residence mobility_impairments country height
1 1 GM 0 house_apt private no 101 66
2 1 GM 0 house_apt private no 101 66
3 1 GM 0 house_apt private no 101 66
4 1 GM 0 house_apt private no 101 66
5 1 GM 0 house_apt private no 101 66
6 1 GM 0 house_apt private no 101 66
age sex task space cleanliness posture sit hover
1 29 male urine public unspecified stand FALSE FALSE
2 29 male urine private unspecified stand FALSE FALSE
3 29 male defecate public unspecified hover FALSE TRUE
4 29 male defecate private unspecified sit TRUE FALSE
5 29 male urine public dirty stand FALSE FALSE
6 29 male urine public clean stand FALSE FALSE
The three factors in the factorial layout are "task", "space" and
"cleanliness". The response variable is the binary variable "sit".
This model allows me to block by participant ("id").
> glmer(sit ~ space*task*cleanliness + (1|id), family = binomial, data = posture.df)
I would like to model the effects of demographics, such as "sex".
The demographics were measured at the person level. If I wanted to
look at the effects of these demographics for only one of the 12
treatment combinations, I could do thus something like this.
> glm(sit ~ sex*height+school, family = binomial, data = subset(posture.df,space=='public'&cleanliness=='unspecified'&task=='defecate'))
I would prefer, of course, to look at these effects on all 12
treatment combinations simultaneously. So how do I include the
demographics?
Thanks
Tom
More information about the R-sig-mixed-models
mailing list