OLS Example With Equal Intervals
use http://www.gseis.ucla.edu/courses/data/hsb2, clear generate oread1=read recode oread1 20/30=1 30/40=2 40/50=3 50/60=4 60/70=5 70/80=6 tabulate oread1, gen(oread1) oread1 | Freq. Percent Cum. ------------+----------------------------------- 1 | 1 0.50 0.50 2 | 21 10.50 11.00 3 | 61 30.50 41.50 4 | 61 30.50 72.00 5 | 47 23.50 95.50 6 | 9 4.50 100.00 ------------+----------------------------------- Total | 200 100.00 /* k-1 dummy variables */ regress write female math or12 or13 or14 or15 or16 Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 7, 192) = 30.02 Model | 9343.36107 7 1334.76587 Prob > F = 0.0000 Residual | 8535.51393 192 44.4558017 R-squared = 0.5226 -------------+------------------------------ Adj R-squared = 0.5052 Total | 17878.875 199 89.843593 Root MSE = 6.6675 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.415011 .9547621 5.67 0.000 3.531841 7.29818 math | .4352535 .0651719 6.68 0.000 .3067087 .5637983 or12 | -.7310555 6.842787 -0.11 0.915 -14.22775 12.76563 or13 | 2.840241 6.740025 0.42 0.674 -10.45376 16.13424 or14 | 5.830803 6.771746 0.86 0.390 -7.525766 19.18737 or15 | 8.876471 6.837878 1.30 0.196 -4.610536 22.36348 or16 | 8.598478 7.206724 1.19 0.234 -5.616039 22.81299 _cons | 21.86909 7.293918 3.00 0.003 7.48259 36.25559 ------------------------------------------------------------------------------ test or12 or13 or14 or15 or16 ( 1) or12 = 0 ( 2) or13 = 0 ( 3) or14 = 0 ( 4) or15 = 0 ( 5) or16 = 0 F( 5, 192) = 5.30 Prob > F = 0.0001 /* ordinal variable */ regress write female math oread1 Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 3, 196) = 70.03 Model | 9249.65685 3 3083.21895 Prob > F = 0.0000 Residual | 8629.21815 196 44.0266232 R-squared = 0.5174 -------------+------------------------------ Adj R-squared = 0.5100 Total | 17878.875 199 89.843593 Root MSE = 6.6353 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.427203 .9435353 5.75 0.000 3.566418 7.287988 math | .4312545 .0646041 6.68 0.000 .303846 .5586629 oread1 | 2.804904 .5652588 4.96 0.000 1.690134 3.919674 _cons | 16.46917 2.748966 5.99 0.000 11.04782 21.89052 ------------------------------------------------------------------------------ /* ordinal variable and k-2 dummy variables */ regress write female math oread1 or13 or14 or15 or16 Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 7, 192) = 30.02 Model | 9343.36107 7 1334.76587 Prob > F = 0.0000 Residual | 8535.51393 192 44.4558017 R-squared = 0.5226 -------------+------------------------------ Adj R-squared = 0.5052 Total | 17878.875 199 89.843593 Root MSE = 6.6675 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.415011 .9547621 5.67 0.000 3.531841 7.29818 math | .4352535 .0651719 6.68 0.000 .3067087 .5637983 oread1 | -.7310555 6.842787 -0.11 0.915 -14.22775 12.76563 or13 | 4.302352 7.355962 0.58 0.559 -10.20652 18.81123 or14 | 8.02397 14.11177 0.57 0.570 -19.81003 35.85797 or15 | 11.80069 20.92866 0.56 0.574 -29.47892 53.08031 or16 | 12.25376 27.84588 0.44 0.660 -42.66936 67.17687 _cons | 22.60014 13.77407 1.64 0.102 -4.567782 49.76807 ------------------------------------------------------------------------------ test or13 or14 or15 or16 ( 1) or13 = 0 ( 2) or14 = 0 ( 3) or15 = 0 ( 4) or16 = 0 F( 4, 192) = 0.53 Prob > F = 0.7160 /* compare to continuous predictor */ regress write female math read Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 3, 196) = 72.52 Model | 9405.34864 3 3135.11621 Prob > F = 0.0000 Residual | 8473.52636 196 43.2322773 R-squared = 0.5261 -------------+------------------------------ Adj R-squared = 0.5188 Total | 17878.875 199 89.843593 Root MSE = 6.5751 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.44337 .9349987 5.82 0.000 3.59942 7.287319 math | .3974826 .0664037 5.99 0.000 .266525 .5284401 read | .3252389 .0607348 5.36 0.000 .2054613 .4450166 _cons | 11.89566 2.862845 4.16 0.000 6.249728 17.5416 ------------------------------------------------------------------------------Note: Dummy coded variables do not contain significant information that is not contained in the ordinal variable.
Ordered Logistic Example With Equal Intervals
generate write3=write recode write3 30/45=1 45/60=2 60/75=3 /* k-1 dummy variables */ ologit write3 female math or12 or13 or14 or15 or16 Ordered logit estimates Number of obs = 200 LR chi2(7) = 122.89 Prob > chi2 = 0.0000 Log likelihood = -147.76514 Pseudo R2 = 0.2937 ------------------------------------------------------------------------------ write3 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 1.485106 .3251231 4.57 0.000 .8478766 2.122336 math | .1228038 .0229207 5.36 0.000 .0778801 .1677274 or12 | -1.889068 2.056765 -0.92 0.358 -5.920255 2.142118 or13 | -1.056602 2.011659 -0.53 0.599 -4.99938 2.886176 or14 | -.2398585 2.020243 -0.12 0.905 -4.199462 3.719745 or15 | .4322685 2.043845 0.21 0.832 -3.573595 4.438132 or16 | 1.774106 2.316172 0.77 0.444 -2.765507 6.313719 -------------+---------------------------------------------------------------- _cut1 | 5.022661 2.232042 (Ancillary parameters) _cut2 | 8.508677 2.30283 ------------------------------------------------------------------------------ test or12 or13 or14 or15 or16 ( 1) or12 = 0 ( 2) or13 = 0 ( 3) or14 = 0 ( 4) or15 = 0 ( 5) or16 = 0 chi2( 5) = 16.36 Prob > chi2 = 0.0059 /* ordinal variable */ ologit write3 female math oread1 Ordered logit estimates Number of obs = 200 LR chi2(3) = 120.82 Prob > chi2 = 0.0000 Log likelihood = -148.80348 Pseudo R2 = 0.2887 ------------------------------------------------------------------------------ write3 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 1.506797 .3224937 4.67 0.000 .8747214 2.138874 math | .1245458 .0228629 5.45 0.000 .0797354 .1693562 oread1 | .7431847 .1920608 3.87 0.000 .3667524 1.119617 -------------+---------------------------------------------------------------- _cut1 | 8.371034 1.089549 (Ancillary parameters) _cut2 | 11.84634 1.291247 ------------------------------------------------------------------------------ /* ordinal variable and k-2 dummy variables */ ologit write3 female math oread1 or13 or14 or15 or16 Ordered logit estimates Number of obs = 200 LR chi2(7) = 122.89 Prob > chi2 = 0.0000 Log likelihood = -147.76514 Pseudo R2 = 0.2937 ------------------------------------------------------------------------------ write3 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 1.485106 .3251231 4.57 0.000 .8478766 2.122336 math | .1228038 .0229207 5.36 0.000 .0778801 .1677274 oread1 | -1.889068 2.056765 -0.92 0.358 -5.920255 2.142118 or13 | 2.721535 2.252718 1.21 0.227 -1.693712 7.136781 or14 | 5.427346 4.28359 1.27 0.205 -2.968335 13.82303 or15 | 7.988542 6.332729 1.26 0.207 -4.423379 20.40046 or16 | 11.21945 8.448682 1.33 0.184 -5.339664 27.77856 -------------+---------------------------------------------------------------- _cut1 | 3.133593 4.131344 (Ancillary parameters) _cut2 | 6.619608 4.160175 ------------------------------------------------------------------------------ test or13 or14 or15 or16 ( 1) or13 = 0 ( 2) or14 = 0 ( 3) or15 = 0 ( 4) or16 = 0 chi2( 4) = 1.95 Prob > chi2 = 0.7447 /* compare to continuous predictor */ ologit write3 female math read Ordered logit estimates Number of obs = 200 LR chi2(3) = 122.78 Prob > chi2 = 0.0000 Log likelihood = -147.82424 Pseudo R2 = 0.2934 ------------------------------------------------------------------------------ write3 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 1.527411 .3238524 4.72 0.000 .892672 2.16215 math | .1167482 .0234653 4.98 0.000 .0707571 .1627394 read | .0855676 .0209828 4.08 0.000 .044442 .1266932 -------------+---------------------------------------------------------------- _cut1 | 9.600994 1.185526 (Ancillary parameters) _cut2 | 13.10302 1.395534 ------------------------------------------------------------------------------Note: Again the dummy coded variables do not contain significant information that is not contained in the ordinal variable. It should be noted, of course, that this will not always be the case.
Categorical Data Analysis Course
Phil Ender