[R] multinomial logistic regression with equality constraints?
Roger Levy
rlevy at ucsd.edu
Wed Feb 7 03:52:31 CET 2007
Hi again Jasjeet, Walter,
I have a further question about an error message I get when running
multinomRob. I am simulating a dataset where I look at the effect of
making a previous categorical choice on the probability of making the
same choice later on. Given the following code:
n <- 20
choice <- c("A","B","C")
intercepts <- c(0.5,0.3,0.2)
prime.strength <- rep(0.4,length(intercepts))
counts <- c()
for(i in 1:length(choice)) {
u <- intercepts[1:length(choice)]
u[i] <- u[i] + prime.strength[i]
counts <- c(counts,rmultinomial(n = n, pr = multinomLogis(u)))
}
dim(counts) <- c(length(choice),length(choice))
counts <- t(counts)
row.names(counts) <- choice
colnames(counts) <- choice
data <- data.frame(Prev.Choice=choice,counts)
for(i in 1:length(choice)) {
data[[paste("last",choice[i],sep=".")]] <-
ifelse(data$Prev.Choice==choice[i],1,0)
}
multinomRob(list(A ~ last.A ,
B ~ last.B ,
C ~ last.C - 1 ,
),
data=data,
print.level=1)
I get the following error:
multinomRob(): Grouped MNL Estimation
Error in if (logliklambda < loglik) bvec <- blambda :
missing value where TRUE/FALSE needed
In addition: Warning message:
NaNs produced in: sqrt(sigma2GN)
It's not clear to me what this error means, or why the resulting dataset
would be problematic for MLE estimation.
Many thanks once again!
Roger
More information about the R-help
mailing list