Running examples in ‘afex-Ex.R’ failed
The error most likely occurred in:

> ### Name: mixed
> ### Title: p-values for fixed effects of mixed-model via lme4::lmer()
> ### Aliases: lmer_alt mixed
> 
> ### ** Examples
> 
> 
> ###########################
> ## Full Analysis Example ##
> ###########################
> 
> ## Not run: 
> ##D ### split-plot experiment (Singmann & Klauer, 2011, Exp. 2)
> ##D ## between-factor: instruction
> ##D ## within-factor: inference & type
> ##D ## hypothesis: three-way interaction
> ##D data("sk2011.2")
> ##D 
> ##D # use only affirmation problems (S&K also splitted the data like this)
> ##D sk2_aff <- droplevels(sk2011.2[sk2011.2$what == "affirmation",])
> ##D 
> ##D # set up model with maximal by-participant random slopes 
> ##D sk_m1 <- mixed(response ~ instruction*inference*type+(inference*type|id), sk2_aff)
> ##D 
> ##D sk_m1 # prints ANOVA table with nicely rounded numbers (i.e., as characters)
> ##D nice(sk_m1)  # returns the same but without printing potential warnings
> ##D anova(sk_m1) # returns and prints numeric ANOVA table (i.e., not-rounded)
> ##D summary(sk_m1) # lmer summary of full model
> ##D 
> ##D # suppressing correlation among random slopes:
> ##D # very similar results, but significantly faster and often better convergence. 
> ##D sk_m2 <- mixed(response ~ instruction*inference*type+(inference*type||id), sk2_aff,
> ##D                expand_re = TRUE)
> ##D sk_m2
> ##D 
> ##D ## mixed objects can be passed to lsmeans directly:
> ##D 
> ##D # recreates basically Figure 4 (S&K, 2011, upper panel)
> ##D # only the 4th and 6th x-axis position are flipped
> ##D lsmip(sk_m1, instruction~type+inference)
> ##D 
> ##D # set up reference grid for custom contrasts:
> ##D # this can be made faster via:
> ##D # lsm.options(disable.pbkrtest = TRUE)
> ##D (rg1 <- lsmeans(sk_m1, c("instruction", "type", "inference")))
> ##D 
> ##D # set up contrasts on reference grid:
> ##D contr_sk2 <- list(
> ##D   ded_validity_effect = c(rep(0, 4), 1, rep(0, 5), -1, 0),
> ##D   ind_validity_effect = c(rep(0, 5), 1, rep(0, 5), -1),
> ##D   counter_MP = c(rep(0, 4), 1, -1, rep(0, 6)),
> ##D   counter_AC = c(rep(0, 10), 1, -1)
> ##D )
> ##D 
> ##D # test the main double dissociation (see S&K, p. 268)
> ##D contrast(rg1, contr_sk2, adjust = "holm")
> ##D # only plausibility effect is not significant here.
> ## End(Not run)
> 
> ###################################################
> ## Replicating Maxwell & Delaney (2004) Examples ##
> ###################################################
> 
> ### replicate results from Table 15.4 (Maxwell & Delaney, 2004, p. 789)
> data(md_15.1)
> # random intercept plus slope
> (t15.4a <- mixed(iq ~ timecat + (1+time|id),data=md_15.1))
Contrasts set to contr.sum for the following variables: timecat, id
Fitting 2 (g)lmer() models:
[..]
Obtaining 1 p-values:
[.]
   Effect       df F.scaling    F p.value
1 timecat 3, 22.54      0.96 1.72     .19
> 
> # to also replicate exact parameters use treatment.contrasts and the last level as base level:
> contrasts(md_15.1$timecat) <- contr.treatment(4, base = 4)
> (t15.4b <- mixed(iq ~ timecat + (1+time|id),data=md_15.1, check.contrasts=FALSE))
Fitting 2 (g)lmer() models:
[..]
Obtaining 1 p-values:
[.]
   Effect       df F.scaling    F p.value
1 timecat 3, 22.54      0.96 1.72     .19
> summary(t15.4a)  # gives "wrong" parameters extimates
Linear mixed model fit by REML ['lmerMod']
Formula: iq ~ timecat + (1 + time | id)
   Data: md_15.1

REML criterion at convergence: 339.1

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.81430 -0.47911 -0.05763  0.57397  1.53583 

Random effects:
 Groups   Name        Variance Std.Dev. Corr 
 id       (Intercept) 168.0200 12.9623       
          time          0.3892  0.6239  -0.40
 Residual              37.4364  6.1185       
Number of obs: 48, groups:  id, 12

Fixed effects:
            Estimate Std. Error t value
(Intercept)  108.000      3.542  30.492
timecat1      -5.000      2.229  -2.244
timecat2      -1.000      1.622  -0.616
timecat3       2.000      1.622   1.233

Correlation of Fixed Effects:
         (Intr) timct1 timct2
