moleps
2010-Aug-29 19:13 UTC
[R] glm prb (Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : )
glm(A~B+C+D+E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : contrasts can be applied only to factors with 2 or more levels however, glm(A~B+C+D+E,family = binomial(link = "logit"),data=tre,na.action=na.omit) runs fine glm(A~B+C+D+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) runs fine glm(A~E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : contrasts can be applied only to factors with 2 or more levels Why is this? Could it be due to collinearity between the two? Regards, //M
David Winsemius
2010-Aug-29 20:24 UTC
[R] glm prb (Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : )
On Aug 29, 2010, at 3:13 PM, moleps wrote:> > glm(A~B+C+D+E+F,family = binomial(link = > "logit"),data=tre,na.action=na.omit) > Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : > contrasts can be applied only to factors with 2 or more levels > > however, > > glm(A~B+C+D+E,family = binomial(link = > "logit"),data=tre,na.action=na.omit) > > runs fine > > glm(A~B+C+D+F,family = binomial(link = > "logit"),data=tre,na.action=na.omit) > > runs fine > > > > glm(A~E+F,family = binomial(link = > "logit"),data=tre,na.action=na.omit) > Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : > contrasts can be applied only to factors with 2 or more levels > > Why is this? Could it be due to collinearity between the two?Perhaps, at least to the extent that the term "collinearity" is an appropriate term for factor interactions. The obvious question at this point is: What does: with( tre, table(E,F) ) # show? -- David Winsemius, MD West Hartford, CT
peter dalgaard
2010-Aug-30 08:35 UTC
[R] glm prb (Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : )
On Aug 29, 2010, at 10:24 PM, David Winsemius wrote:> > On Aug 29, 2010, at 3:13 PM, moleps wrote: > >> >> glm(A~B+C+D+E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) >> Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : >> contrasts can be applied only to factors with 2 or more levels >> >> however, >> >> glm(A~B+C+D+E,family = binomial(link = "logit"),data=tre,na.action=na.omit) >> >> runs fine >> >> glm(A~B+C+D+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) >> >> runs fine >> >> >> >> glm(A~E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) >> Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : >> contrasts can be applied only to factors with 2 or more levels >> >> Why is this? Could it be due to collinearity between the two? > > Perhaps, at least to the extent that the term "collinearity" is an appropriate term for factor interactions. The obvious question at this point is: What does: > > with( tre, table(E,F) ) # show?Yes. Also notice the pattern of missing values. A likely scenario for the error would be to have E and F being something like "gender" and "menarche", where the latter is absent for boys. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com