Regression Analysis with the Ordered Multinomial Logistic Model Braden Hoelzle Southern Methodist University December 2009
Situating the Model GLM – Generalized Linear Model Linear RegressionLogistic Regression Ordered Multinomial Logistic Regression Unordered Multinomial Logistic Regression
Review: Logistic Regression Dichotomous Dependent Variable Independent Variables can be dichotomous, integral, categorical…etc. We are trying to predict the probability that a person does or doesnt have a trait Example: At risk of dropping out or Not at risk Others??
Transform to Probability Probability range = (0 p 1) Therefore we must transform continuous values to the range 0-1 by using the formula: Or expanded to:
A Quick Example > m1 <- glm(comply ~ physrec, family = binomial(link = "logit")) > summary(m1) Call: glm(formula = comply ~ physrec, family = binomial(link = "logit")) Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) e-06 physrec e-07 The probability of complying if NOT recommended by physician: exp( )/(1 + exp( )) The probability of complying if recommended by physician: exp( )/(1 + exp( ))
Ordered Multinomial Logistic Model Four Types of Scales 1. _________ - mutually exclusive categories w/ no logical order. 2. _________ - mutually exclusive categories w/ logical rank order. 3. _________ - ordered data w/ equal distance between each point (no absolute zero). 4. _________ - ordered data w/ equal distance between each point (w/ a true zero). What type of data would you expect our ordered multinomial regression to model?
Definition The ordered multinomial logistic model enables us to model ordinally scaled dependent variables with one or more independent variables. These IV(s) can take many different forms (ie. real numbers values, integers, categorical, binomial, etc.).
Does this Occur Much? Ordinal data are the most frequently encountered type of data in the social sciences (Johnson & Albert, 1999, p. 126). Examples – Yes, maybe, no – Likert scale (Strongly Agree – Strongly Disagree) – Always, frequently, sometimes, rarely, never – No hs diploma, hs diploma, some college, bachelors degree, masters degree, doctoral degree – Free school lunch, reduced school lunch, full price lunch – 0-10k per year, 10-20K per year, 20-30K per year, 30 – 60K per year, > 60K per year – Low, medium, high – Basic math, regular math, pre-AP math, AP math – Neles dancing ability, Megs dancing ability, Saralyns dancing ability, Joses dancing ability, Kyles dancing ability, Bradens dancing ability, a rock
Running Regression using the Ordered Multinomial Logistic Model in R Load/Install Libraries: library(arm) library (psych) Load data (UCLA – Academic Technology Services, n.d.) mydata <- read.csv(url(" at/r/dae/ologit.csv")) attach(mydata)
Definitions Variables: apply - college juniors reported likelihood of applying to grad school (0 = unlikely, 1 = somewhat likely, 2 = very likely) pared – indicating whether at least one parent has a graduate degree (0 = no, 1 = yes) public – indicating whether the undergraduate institution is a pubic or private (0 = private, 1 = public) gpa – college gpa Which variable will likely be our dependent variable?
Description of Data > str(mydata) 'data.frame': 400 obs. of 4 variables: $ apply : int $ pared : int $ public: int $ gpa : num > summary(mydata$gpa) Min. 1st Qu. Median Mean 3rd Qu. Max > table(apply) apply > table(pared) pared > table(public) public
Crosstabs > xtabs(~ pared + apply) apply pared > xtabs(~ public + apply) apply public Why would this information be important for running our ordered multinomial logistic model?
Assumptions No perfect predictions – one predictor variable value cannot solely correspond to one dependent variable value. (ex. – Every student w/ parents who went to graduate school cannot indicate that they are very likely to attend graduate school) – check using crosstabs ( see slide 12). No empty or very small cells – see crosstabs. Sample Size – always requires more cases than OLS regression.
Running a Single Predictor Model > summary(m1 <- bayespolr(as.ordered(apply)~gpa,data=mydata)) Call: bayespolr(formula = as.ordered(apply) ~ gpa, data = mydata) Coefficients: Value Std. Error t value gpa Intercepts: Value Std. Error t value 0| | Residual Deviance: AIC:
Transforming Outcomes to Probabilities (beta <- coef(m1)) gpa (tau <- m1$zeta) 0|1 1| x<- 3 ##### Note: mean = logit.prob <- function(eta){exp(eta)/(1+exp(eta))} (p1 <- logit.prob(tau[1] - x * beta)) (p2<- logit.prob(tau[2] - x * beta) - logit.prob(tau[1] - x * beta)) (p3<- 1 - logit.prob(tau[2] - x * beta)) p1+p2+p3 1
Adding Multiple Predictors > summary(m2 <- bayespolr(as.ordered(apply)~gpa + pared + public,data=mydata)) Call: bayespolr(formula = as.ordered(apply) ~ gpa + pared + public, data = mydata) Coefficients: Value Std. Error t value gpa pared public Intercepts: Value Std. Error t value 0| | Residual Deviance: AIC:
Transforming Outcomes to Probabilities (beta <- coef(m2)) gpa pared public (tau <- m2$zeta) 0|1 1| (x<- cbind(0:4, 0,.15)) [,1] [,2] [,3] [1,] [2,] [3,] [4,] [5,] (x2<-cbind(0:4, 1,.15)) [,1] [,2] [,3] [1,] [2,] [3,] [4,] [5,]
Transforming Outcomes to Probabilities (cont.) logit.prob <- function(eta){exp(eta)/(1+exp(eta))} (p1 <- logit.prob(tau[1] - x %*% beta)) [,1] [1,] [2,] [3,] [4,] [5,] (p2<- logit.prob(tau[2] - x %*% beta) - logit.prob(tau[1] - x %*% beta)) [,1] [1,] [2,] [3,] [4,] [5,] (p3<- 1 - logit.prob(tau[2] - x %*% beta)) [,1] [1,] [2,] [3,] [4,] [5,]
Transforming Outcomes to Probabilities (cont.) (p4 <- logit.prob(tau[1] - x2 %*% beta)) [,1] [1,] [2,] [3,] [4,] [5,] (p5<- logit.prob(tau[2] - x2 %*% beta) - logit.prob(tau[1] - x2 %*% beta)) [,1] [1,] [2,] [3,] [4,] [5,] (p6<- 1 - logit.prob(tau[2] - x2 %*% beta)) [,1] [1,] [2,] [3,] [4,] [5,]
Plotting the Results
Why Not Use Linear Regression? > summary(m1.2<-lm(apply~gpa, data=mydata)) Call: lm(formula = apply ~ gpa, data = mydata) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) gpa ** --- Signif. codes: 0 *** ** 0.01 * Residual standard error: on 398 degrees of freedom Multiple R-squared: , Adjusted R-squared: F-statistic: on 1 and 398 DF, p-value:
What Do Our Results Mean? Plug in a gpa of 3: > (y.hat<-( (.2568 * 3))) [1] This means that we expect someone w/ a 3.0 gpa to fall about half way between unlikely (0) and slightly likely (1) to apply to grad school. But what is half way between these two points (a little unlikely?, neither likely nor unlikely?, very slightly likely?) This is somewhat vague.
Our Graph using Linear Regression A Normal OLS Line An OLS Line on Our Data
We Royally Violate our Assumptions
However… The decision between linear regression and ordered multinomial regression is not always black and white. When you have a large number of categories that can be considered equally spaced simple linear regression is an optional alternative (Gelman & Hill, 2007). ** But check your assumptions!!
Practice Read in the following table (Quinn, n.d.): nes96 <- read.table(" es96r.dat", header=TRUE) Run a regression using the ordered multinomial logistic model to predict the variation in the dependent variable ClinLR using the dependent variables PID and educ. ClinLR = Ordinal variable from 1-7 indicating ones view of Bill Clintons political leanings, where 1 = extremely liberal, 2 = liberal, 3 = slightly liberal, 4 = moderate, 5= slightly conservative, 6 = conservative, 6 = extremely conservative. PID = Ordinal variable from 0-6 indicating ones own political identification, where 0 = Strong Democrat and 6 = Strong Republican educ = Ordinal variable from 1-7 indicating ones own level of education, where 1 = 8 grades or less and no diploma, 2 = 9-11 grades, no further schooling, 3 = High school diploma or equivalency test, 4 = More than 12 years of schooling, no higher degree, 5 = Junior or community college level degree (AA degrees), 6 = BA level degrees; 17+ years, no postgraduate degree, 7 = Advanced degree
References Gelman, A. & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. New York: Cambridge University Press. Johnson, V. E. & Albert, J. H. (1999). Statistics for the social sciences and public policy: Ordinal data modeling. New York: Springer. Quinn, K. (n.d.). Retrieved from asses/536/data/nes96r.dat UCLA: Academic Technology Services. (n.d.). Retrieved from at/r/dae/ologit.csv