knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette replicates the ordinal logistic regression example done by the UCLA Statistical Consulting Group. It demonstrates how to use the pomcheckr
package to check if the proportional odds assumption holds.
library(pomcheckr) library(ggplot2) data(ologit)
head(ologit)
ologit
is a synthetic data set consisting of the following:
apply - indicates how likely a student is to apply to graduate school
pared - 1 if at least one parent has a graduate degree, 0 otherwise
public - 1 if the undergraduate institution if public, 0 otherwise
gpa - the student's grade point average
Some of the descriptive statistics from the example are repeated below.
## one at a time, table apply, pared, and public lapply(ologit[, c("apply", "pared", "public")], table)
## three way cross tabs (xtabs) and flatten the table ftable(xtabs(~ public + apply + pared, data = ologit))
ggplot(ologit, aes(x = apply, y = gpa)) + geom_boxplot() + geom_jitter(size=0.1, alpha = .5) + facet_grid(pared ~ public, margins = TRUE) + theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
The source page describes various analysis methods that one might consider and what the limitations are with respect to this data set. Since the outcome apply
is an ordered, categorical variable an ordered logistic (aka cumulative logit) model is an appropriate choice.
A key assumption of an ordinal logistic regression is that the odds of adjacent categories are proportional (i.e., the slope coefficients are the same). The score test is sometimes used to test this assumption, but it tends to be conservative and rejects the null more often than it should. The source page illustrates a graphical method for checking this assumption, and pomcheckr
will automatically generate the necessary plots.
plot(pomcheck(apply ~ pared + public + gpa, data=ologit))
The basic idea is a series of binary logistic regressions without the parallel slopes assumption are run on the response against the predictors. Then we check for equality of the slope coefficients across levels of the predictor (or cutpoints if the predictor is continuous). See the source page for further details.
In the above plots, the slope coefficients are roughly equal for both pared
and gpa
. However, the plot for public
suggests the parallel slopes assumption is not satisfied for that predictor.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.