timecat1 -0.025              
timecat2 -0.011  0.026       
timecat3  0.011 -0.458 -0.407
> summary(t15.4b)  # identical parameters estimates
Linear mixed model fit by REML ['lmerMod']
Formula: iq ~ timecat + (1 + time | id)
   Data: md_15.1

REML criterion at convergence: 336.4

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.81430 -0.47911 -0.05763  0.57397  1.53583 

Random effects:
 Groups   Name        Variance Std.Dev. Corr 
 id       (Intercept) 168.0197 12.9622       
          time          0.3892  0.6239  -0.40
 Residual              37.4364  6.1185       
Number of obs: 48, groups:  id, 12

Fixed effects:
            Estimate Std. Error t value
(Intercept)  112.000      4.231  26.470
timecat1      -9.000      4.092  -2.199
timecat2      -5.000      3.303  -1.514
timecat3      -2.000      2.722  -0.735

Correlation of Fixed Effects:
         (Intr) timct1 timct2
timecat1 -0.506              
timecat2 -0.493  0.749       
timecat3 -0.434  0.595  0.607
> 
> # for more examples from chapter 15 see ?md_15.1
> 
> ### replicate results from Table 16.3 (Maxwell & Delaney, 2004, p. 837)
> data(md_16.1)
> 
> # original results need treatment contrasts:
> (mixed1_orig <- mixed(severity ~ sex + (1|id), md_16.1, check.contrasts=FALSE))
Fitting 2 (g)lmer() models:
[..]
Obtaining 1 p-values:
[.]
  Effect   df F.scaling      F p.value
1    sex 1, 4      1.00 9.97 *     .03
> summary(mixed1_orig$full.model)
Linear mixed model fit by REML ['lmerMod']
Formula: severity ~ sex + (1 | id)
   Data: md_16.1

REML criterion at convergence: 155.2

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-1.8248 -0.4452 -0.1247  0.6843  1.4141 

Random effects:
 Groups   Name        Variance Std.Dev.
 id       (Intercept) 18.11    4.256   
 Residual             45.56    6.749   
Number of obs: 24, groups:  id, 6

Fixed effects:
            Estimate Std. Error t value
(Intercept)   60.000      3.136  19.134
sexmale      -14.000      4.435  -3.157

Correlation of Fixed Effects:
        (Intr)
sexmale -0.707
> 
> # p-value stays the same with afex default contrasts (contr.sum),
> # but estimates and t-values for the fixed effects parameters change.
> (mixed1 <- mixed(severity ~ sex + (1|id), md_16.1))
Contrasts set to contr.sum for the following variables: sex, id
Fitting 2 (g)lmer() models:
[..]
Obtaining 1 p-values:
[.]
  Effect   df F.scaling      F p.value
1    sex 1, 4      1.00 9.97 *     .03
> summary(mixed1$full.model)
Linear mixed model fit by REML ['lmerMod']
Formula: severity ~ sex + (1 | id)
   Data: md_16.1

REML criterion at convergence: 156.6

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-1.8248 -0.4452 -0.1247  0.6843  1.4141 

Random effects:
 Groups   Name        Variance Std.Dev.
 id       (Intercept) 18.11    4.256   
 Residual             45.56    6.749   
Number of obs: 24, groups:  id, 6

Fixed effects:
            Estimate Std. Error t value
(Intercept)   53.000      2.217  23.902
sex1           7.000      2.217   3.157

Correlation of Fixed Effects:
     (Intr)
sex1 0.000 
> 
> 
> # data for next examples (Maxwell & Delaney, Table 16.4)
> data(md_16.4)
> str(md_16.4)
'data.frame':	29 obs. of  6 variables:
 $ obs   : Factor w/ 29 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ room  : Factor w/ 3 levels "1","2","3": 1 1 1 1 2 2 2 2 2 2 ...
 $ cond  : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
 $ cog   : int  46 52 60 44 46 48 50 54 50 48 ...
 $ skill : int  4 4 4 4 6 6 6 6 6 6 ...
 $ induct: int  21 26 33 22 18 25 26 24 21 25 ...
> 
> ### replicate results from Table 16.6 (Maxwell & Delaney, 2004, p. 845)
> # Note that (1|room:cond) is needed because room is nested within cond.
> # p-value (almost) holds.
> (mixed2 <- mixed(induct ~ cond + (1|room:cond), md_16.4))
Contrasts set to contr.sum for the following variables: cond, room
Fitting 2 (g)lmer() models:
[..]
Obtaining 1 p-values:
[.]
  Effect      df F.scaling    F p.value
1   cond 1, 3.99      1.00 3.20     .15
> # (differences are dut to the use of Kenward-Roger approximation here,
> # whereas M&W's p-values are based on uncorrected df.)
> 
> # again, to obtain identical parameter and t-values, use treatment contrasts:
> summary(mixed2) # not identical
Linear mixed model fit by REML ['lmerMod']
Formula: induct ~ cond + (1 | room:cond)
   Data: md_16.4

