Skip to content

multinom and contrasts

4 messages · John Fox, array chip

#
Dear John,

Thanks for the answer! In my own dataset, The
multinom() did not converge even after I had tried to
increase the maximum number of iteration (from default
100 to 1000). In this situation, there is some bigger
diffrenece in fitted probabilities under different
contrasts (e.g. 0.9687817 vs. 0.9920816). My question
is whether the analysis (fitted probabilities) is
still valid if it does not converge? and what else can
I try about it?

Thank you!
--- 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(
#
Dear chip,
If multinom() doesn't converge to a stable solution after 1000 iterations,
it's probably safe to say that the problem is ill-conditioned in some
respect. Have you looked at the covariance matrix of the estimates?

Regards,
 John
#
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
#
Dear array,
You are, therefore, fitting a complex model with 5*(1 + 10 + 1 + 3) = 75
parameters to a data set with 206 observations.
If you look at the covariance matrix of the coefficients, you'll see that
there are still problems with the fit:

	> summary(diag(vcov(obj1)))
      	Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
	-1.029e-20  6.670e+05  3.502e+06  7.781e+06  1.075e+07  4.768e+07 

That negative variance (though essentially 0) doesn't bode well. Indeed,
requiring nearly 1000 iterations for apparent convergence is in itself an
indication of problems.
I don't know anything about your application, so I hesitate to make
recommendations, but (assuming that the model you've fit makes sense) in the
abstract I'd suggest collecting a lot more data or fitting a much simpler
model.

Regards,
 John