I've run an ordered logistic regression model in R with Zelig and am looking to calculate predicted probabilities. Zelig has a series of simple one line commands to generate the information I want on first differences and so forth. Unfortunately, I keep getting an error when running the zelig function and was wondering if there was a quick alternative for generating predicted probabilities for a ordered logit in R.

For what it's worth, here's the error from my Zelig code.

> x.out <- setx(mod, credit=1)
Error in dta[complete.cases(mf), names(dta) %in% vars, drop = FALSE] : 
  incorrect number of dimensions

I just need an alternative solution that I can use to generate the probabilities.

  • $\begingroup$ There is also a zelig list, you might get a solution to the error there. $\endgroup$ – Peter Flom Dec 16 '11 at 11:18

A similar issue was raised on Stack Overflow more than one year ago. I don't know if re-installing Zelig and its dependencies will solve your problem (especially because I would prefer to understand why this error message came up before reinstalling).

Anyway, you can use the lrm() function from the rms package, as it allows to fit several models for categorical outcomes including proportional odds model. There is a predict() (but also Predict()) function to get the desired predicted values. As an alternative, you may want to look at the ordinal package (see the clm() function).

  • $\begingroup$ Thanks, re-installing did not help. I'll looking into the rms package. $\endgroup$ – ATMathew Dec 16 '11 at 10:51
  • $\begingroup$ For rms do ?predict.lrm to see how to get all probabilities of interest. $\endgroup$ – Frank Harrell Dec 16 '11 at 21:55

There is also polr in MASS that can fit the proportional odds cumulative logit model, which I like because you can show the fitted model easily using the effects package (for lrm and clm this is not the case I believe, except maybe with Effect() in the development version), and also get 95% confidence limits on your predictions. Here is a little example :

data$response=factor(data$response, ordered=T)
fit=polr(response ~ cheese, weights=count, data=data)
p=(1 - pnorm(abs(z), 0, 1)) * 2 # 2-tailed Wald z tests to test significance of coefficients
Anova(fit, type="III")  # likelihood ratio tests for effect of different factors

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.