[R-sig-ME] Fwd: Advice on Mixed Models

Rose Rosei roserosei2030 at gmail.com
Sat Mar 11 14:17:59 CET 2017


Many thanks, Professor Bolker- Very Much appriciated

When I use this model:

lmer(mark~ (1|A)+(1+D)+(1|S)+(1|Q)+ S1+ (1|S1/D/S/A), R) # session as a
fiexed effect

I got the following results, which are not consistent with the SPSS Output
( Variance Components)

Linear mixed model fit by REML ['lmerMod']
Formula: mark ~ (1 | A) + (1 + D) + (1 | S) + (1 | Q) + S1 + (1 | S1/D/S/A)
   Data: R
REML criterion at convergence: 190.5212
Random effects:
 Groups       Name        Std.Dev.
 A:(S:(D:S1)) (Intercept) 0.9581
 A            (Intercept) 0.7198
 Q            (Intercept) 0.0000
 S:(D:S1)     (Intercept) 0.0000
 D:S1         (Intercept) 0.0000
 S1           (Intercept) 1.1411
 S            (Intercept) 0.0000
 Residual                 0.6722
Number of obs: 80, groups:  A:(S:(D:S1)), 10; A, 10; Q, 8; S:(D:S1), 7;
D:S1, 4; S1, 2; S, 2
Fixed Effects:
(Intercept)            D           S1
    2.31250      0.02679     -0.59821
convergence code 0; 2 optimizer warnings; 0 lme4 warnings

SPSS output

*Variance Estimates*

Component

Estimate

Var(A)

2.443

Var(D)

-.302a

Var(S1)

-.348a

Var(O)

.093

Var(A * D)

.000b

Var(A * S1)

.000b

Var(A * O)

.548

Var(A * S)

.000b

Var(D * S1)

.139

Var(D * O)

-.074a

Var(D * S)

.554

Var(S1 * O)

-.210a

Var(S1 * S)

.644

Var(O * S)

-.124a

Var(A * D * S1)

.000b

Var(A * D * O)

.000b

Var(A * D * S)

.000b

Var(A * S1 * O)

.000b

Var(A * S1 * S)

.000b

Var(A * O * S)

.000b

Var(D * S1 * O)

.090

Var(D * S1 * S)

-1.834a

Var(D * O * S)

.070

Var(S1 * O * S)

.338

Var(A * D * S1 * O)

.000b

Var(A * D * S1 * S)

.000b

Var(A * D * O * S)

.000b

Var(A * S1 * O * S)

.000b

Var(D * S1 * O * S)

-.276a

Var(A * D * S1 * O * S)

.000b

Var(Error)

.000b

Dependent Variable: mark

 Method: Minimum Norm Quadratic Unbiased Estimation (Weight = 1 for Random
Effects and Residual)

a. For the ANOVA and MINQUE methods, negative variance component estimates
may occur. Some possible reasons for their occurrence are: (a) the
specified model is not the correct model, or (b) the true value of the
variance equals zero.

b. This estimate is set to zero because it is redundant.

When I use this model:
lmer(mark~ (1|A)+(1+D)+(1|S)+(1|Q)+ S1+ (1|S1:D/S/A), R)

I got the follwowig error

Error: couldn't evaluate grouping factor A:(S:(S1:`:`)) within model frame:
try adding grouping factor to data frame explicitly if possible
In addition: Warning message:
In S1:`:` : numerical expression has 80 elements: only the first used;

Would you advise me what went wrong with the model.

Many thanks,
Rose

On Fri, Mar 10, 2017 at 11:59 PM, Ben Bolker <bbolker at gmail.com> wrote:

>
>
> On 17-03-08 02:01 PM, Rose Rosei wrote:
> > Dear Advisors
> >
> > Would you please advise me. I would like to fit my model, but I struggled
> > to do it
> >
> >
> >   A= Applicant = 10 persons
> >   S= Stream ( four levels, 1, 2)
>
>   Not sure what "four levels, 1, 2" means here.  Do you mean "four
> levels, 1-4" ... ?
>
> >   D= Day   (1,2)
> >  S1= Session ( 1,2)
> >  Q = Qestion ( 1-to 8)
> >  Applicants are crossed in Questions, but Applicants nested in Stream,
> >   nested in Day, nested in session (S1). All variables are a a random
> factor
>
>   You need to know that **with modern mixed-model machinery (e.g. nlme,
> lme4 as opposed to aov() in R) it is not in general practical to
> estimate random-effects terms for variables with fewer than 5 or 6
> levels**.
> See e.g. http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#singu
> lar-fit
>
> >
> >    I want to calculate SD for A, S, D, S1 and Q, and their interaction
> > .score=dependent variable
> >
> >  I have used the following codes, but it seems they are wrong.
> >
> >  lmer(score~ (1|A)+(1|S)+(1+D)+(1|S1)+(1|Q)
> +(1|A/S)+1|S/D)+(1|D/S1)+(1|S1/Q),
> > R)
>
>   (1|S1/D/S/A) gives "Applicants nested in Stream, nested in Day, nested
> in session (S1)".  As I said above, it would be wiser if possible to use
> S1+ (1|S1:D/S/A) (i.e. treat session as a fixed effect).
> I would probably handle questions via (1|Q); if each applicant receives
> each question no more than once within a session/day/stream combination,
> then the S1:D:S:A:Q interaction will be handled by the residual variance
> term.
>
> In addition to the problems stated above, many of these terms are
> redundant.  The nesting syntax (1|A/S) expands to (1|A) + (1|A:S) (i.e.
> variability among levels of A, and variability among the interacting
> levels of A and S). Fitting a crossed term as compactly as possible
> would use (1|A*S), but I think this doesn't actually work: (1|A) + (1|S)
> or (1|A:S) or (1|A/S)+(1|S) both describe crossed random effects of A
> and S.  You may also have the nesting order backwards: (1|A/S) means
> "Stream nested within Applicants", not "Applicants nested within Stream".
>
>
> >
> > Linear mixed model fit by REML ['lmerMod']
> > Formula: score ~ (1 | A) + (1 | S) + (1 + D) + (1 | S1) + (1 | Q) + (1 |
> >     A/S) + (1 | S/D) + (1 | D/S1) + (1 | S1/Q)
> >    Data: R
> > REML criterion at convergence: 192.4591
> > Random effects:
> >  Groups   Name        Std.Dev.
> >  Q.S1     (Intercept) 0.000e+00
> >  A        (Intercept) 2.383e-01
> >  S.A      (Intercept) 7.692e-01
> >  A.1      (Intercept) 8.399e-01
> >  Q        (Intercept) 0.000e+00
> >  S1.D     (Intercept) 1.386e-08
> >  D.S      (Intercept) 0.000e+00
> >  S1       (Intercept) 0.000e+00
> >  D        (Intercept) 9.498e-01
> >  S        (Intercept) 0.000e+00
> >  S1.1     (Intercept) 0.000e+00
> >  S.1      (Intercept) 0.000e+00
> >  Residual             6.722e-01
> > Number of obs: 80, groups:
> > Q:S1, 16; A, 10; S:A, 10; Q, 8; S1:D, 4; D:S, 4; S1, 2; D, 2; S, 2
> > Fixed Effects:
> > (Intercept)            D
> >     1.61458     -0.07292
> > convergence code 0; 2 optimizer warnings; 0 lme4 warnings
> >
> >    Very much appreciated for your help.
> > looking forward to hearing from you.
> >    Rose
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list