*Simulate data to show ordinal modelclearsetseed 30004setobs 2000
Number of observations (_N) was 0, now 2,000.
matrix P = (1, 0.2 \ 0.2, 1) // Small correlationcorr2data x1 x2, n(2000) cov(P)gen c = rnormal(0,10)gen b = creplace b = 0 in 1/1000
(1,000 real changes made)
replace b = 1 in 1001/2000
(1,000 real changes made)
gen ystar = 0 + 0.2*(c) + 2*(b) + rnormal()*Cut ystar into five categories with equal numbers of observationsxtiley = ystar, nq(5)** Ordinal Models **// Equal distribution in each outcome category //quiologity c.c i.b x1 x2*Pr(probs)qui margins, at(c=(-30(.5)30)) atmeansmarginsplot, noci plotopts(msym(none) lwidth(medthick) lpat(solid)) /// xlab(-30(10)30) xtitle("Continuous IV") ytitle("Pr({it:y} = {it:j})") ///title("Ordinal Logit Functional Form: Equal Probability in Each of 5 DV Categories", size(medium)) ///subtitle("Probability of each category {it:j}") ///scheme(cleanplots5)
Variables that uniquely identify margins: c
library(haven) # import Stata data and labelslibrary(dplyr) # data manipulationlibrary(ggplot2) # graphslibrary(MASS) # ordinal logit: polr(); mvrnorm()library(marginaleffects) # predictions and marginal effectslibrary(cleanplots) # graph schemecleanplots_defaults()# Simulate data to show ordinal model# (R's random numbers differ from Stata's, so the estimates differ a little)set.seed(30004)n <-2000sim <-as.data.frame(mvrnorm(n, mu =c(0, 0), Sigma =matrix(c(1, .2, .2, 1), 2),empirical =TRUE)) # x1 and x2 with a small correlationnames(sim) <-c("x1", "x2")sim <- sim |>mutate(c =rnorm(n, 0, 10),b =rep(0:1, each = n /2),ystar =0+0.2* c +2* b +rnorm(n),y =factor(ntile(ystar, 5))) # five categories with equal numbers of observations# Equal distribution in each outcome categorysimmod <-polr(y ~ c + b + x1 + x2, data = sim, Hess =TRUE)# Pr(probs) with the other IVs at their meanspr_sim <-predictions(simmod, newdata =datagrid(c =seq(-30, 30, .5)))ggplot(pr_sim, aes(x = c, y = estimate, color = group)) +geom_line(linewidth =1) +scale_color_viridis_d(option ="cividis", end = .95, direction =-1,labels =paste0("Outcome=", 1:5)) +scale_x_continuous(breaks =seq(-30, 30, 10)) +labs(title ="Ordinal Logit Functional Form: Equal Probability in Each of 5 DV Categories",subtitle ="Probability of each category j",x ="Continuous IV", y ="Pr(y = j)", color =NULL) +theme(plot.title.position ="plot")
Note that cumulatively the five Pr(y = j) must sum to one at any given value of x
Is the outcome ordered?
Because values can be ordered does not mean it is substantively meaningful to order categories
A variable can be partially ordered such as SA, A, D, SD, Don’t Know
A variable can be ordered on multiple dimensions
Likert scale items* usually reflect two dimensions, not one
Stats tip: Ordinal \(\neq\) Likert. Likert is a more specific category, referring to a “strongly disagree” to “strongly agree” set of response options. The name comes from the scale’s inventor, Rensis Likert.
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
1
2
3
4
5
Multiple ordering of a Likert scale
How a given independent variable influences the outcome depends on the relationship of interest. For example, some opinions might show partisan differences; these could possibly be that liberals and conservatives differ on how much they agree or disagree about something, but also possibly how likely they are to report strong opinions about something (or both)
Ordinal is not interval
Researchers often treat ordinal variables as interval (e.g., in a linear regression)
Doing this treats the category spacing as real and meaningful information
In addition, we lose any ability to examine how things are associated with each individual outcome category
When can I treat ordinal as continuous?
Linear regression for an ordinal DV imposes equidistance spacing among outcome categories