[R-sig-ME] HELP: Got error message in R lme4!
Andrew Dolman
andydolman at gmail.com
Wed Jul 14 10:29:58 CEST 2010
Hi Chester,
When I get that error message it is usually fixed by making sure that
the random variables are stored as factors. e.g. as.factor(id)
lmer() normally coerces things to factors when they are on the right
hand side of | but sometimes this seems to be broken.
Andy.
andydolman at gmail.com
On 13 July 2010 19:22, Chester Kam <chesterkam at gmail.com> wrote:
> Dear all,
>
>
>
> Hi, a few days ago I have posted a message to my problem. Thank you very
> much for your help! Now I wonder if any of you can help me with my linear
> mixed model with R because I got an error message in R. I tried to
> google the solution, but to no avail. To recall, I am trying to predict
> manager's performance with one fixed effect and two random effects. The
> fixed effect is scoring method (only 2 different methods), and the random
> effects are the type of exercise (interpersonal, in-baskets... together 9
> different exercises) and the managers in the study (46 managers, this
> variable is named id in the datafile).
>
>
>
> Therefore, all 46 managers engage in all 9 exercises. Each of the exercises
> was assessed two ways.
>
>
>
> I do not have problems when I examine the main effect of the variables
> (performance ~ method + (1|id) + (1|exercise). However, I start to encounter
> problems when I examine the interactions between these three variables. I
> wonder if you have any clues why it is the case.
>
>
>
> *When I just try to examine the main effects (without interactions), the
> result is fine:*
>
> * *
>
> *> Model1 <- lmer(performance ~ method + (1|id) + (1|exercise), data=mtmm)*
>
> *> summary (Model1)*
>
> Linear mixed model fit by REML
>
> Formula: performance ~ method + (1 | id) + (1 | exercise)
>
> Data: mtmm
>
> AIC BIC logLik deviance REMLdev
>
> 1617 1641 -803.6 1599 1607
>
> Random effects:
>
> Groups Name Variance Std.Dev.
>
> id (Intercept) 0.113182 0.33642
>
> exercise (Intercept) 0.020629 0.14363
>
> Residual 0.358530 0.59877
>
> Number of obs: 827, groups: id, 46; exercise, 9
>
> Fixed effects:
>
> Estimate Std. Error t value
>
> (Intercept) 3.57527 0.07497 47.69
>
> method 0.13553 0.04164 3.25
>
> Correlation of Fixed Effects:
>
> (Intr)
>
> method -0.278
>
>
>
> *Problems occurs, however, when I specify intearctions. For example:*
>
> * *
>
> *(BETWEEN TWO RANDOM EFFECTS)***
>
> *> Model1 <- lmer(performance ~ method + (1|id) + (1|exercise) +
> (1|id:exercise), data=mtmm)*
>
> Error: length(f1) == length(f2) is not TRUE
>
> In addition: Warning messages:
>
> 1: In id:exercise :
>
> numerical expression has 827 elements: only the first used
>
> 2: In id:exercise :
>
> numerical expression has 827 elements: only the first used
>
>
>
> *(BETWEEN ONE FIXED EFFECT AND ONE RANDOM EFFECT)*
>
> *> Model1 <- lmer(performance ~ method + (1|id) + (1|exercise) +
> (1|method:exercise), mtmm)*
>
> Error: length(f1) == length(f2) is not TRUE
>
> In addition: Warning messages:
>
> 1: In method:exercise :
>
> numerical expression has 827 elements: only the first used
>
> 2: In method:exercise :
>
> numerical expression has 827 elements: only the first used
>
> * *
>
> *The descriptive statistics of the data is as follow:*
>
> *> summary(mtmm)*
>
> id exercise method performance
>
> 40,873 : 18 Min. :1.000 Min. :0.0000 Min. :1.000
>
> 40,888 : 18 1st Qu.:3.000 1st Qu.:0.0000 1st Qu.:3.200
>
> 40,894 : 18 Median :5.000 Median :1.0000 Median :3.670
>
> 40,897 : 18 Mean :4.996 Mean :0.5006 Mean :3.643
>
> 40,903 : 18 3rd Qu.:7.000 3rd Qu.:1.0000 3rd Qu.:4.200
>
> 40,915 : 18 Max. :9.000 Max. :1.0000 Max. :5.000
>
> (Other):719
>
> * *
>
> *A sample data is as follow:*
>
> id
>
> exercise
>
> method
>
> performance
>
> 40873
>
> 1
>
> 0
>
> 3.2
>
> 40873
>
> 1
>
> 1
>
> 3
>
> 40873
>
> 2
>
> 0
>
> 3.2
>
> 40873
>
> 2
>
> 1
>
> 3.8
>
> 40873
>
> 3
>
> 0
>
> 4.8
>
> 40873
>
> 3
>
> 1
>
> 4
>
> 40873
>
> 4
>
> 0
>
> 2.2
>
> 40873
>
> 4
>
> 1
>
> 3.2
>
> 40873
>
> 5
>
> 0
>
> 4.73
>
> 40873
>
> 5
>
> 1
>
> 4.73
>
> 40873
>
> 6
>
> 0
>
> 4.4
>
> 40873
>
> 6
>
> 1
>
> 3
>
> 40873
>
> 7
>
> 0
>
> 3.57
>
> 40873
>
> 7
>
> 1
>
> 3.92
>
> 40873
>
> 8
>
> 0
>
> 3.8
>
> 40873
>
> 8
>
> 1
>
> 3.8
>
> 40873
>
> 9
>
> 0
>
> 4.27
>
> 40873
>
> 9
>
> 1
>
> 3.96
>
> 40888
>
> 1
>
> 0
>
> 2.4
>
> 40888
>
> 1
>
> 1
>
> 3
>
> 40888
>
> 2
>
> 0
>
> 3.6
>
> 40888
>
> 2
>
> 1
>
> 2.4
>
> 40888
>
> 3
>
> 0
>
> 3.4
>
> 40888
>
> 3
>
> 1
>
> 3
>
> 40888
>
> 4
>
> 0
>
> 3.8
>
> 40888
>
> 4
>
> 1
>
> 3.4
>
> 40888
>
> 5
>
> 0
>
> 2.87
>
> 40888
>
> 5
>
> 1
>
> 3.13
>
> 40888
>
> 6
>
> 0
>
> 3.4
>
> 40888
>
> 6
>
> 1
>
> 3.8
>
> 40888
>
> 7
>
> 0
>
> 4.75
>
> 40888
>
> 7
>
> 1
>
> 4.58
>
> 40888
>
> 8
>
> 0
>
> 3.1
>
> 40888
>
> 8
>
> 1
>
> 4.2
>
> 40888
>
> 9
>
> 0
>
> 3.79
>
> 40888
>
> 9
>
> 1
>
> 2.48
>
> *So I wonder what is wrong in my setup. Or, I need a supercomputer, with
> plenty of processing power, in order to assess my data?*
>
> * *
>
> *In addition, I wonder if there is a difference between (1|exercise:method)
> and (1|method:exercise), or between (1|exercise:id) and (1|id:exercise)?*
>
> * *
>
> *Thanks so much for help me again! I appreciate it a lot!*
>
> * *
>
> *Chester*
>
> *PhD Candidate*
>
> *University of Western Ontario*
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list