Hi, I am working with a random intercept model. I have the usual "X" vector of covariates and one id variable which will make up the random intercept. Now I wish to add group-level predictors (which are NOT in the X vector) such that the random intercept depends on these predictors. For example, Response variable: Production of maize Covariate: Size of plot Group-level predictor: Age of farmer ID variable: Household_ID I wish to confirm the syntax for including the group-level "Age of farmer" variable. fit<-lmer(Production~ Size+ Age+ (1|Household_ID), data=data) Is this correct or is there another way of declaring the group-level predictor in the formula? Thank you
Syntax for adding group-level predictors
2 messages · Yashree Mehta, Thierry Onkelinx
Dear Yashree, You added "Age" to the fixed effects. This assumes that the slope of Age is shared among all household. Which makes sense to me. For "Size" you have two options: Size + Age + (1|ID) or Age + (1 + Size|ID). The former assumes that the slope of Size is the same for each household (hence a 'fixed' slope). The latter assumes that each household has a different slope for Size (hence a 'random' slope). Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkelinx at inbo.be Havenlaan 88 bus 73, 1000 Brussel www.inbo.be /////////////////////////////////////////////////////////////////////////////////////////// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /////////////////////////////////////////////////////////////////////////////////////////// 2018-05-11 14:50 GMT+02:00 Yashree Mehta <yashree19 at gmail.com>:
Hi,
I am working with a random intercept model. I have the usual "X" vector of
covariates and one id variable which will make up the random intercept. Now
I wish to add group-level predictors (which are NOT in the X vector) such
that the random intercept depends on these predictors.
For example,
Response variable: Production of maize
Covariate: Size of plot
Group-level predictor: Age of farmer
ID variable: Household_ID
I wish to confirm the syntax for including the group-level "Age of farmer"
variable.
fit<-lmer(Production~ Size+ Age+ (1|Household_ID), data=data)
Is this correct or is there another way of declaring the group-level
predictor in the formula?
Thank you
[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models