[R-sig-ME] Can we do b-spline within lmer function?

Andy Fugard a.fugard at ed.ac.uk
Fri Jan 18 20:19:59 CET 2008


Ken Beath wrote:
> On 15/01/2008, at 9:42 AM, Zhong, Xiao wrote:
> 
>> Thanks, Ken.
>>
>> I tried your advice on my model:
>>
>> model2.growth.mcas5 <- lmer(response ~ bs(monthElapsed) + skills +  
>> (1|studentID), data= mcas5, family=binomial(link="logit"), control =
>> list(msVerbose = 1, usePQL = FALSE))
>>
>> It worked! What it gave me is:
>>
>>                      (Intercept)                   
>> bs(monthElapsed)1                   
>> bs(monthElapsed)2                  bs(monthElapsed)3
>>                        -0.1509712                           
>> 0.7019262                          
>> -0.1934738                          0.6257330
>>                  skillsG-Geometry                skillsM- 
>> Measurement    skillsN-Number-Sense-Operations skillsP-Patterns- 
>> Relations-Algebra
>>                        -0.4333880                          
>> -0.9468761                           
>> 0.5263370                          0.1897903
>>
>> Since I am trying to use design matrix to predict after that glmm  
>> fitting, could you tell me if there is some function/command that I  
>> can use to find what the three "bs" did to my "monthElapsed" variable?
>>
> 
> As Vito mentioned you probably need a few more knots, see the help on  
> bs. The spline models I have fitted have been in lme and have used  
> predict to obtain the shape of the curves, but this doesn't seem  
> available in lmer.

I have been reading this thread with interest.  When bs uses only a 
cubic, presumably it's easy to wire up a custom predict function based 
on the fixed effects, using coef - for this example piping the output 
through the inverse logit function to get back something in [0,1].  But 
what does the formula look like when you use proper splines?  I can't 
get that from the help.

Andy




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