Reputation: 5779
I am using MASS::polr
to run ordinal logistic regressions, but I am getting a lot of errors that I am hoping people can enlighten me about.
First if I run this the function fails to find starting values:
MASS::polr(as.ordered(cyl)~mpg+gear,mtcars)
So if I specify starting values, I get an error from optim
stating 'non-finite value supplied by optim':
MASS::polr(as.ordered(cyl)~mpg+gear,mtcars,start=c(1,1,1,1))
After reading some R-help, and previous stack overflow questions about this, the response is usually that there is something wrong with the data i.e. the response variable has a category with relatively few values, but in this instance I don't see anything wrong with mtcars
.
Any guidance on how to diagnose, and deal with issues in data that will impact MASS::polr
would be appreciated.
Regards
Upvotes: 0
Views: 1133
Reputation: 146070
Going on a scavenger hunt through ?polr
, the starting values are to be specified "in the format c(coefficients, zeta)
". Looking lower, we see that zeta
is "the intercepts for the class boundaries.". In the Details section, we can see that the zeta values must be ordered:
zeta_0 = -Inf < zeta_1 < ... < zeta_K = Inf
([sic], as that presumably should be a < Inf
at the end.)
So you need the second zeta value to be greater than the first. This works, for example:
MASS::polr(as.ordered(cyl) ~ mpg + gear, mtcars, start = c(1, 1, 1, 2))
Upvotes: 2