[R-sig-ME] Calculation of random effects for factors in R
Sudell, Maria [mesudell]
M.E.Sudell at liverpool.ac.uk
Tue Jul 28 16:01:49 CEST 2015
Hello,
I have a question concerning exactly how random effects for a factor are calculated in R. I have tried to find an answer on various R related websites and text books but cannot find a definitive explanation.
As an example, if you had a longitudinal dataset, and you wanted to include an individual specific random effect for a smoking factor (say 3 levels, current, ex, never), how would the random effects be calculated using R? (I understand how to code this in R, I am aiming to understand the mechanics of how the function gets to the random effects).
My understanding so far would be that indicator variables for each of the levels of the factor would be included (in this case 3 indicator variables of 0,1, one for each of current, ex, never). Then coefficients for the indicator variables would be found (so for each individual in the dataset, we would end up with a coefficient for one of the indicator variables, assuming that individuals can't be in more than one group). These random coefficients (one for each individual as each individual would only fall into one smoking status) would then have their mean and variation calculated, in order to report the distribution of the random effect. Is this correct?
Apologies for such a simple question. Any help or explanation (or point to relevant paper or textbook) of how random effects are calculated for factors in R would be greatly appreciated.
Many thanks
Maria
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list