Oridnal Regression
Index
Reference
Data
- American Community Survey (ACS) data of Nashville, TN, 2018
- Data Dictionary: https://www2.census.gov/programs-surveys/acs/tech_docs/pums/data_dict/PUMS_Data_Dictionary_2014-2018.pdf
education_level3 | N |
---|---|
High School or Less | 2787 |
Undergraduate or Less | 2886 |
Graduate | 817 |
Plot
Plot using rmsb
Ordinal with MASS package
ordinal package
education_level3 | |||
---|---|---|---|
Predictors | Odds Ratios | CI | p |
High School or Less|Undergraduate or Less | 65.59 | 38.30 – 112.30 | <0.001 |
Undergraduate or Less|Graduate | 1163.97 | 656.72 – 2063.04 | <0.001 |
Gender: Female | 1.48 | 1.30 – 1.69 | <0.001 |
Wages or salary income past 12 months (use ADJINC to adjust WAGP to constant dollars) |
1.65 | 1.57 – 1.74 | <0.001 |
Observations | 3794 | ||
R2 Nagelkerke | 0.120 |
rms package
Effects Response : education_level3
Factor Low High Diff. Effect S.E. Lower 0.95
wagp_log 9.741 11.002 1.2611 0.63477 0.033425 0.56926
Odds Ratio 9.741 11.002 1.2611 1.88660 NA 1.76700
gender - Female:Male 1.000 2.000 NA 0.39414 0.065348 0.26606
Odds Ratio 1.000 2.000 NA 1.48310 NA 1.30480
Upper 0.95
0.70028
2.01430
0.52222
1.68580
glm package
- Re-code education level into three variables
lvl1 N
1: 1 3794
2: 0 3794
y N
1: 0 3469
2: 1 4119
Call:
glm(formula = y ~ 0 + factor(lvl1) + gender + wagp_log, family = binomial,
data = dtb, epsilon = 1e-19)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.0186 -0.6937 0.3632 0.6601 2.3706
Coefficients:
Estimate Std. Error z value Pr(>|z|)
factor(lvl1)0 7.07199 0.27055 26.139 < 2e-16 ***
factor(lvl1)1 4.20227 0.25153 16.707 < 2e-16 ***
genderFemale -0.39795 0.05944 -6.695 2.16e-11 ***
wagp_log -0.50422 0.02433 -20.727 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 10519.2 on 7588 degrees of freedom
Residual deviance: 7274.7 on 7584 degrees of freedom
AIC: 7282.7
Number of Fisher Scoring iterations: 5
Intercept lvl1 gender=Female wagp_log
7.0719899 -2.8697202 -0.3979506 -0.5042197
Effects Response : y
Factor Low High Diff. Effect S.E. Lower 0.95
lvl1 0.000 1.000 1.0000 -2.869700 0.061800 -2.990800
Odds Ratio 0.000 1.000 1.0000 0.056715 NA 0.050245
wagp_log 9.741 11.002 1.2611 -0.635890 0.030679 -0.696020
Odds Ratio 9.741 11.002 1.2611 0.529470 NA 0.498570
gender - Female:Male 1.000 2.000 NA -0.397950 0.059440 -0.514450
Odds Ratio 1.000 2.000 NA 0.671700 NA 0.597830
Upper 0.95
-2.748600
0.064018
-0.575760
0.562280
-0.281450
0.754690
Intercept lvl1 gender=Female wagp_log
7.0719899 -2.8697202 -0.3979506 -0.5042197
Call:
glm(formula = y ~ lvl1 + gender + wagp_log, family = binomial,
data = dtb)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.0186 -0.6937 0.3632 0.6601 2.3706
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 7.07199 0.27054 26.140 < 2e-16 ***
lvl1 -2.86972 0.06180 -46.437 < 2e-16 ***
genderFemale -0.39795 0.05944 -6.695 2.16e-11 ***
wagp_log -0.50422 0.02433 -20.728 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 10463.5 on 7587 degrees of freedom
Residual deviance: 7274.7 on 7584 degrees of freedom
AIC: 7282.7
Number of Fisher Scoring iterations: 4
Call:
glm(formula = y ~ gender + wagp_log + education_ge_undergraduate +
education_ge_graduate, family = binomial, data = dtb)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.17741 -1.17741 0.00008 1.17741 1.17741
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.957e+01 2.439e+02 0.080 0.936
genderFemale -1.029e-14 6.113e-02 0.000 1.000
wagp_log 7.670e-16 2.478e-02 0.000 1.000
education_ge_undergraduate -1.957e+01 2.439e+02 -0.080 0.936
education_ge_graduate -1.957e+01 2.990e+02 -0.065 0.948
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 10463.5 on 7587 degrees of freedom
Residual deviance: 6030.4 on 7583 degrees of freedom
AIC: 6040.4
Number of Fisher Scoring iterations: 18
brms package
SAMPLING FOR MODEL '4f0612a04dc8c8df8213a17f0a92f218' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.000881 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 8.81 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 5.85857 seconds (Warm-up)
Chain 1: 5.17293 seconds (Sampling)
Chain 1: 11.0315 seconds (Total)
Chain 1:
SAMPLING FOR MODEL '4f0612a04dc8c8df8213a17f0a92f218' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 0.000795 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 7.95 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 6.03269 seconds (Warm-up)
Chain 2: 5.6814 seconds (Sampling)
Chain 2: 11.7141 seconds (Total)
Chain 2:
SAMPLING FOR MODEL '4f0612a04dc8c8df8213a17f0a92f218' NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 0.000872 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 8.72 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 5.77304 seconds (Warm-up)
Chain 3: 5.70429 seconds (Sampling)
Chain 3: 11.4773 seconds (Total)
Chain 3:
SAMPLING FOR MODEL '4f0612a04dc8c8df8213a17f0a92f218' NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 0.000816 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 8.16 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 5.74178 seconds (Warm-up)
Chain 4: 5.93405 seconds (Sampling)
Chain 4: 11.6758 seconds (Total)
Chain 4:
Family: cumulative
Links: mu = logit; disc = identity
Formula: education_level3 ~ gender + wagp_log
Data: dt (Number of observations: 3794)
Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup draws = 4000
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept[1] 4.19 0.27 3.67 4.71 1.00 3582 2852
Intercept[2] 7.07 0.29 6.52 7.62 1.00 3451 2692
genderFemale 0.40 0.07 0.27 0.52 1.00 3642 3019
wagp_log 0.50 0.03 0.45 0.55 1.00 3615 2872
Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
disc 1.00 0.00 1.00 1.00 NA NA NA
Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
SAMPLING FOR MODEL '62f7a71f4b20767090dcbea7f27d9b6c' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.001333 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 13.33 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 4.22494 seconds (Warm-up)
Chain 1: 4.22861 seconds (Sampling)
Chain 1: 8.45355 seconds (Total)
Chain 1:
SAMPLING FOR MODEL '62f7a71f4b20767090dcbea7f27d9b6c' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 0.000779 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 7.79 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 4.39852 seconds (Warm-up)
Chain 2: 4.68376 seconds (Sampling)
Chain 2: 9.08228 seconds (Total)
Chain 2:
SAMPLING FOR MODEL '62f7a71f4b20767090dcbea7f27d9b6c' NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 0.000803 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 8.03 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 4.29013 seconds (Warm-up)
Chain 3: 4.25251 seconds (Sampling)
Chain 3: 8.54264 seconds (Total)
Chain 3:
SAMPLING FOR MODEL '62f7a71f4b20767090dcbea7f27d9b6c' NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 0.00083 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 8.3 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 4.2281 seconds (Warm-up)
Chain 4: 4.15997 seconds (Sampling)
Chain 4: 8.38808 seconds (Total)
Chain 4:
Family: binomial
Links: mu = logit
Formula: y ~ lvl1 + gender + wagp_log
Data: dtb (Number of observations: 7588)
Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup draws = 4000
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept 7.08 0.27 6.57 7.61 1.00 3304 2915
lvl1 -2.87 0.06 -2.99 -2.76 1.00 3486 3260
genderFemale -0.40 0.06 -0.52 -0.28 1.00 4170 3333
wagp_log -0.51 0.02 -0.55 -0.46 1.00 3636 3008
Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).