问题
I am having trouble with mlogit() function. I am trying to predict which variables in a given set are the most preferred amongst people who took our survey. I am trying to predict the optimal combination of variables to create the most preferred option. Basically, we are measuring "Name", "Logo Size", "Design", "Theme","Flavor", and "Color".
To do this, we have a large data set and are trying to run it through mlogit.data() and mlogit(), although we keep getting the same error:
Error in if (abs(x - oldx) < ftol) { : missing value where TRUE/FALSE needed
None of my data is negative or missing, so this is very confusing. My syntax is:
#Process data in mlogit.data()
data2 <-
mlogit.data(data=data, choice="Choice",
shape="long", varying=5:10,
alt.levels=paste("pos",1:3))
#Make character columns factors and "choice" column (the one we are
#measuring) a numeric.
data2$Name <- as.factor(data2$Name)
data2$Logo.Size <- as.factor(data2$Logo.Size)
data2$Design <- as.factor(data2$Design)
data2$Theme <- as.factor(data2$Theme)
data2$Color <- as.factor(data2$Color)
data2$Choice <- as.numeric(as.character(data2$Choice))
##### RUN MODEL #####
m1 <- mlogit(Choice ~ 0 + Name + Logo.Size + Design + Theme + Flavor
+ Color, data = data2)
m1
Does it look like there is a problem with my syntax, or is it likely my data that is the problem?
来源:https://stackoverflow.com/questions/46840042/r-mlogit-function-error-in-if-absx-oldx-ftol-missing-value-where