REML criterion at convergence: 172.4

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.39742 -0.74219  0.04089  0.67433  1.93550 

Random effects:
 Groups    Name        Variance Std.Dev.
 room:cond (Intercept) 26.63    5.160   
 Residual              20.26    4.501   
Number of obs: 29, groups:  room:cond, 6

Fixed effects:
            Estimate Std. Error t value
(Intercept)   31.552      2.274  13.874
cond1         -4.074      2.274  -1.792

Correlation of Fixed Effects:
      (Intr)
cond1 -0.008
> 
> # prepare new data.frame with contrasts:
> md_16.4b <- within(md_16.4, cond <- C(cond, contr.treatment, base = 2))
> str(md_16.4b)
'data.frame':	29 obs. of  6 variables:
 $ obs   : Factor w/ 29 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ room  : Factor w/ 3 levels "1","2","3": 1 1 1 1 2 2 2 2 2 2 ...
 $ cond  : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "contrasts")= num [1:2, 1] 1 0
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr  "0" "1"
  .. .. ..$ : chr "1"
 $ cog   : int  46 52 60 44 46 48 50 54 50 48 ...
 $ skill : int  4 4 4 4 6 6 6 6 6 6 ...
 $ induct: int  21 26 33 22 18 25 26 24 21 25 ...
> 
> # p-value stays identical:
> (mixed2_orig <- mixed(induct ~ cond + (1|room:cond), md_16.4b, check.contrasts=FALSE))
Fitting 2 (g)lmer() models:
[..]
Obtaining 1 p-values:
[.]
  Effect      df F.scaling    F p.value
1   cond 1, 3.99      1.00 3.20     .15
> summary(mixed2_orig$full.model) # replicates parameters
Linear mixed model fit by REML ['lmerMod']
Formula: induct ~ cond + (1 | room:cond)
   Data: md_16.4b

REML criterion at convergence: 171

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.39742 -0.74219  0.04089  0.67433  1.93550 

Random effects:
 Groups    Name        Variance Std.Dev.
 room:cond (Intercept) 26.63    5.160   
 Residual              20.26    4.501   
Number of obs: 29, groups:  room:cond, 6

Fixed effects:
            Estimate Std. Error t value
(Intercept)   35.626      3.229  11.032
cond1         -8.148      4.548  -1.792

Correlation of Fixed Effects:
      (Intr)
cond1 -0.710
> 
> 
> ### replicate results from Table 16.7 (Maxwell & Delaney, 2004, p. 851)
> # F-values (almost) hold, p-values (especially for skill) are off
> (mixed3 <- mixed(induct ~ cond + skill + (1|room:cond), md_16.4))
Contrasts set to contr.sum for the following variables: cond, room
Numerical variables NOT centered on 0 (i.e., interpretation of all main effects might be difficult if in interactions): skill
Fitting 3 (g)lmer() models:
[...]
Obtaining 2 p-values:
[..]
  Effect      df F.scaling      F p.value
1   cond 1, 3.02      1.00 7.66 +     .07
2  skill 1, 3.27      1.00 8.12 +     .06
> 
> # however, parameters are perfectly recovered when using the original contrasts:
> mixed3_orig <- mixed(induct ~ cond + skill + (1|room:cond), md_16.4b, check.contrasts=FALSE)
Numerical variables NOT centered on 0 (i.e., interpretation of all main effects might be difficult if in interactions): skill
Fitting 3 (g)lmer() models:
[...]
Obtaining 2 p-values:
[..]
> summary(mixed3_orig)
Linear mixed model fit by REML ['lmerMod']
Formula: induct ~ cond + skill + (1 | room:cond)
   Data: md_16.4b

REML criterion at convergence: 164.5

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.40177 -0.69562 -0.06924  0.51685  2.01182 

Random effects:
 Groups    Name        Variance Std.Dev.
 room:cond (Intercept)  6.572   2.564   
 Residual              20.274   4.503   
Number of obs: 29, groups:  room:cond, 6

Fixed effects:
            Estimate Std. Error t value
(Intercept)  20.2521     5.8201   3.480
cond1        -7.5686     2.7163  -2.786
skill         2.3092     0.8086   2.856

Correlation of Fixed Effects:
      (Intr) cond1 
cond1 -0.347       
skill -0.944  0.119
> 
> 
> ### replicate results from Table 16.10 (Maxwell & Delaney, 2004, p. 862)
> # for this we need to center cog:
> md_16.4b$cog <- scale(md_16.4b$cog, scale=FALSE)
> 
> # F-values and p-values are relatively off:
> (mixed4 <- mixed(induct ~ cond*cog + (cog|room:cond), md_16.4b))
Contrasts set to contr.sum for the following variables: cond, room
Fitting 4 (g)lmer() models:
[....]
Obtaining 3 p-values:
[.
 *** caught segfault ***
address 9, cause 'memory not mapped'