Skip to content
Prev 67700 / 398506 Next

multinom and contrasts

Dear John,

My dataset has a response variable with 6 levels, and 
12 independent variables, 10 of them are continuous
variable, one is a categorical variable with 2 levels,
the other one is also a categorical variable with 4
levels. total 206 observations. I attached my dataset
with the email "sample.txt".

library(MASS)
library(nnet)

sample<-read.table("sample.txt",sep='\t',header=T,row.names=1)
wts2<-sample$wts
sample<-sample[,-4]

options(contrasts=c('contr.helmert','contr.poly'))
obj1<-multinom(class~.,sample,weights=wts2,maxit=1000)
options(contrasts=c('contr.treatment','contr.poly'))
obj2<-multinom(class~.,sample,weights=wts2,maxit=1000)

predict(obj1,type='probs')[1:5,]
predict(obj2,type='probs')[1:5,]

Interestingly, if I change the values of the variable
"bkgd" for 2 observations (from "a", to "f"), then I
can get convergence with helmert contrast, but still
not converged with treatment contrast:

sample$bkgd[201]<-'f'
sample$bkgd[205]<-'f'

options(contrasts=c('contr.helmert','contr.poly'))
obj1<-multinom(class~.,sample,weights=wts2,maxit=1000)
options(contrasts=c('contr.treatment','contr.poly'))
obj2<-multinom(class~.,sample,weights=wts2,maxit=1000)

predict(obj1,type='probs')[1:5,]
predict(obj2,type='probs')[1:5,]

appreciate any suggestions!
--- John Fox <jfox at mcmaster.ca> wrote:

            
xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),],
xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),],
xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),])
xx<-multinom(Type~Infl+Cont,data=housing[-c(1,10,11,22,25,30),])
obj.glm<-glm(Cont~Infl+Type,family='binomial',data=housing[-c(
obj.glm<-glm(Cont~Infl+Type,family='binomial',data=housing[-c(
__________________________________ 


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sample.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050414/bc7de7fc/sample.txt