afex icon indicating copy to clipboard operation
afex copied to clipboard

mixed/lmer_alt do not work with splines in formula

Open singmann opened this issue 8 years ago • 0 comments

library("afex")
library("splines")

summary(lmer(Reaction ~ ns(Days, df = 3) + (ns(Days, df = 3) || Subject),
                    data = sleepstudy))$varcor
## Groups    Name              Std.Dev. Corr       
## Subject   (Intercept)       24.616              
## Subject.1 ns(Days, df = 3)1 56.662              
##           ns(Days, df = 3)2 64.683   0.566      
##           ns(Days, df = 3)3 47.919   0.435 0.717
## Residual                    21.024     

summary(lmer_alt(Reaction ~ ns(Days, df = 3) + (ns(Days, df = 3) || Subject),
                    data = sleepstudy))$varcor
## Numerical variables NOT centered on 0 (i.e., interpretation of all main effects might be difficult if in interactions): Days
## Error in parse(text = x, keep.source = FALSE) : 
##   <text>:1:50: unexpected numeric constant
## 1: Reaction~ns(Days, df = 3)+(1+re1.ns(Days, df = 3)1
##                                                      ^

Example taken from R-sig-mixed: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2017q4/026226.html

singmann avatar Nov 29 '17 09:11 singmann