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 + Ffixed effects(K|F)random slope ofKvarying onGand(Z|G/F/K)random slope ofZvarying onKnested inFnested inG. Also, while you use\rather then:, this translates to:(Z|G) + (Z|G:F) + (Z|G:F:K). You do not use0 +or- 1in 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
Kis both the random slope and grouping variable for random effects - is it for purpose?Check an article by Bates et al. (in press) on
lme4and formulas in this package.