[R] Help with lmer formula
Joshua Wiley
jwiley.psych at gmail.com
Tue Jul 3 06:31:13 CEST 2012
Hi Camila,
In mixed equation form instead of multilevel, it would be:
Y_it = gamma_00 + gamma_10*X_it + gamma_11*W_it*X + (e_it + u_0t + u_1j*X)
your code seems reasonable. Note that the random intercept and slope
will be correlated in your specification (unstructured if you want, it
is possible to force out, but is sensible starting place)
model <- lmer(Y ~ X + X:W + (X | ID), data = data)
which gives:
residual variance: e_it
variance of intercept (constant term, gamma_00): u_0t
variance of slope (gamma_10): u_1j*X
as well as overall estimates for the intercept, slope of X, and the
interaction of X and W.
Bert is correct that R sig mixed models is the more appropriate list,
but many people read both and there is no reason it cannot be answered
here.
Cheers,
Josh
On Mon, Jul 2, 2012 at 6:47 PM, Camila Mendes <cacamendes85 at gmail.com> wrote:
> Hey all -
>
> I am a newbie on mixed-effects models. I want to estimate the following
> model:
>
> Y_it = alpha_0t + alpha_1t*X_it + e_it
> alpha_0t = gamma_00 + u_0t
> alpha_1t = gamma_10 + gamma_11*W_it + u_1j
>
> Where Y is my outcome, X is my level-1 predictor, and W is my level 2
> predictor.
>
> I am not sure if I am doing it right. Is this the correct specification of
> the formula?
>
> model = lmer(Y ~ X + X:Y + ( X | ID), data = data)
>
> Also, can you help me to write down the combined model formula? I tried
> by substituting on the first equation, but I got some weird interactions
> with the residual (?)
>
> Thanks a lot!
>
> - Camila
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
More information about the R-help
mailing list