Test of Parallel Regression Assumption in R
Dear Heather, You can make this test using the ordinal package. Here the function clm fits cumulative link models where the ordinal logistic regression model is a special case (using the logit link). Let me illustrate how to test the parallel regression assumption for a particular variable using clm in the ordinal package. I am using the wine dataset from the same package, I fit a model with two explanatory variables; temp and contact, and I test the parallel regression assumption for the contact variable in a likelihood ratio test:
library(ordinal)
Loading required package: MASS Loading required package: ucminf Loading required package: Matrix Loading required package: lattice
head(wine)
response rating temp contact bottle judge 1 36 2 cold no 1 1 2 48 3 cold no 2 1 3 47 3 cold yes 3 1 4 67 4 cold yes 4 1 5 77 4 warm no 5 1 6 60 4 warm no 6 1
fm1 <- clm(rating ~ temp + contact, data=wine) fm2 <- clm(rating ~ temp, nominal=~ contact, data=wine) anova(fm1, fm2)
Likelihood ratio tests of cumulative link models:
formula: nominal: link: threshold:
fm1 rating ~ temp + contact ~1 logit flexible
fm2 rating ~ temp ~contact logit flexible
no.par AIC logLik LR.stat df Pr(>Chisq)
fm1 6 184.98 -86.492
fm2 9 190.42 -86.209 0.5667 3 0.904
The idea is to fit the model under the null hypothesis (parallel
effects - fm1) and under the alternative hypothesis (non-parallel
effects for contact - fm2) and compare these models with anova() which
performs the LR test. From the high p-value we see that the null
cannot be rejected and there is no evidence of non-parallel slopes in
this case. For additional information, I suggest that you take a look
at the following package vignette
(http://cran.r-project.org/web/packages/ordinal/vignettes/clm_tutorial.pdf)
where these kind of tests are more thoroughly described starting page
6.
I think you can also make similar tests with the VGAM package, but I
am not as well versed in that package.
Hope this helps,
Rune
Rune Haubo Bojesen Christensen
Postdoc
DTU Compute - Section for Statistics
---------------------------------------------------
Technical University of Denmark
Department of Applied Mathematics and Computer Science
Richard Petersens Plads
Building 324, Room 220
2800 Lyngby
Direct +45 45253363
Mobile +45 30264554
http://www.imm.dtu.dk
On 11 March 2013 22:52, Nicole Ford <nicole.ford at me.com> wrote:
here's some code as an example.... hope it helps!
mod<-polr(vote~age+demsat+eusup+lrself+male+retnat+union+urban, data=dat)
summary(mod)
mod<-polr(vote~age+demsat+eusup+lrself+male+retnat+union+urban, data=dat)
levs<-levels(dat$vote)
tmpdat<-list()
for(i in 1:(nlevels(dat$vote)-1)){
tmpdat[[i]] <- dat
tmpdat[[i]]$z <- as.numeric(as.numeric(tmpdat[[1]]$vote) <= levs[i])
}
form<-as.formula("z~age+demsat+eusup+lrself+male+retnat+union+urban")
mods<-lapply(tmpdat, function(x)glm(form, data=x, family=binomial))
probs<-sapply(mods, predict, type="response")
p.logits<-cbind(probs[,2], t(apply(probs, 1, diff)), 1-probs[,ncol(probs)])
p.ologit<-predict(mod, type='probs')
n<-nrow(p.logits)
bin.ll <- p.logits[cbind(1:n, dat$vote)]
ologit.ll <- p.ologit[cbind(1:n, dat$vote)]
binom.test(sum(bin.ll > ologit.ll), n)
dat$vote.fac<-factor(dat$vote, levels=1:6)
mod<-polr(dat$vote.fac~age+demsat+eusup+lrself+male+retnat+union+urban, data=dat)
source("http://www.quantoid.net/cat_pre.R ")
catpre(mod)
install.packages("rms")
library(rms)
olprobs<-predict(mod, type='probs')
pred.cat<-apply(olprobs, 1, which.max)
table(pred.cat, dat$vote)
round(prop.table(table(pred.cat, dat$vote), 2), 3)
On Mar 11, 2013, at 5:02 PM, Heather Kettrey wrote:
Hi, I am running an analysis with an ordinal outcome and I need to run a test of the parallel regression assumption to determine if ordinal logistic regression is appropriate. I cannot find a function to conduct such a test.
From searching various message boards I have seen a few useRs ask this same
question without a definitive answer - and I came across a thread that
indicated there is no such function available in any R packages. I hope
this is incorrect.
Does anyone know how to test the parallel regression assumption in R?
Thanks for your help!
--
Heather Hensman Kettrey
PhD Candidate
Department of Sociology
Vanderbilt University
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.