Skip to content
Prev 12442 / 20628 Next

Problem with profile and glmer

It works with replacing

 thedata <- data.frame(herd,incidence,size,period)

with 

 thedata <<- data.frame(herd,incidence,size,period)

 so it seems that when searching for thedata, glmer searches in the
 parent environnement of testprofile() and not in the local
 environnement of testprofile().

I guess it has to do with the line

glmod <- eval(mc, parent.frame(1L))

but my knowledge stops here...

Hope that will help as a workaround until developpers find a fix for
that...
On Mon, Sep 15, 2014 at 02:21:37PM +1000, Ken Beath wrote:
? With the following code
? 
? library(lme4)
? data(cbpp)
? 
? testprofile <- function(herd,incidence,size,period) {
?   thedata <- data.frame(herd,incidence,size,period)
?   gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
?               data = thedata, family = binomial)
?   pr4 <- profile(gm1)
? }
? 
? testprofile(cbpp$incidence,cbpp$incidence,cbpp$size,cbpp$period)
? 
? I get the error in profile " Error: 'data' not found, but variables found
? in environment of formula: try specifying 'formula' as a formula rather
? than a string in the original model"
? 
? I have tried with as.formula for the formula. The profile and glmer work
? fine when they are called outside the function.
? -- 
? 
? *Ken Beath*
? Lecturer
? Statistics Department
? MACQUARIE UNIVERSITY NSW 2109, Australia
? 
? Phone: +61 (0)2 9850 8516
? 
? Building E4A, room 526
? http://stat.mq.edu.au/our_staff/staff_-_alphabetical/staff/beath,_ken/
? 
? CRICOS Provider No 00002J
? This message is intended for the addressee named and may...{{dropped:9}}
? 
? _______________________________________________
? R-sig-mixed-models at r-project.org mailing list
? https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models