I have the following SAS code that I would like to write in R. I know the class statement is redundant in R (not necessary).
proc mixed data=in_data;
class G F K kal;
model conc=;
random G F K(F) kal(G*F*K);
ods output covparms=out.cov_out;
run;
I tried the below code, with no luck.
fit <- lmer( conc ~ (1 | G) + (1 | F) + (1 | K/F) + (1 | kal/G:F:K) , sample_1)
with the following output. I was hoping not to get a value for kal or K.
summary(fit)
Random effects:
Groups Name Variance Std.Dev.
G:F:K:kal (Intercept) 1.421e-04 0.011921
F:K (Intercept) 1.326e-05 0.003641
F (Intercept) 6.548e-05 0.008092
kal (Intercept) 9.852e-06 0.003139
K (Intercept) 1.272e-05 0.003567
G (Intercept) 2.165e-03 0.046527
Residual 4.647e-04 0.021557
Your formula translates to:
conc ~
value is modelled usingG + F
fixed effects(K|F)
random slope ofK
varying onG
and(Z|G/F/K)
random slope ofZ
varying onK
nested inF
nested inG
. Also, while you use\
rather then:
, this translates to:(Z|G) + (Z|G:F) + (Z|G:F:K)
. You do not use0 +
or- 1
in your definition, so intercept is included.So your model translates to:
conc ~ 1 + G + F + (1 + K|F) + (1 + Z|G) + (1 + Z|G:F) + (1 + Z|G:F:K)
. Is this what you wanted?What may be problematic is that in your definition
K
is both the random slope and grouping variable for random effects - is it for purpose?Check an article by Bates et al. (in press) on
lme4
and formulas in this package.