Error in contrasts(this_fixed_data) : contrasts apply only to factors

261 views
Skip to first unread message

Michael Bishop

unread,
Dec 3, 2012, 11:05:55 PM12/3/12
to ez...@googlegroups.com
Thanks so much for your continued help.   The subject lists the error I'm getting when I attempt ezPredict as shown below.
continuous variables: avrank.zgs  and gpa.n.z
factors:  race5f and sschlcde2 (technically its "labelled")

lme.avrank.zgs <- lmer(avrank.zgs ~ 1 + (1|sschlcde2) + race5f + gpa.n.z
                    , data=avr, na.action="na.exclude" )

> p.lme.avrank.zgs = ezPredict(
+   fit = lme.avrank.zgs
+   , numeric_res = 10
+ )
Error in contrasts(this_fixed_data) : contrasts apply only to factors


Michael Bishop

unread,
Dec 9, 2012, 3:13:11 PM12/9/12
to ez...@googlegroups.com
I'm still getting:
Error in contrasts(this_fixed_data) : contrasts apply only to factors
when I try to use ezPredict on my data.  I have tried using a few different continuous outcome variables, and a number of different fixed and random predictors and always get the same error... I don't get the error when I use a gamm4 model, and set "fit = gam.avrank.zgs$gam"  nor do I have a problem when I use the ANT data and an lmer model.

Many sincere thanks if you can give me any help.
Mike

Joerg Stephan

unread,
Aug 3, 2017, 6:15:13 AM8/3/17
to ez4r


On Sunday, 9 December 2012 21:13:11 UTC+1, Michael Bishop wrote:
I'm still getting:
Error in contrasts(this_fixed_data) : contrasts apply only to factors
when I try to use ezPredict on my data.  I have tried using a few different continuous outcome variables, and a number of different fixed and random predictors and always get the same error... I don't get the error when I use a gamm4 model, and set "fit = gam.avrank.zgs$gam"  nor do I have a problem when I use the ANT data and an lmer model.

Many sincere thanks if you can give me any help.
Mike


Hi,
I got the same message ("Error in contrasts(this_fixed_data) : contrasts apply only to factors"). However, I realized it was because I centered and scaled the continuous variable within the model. The solution was to scale the variable within the data frame (e.g. data$x.sc<-scale(x)) and than use x.sc in the model instead of x.
Best
jörg
 
Reply all
Reply to author
Forward
0 new messages