One type of categorical predictor variable is an ordinal variable. If an ordinal predictor has only three or four levels then clearly it should coded using dummy or effect coding. There are times when an ordinal predictor can be treated as if it were interval (this is called quasi-interval) especially if the variable has more than five or six levels.
The trick here is to test whether the categorical coded variable contains information that is not captured by the quasi-interval version. We do this by including both the quasi-interval version and the coded in the same model.
For our example, we will use the hsbdemo dataset and create an ordinal version of the write variable.
Example With Equal Intervals
use http://www.philender.com/courses/data/hsbdemo, clear generate oread = read recode oread 20/30=1 30/40=2 40/50=3 50/60=4 60/70=5 70/80=6 tabulate oread, gen(or) oread | 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 or2 or3 or4 or5 or6 Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 7, 192) = 32.10 Model | 9641.32136 7 1377.33162 Prob > F = 0.0000 Residual | 8237.55364 192 42.9039252 R-squared = 0.5393 -------------+------------------------------ Adj R-squared = 0.5225 Total | 17878.875 199 89.843593 Root MSE = 6.5501 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.499503 .9381843 5.86 0.000 3.649032 7.349975 math | .3925443 .0659518 5.95 0.000 .2624612 .5226274 or2 | -.6684935 6.72232 -0.10 0.921 -13.92757 12.59059 or3 | 3.052046 6.610617 0.46 0.645 -9.986712 16.0908 or4 | 7.794332 6.683544 1.17 0.245 -5.388266 20.97693 or5 | 9.975781 6.743944 1.48 0.141 -3.32595 23.27751 or6 | 9.642069 7.090349 1.36 0.175 -4.34291 23.62705 _cons | 23.62109 7.194878 3.28 0.001 9.42994 37.81224 ------------------------------------------------------------------------------ test or2 or3 or4 or5 or6 ( 1) or2 = 0 ( 2) or3 = 0 ( 3) or4 = 0 ( 4) or5 = 0 ( 5) or6 = 0 F( 5, 192) = 6.88 Prob > F = 0.0000 /* ordinal variable */ regress write female math oread Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 3, 196) = 72.94 Model | 9431.11641 3 3143.70547 Prob > F = 0.0000 Residual | 8447.75859 196 43.1008091 R-squared = 0.5275 -------------+------------------------------ Adj R-squared = 0.5203 Total | 17878.875 199 89.843593 Root MSE = 6.5651 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.467793 .9337681 5.86 0.000 3.626271 7.309316 math | .4019876 .0654621 6.14 0.000 .2728871 .5310882 oread | 3.143758 .5801709 5.42 0.000 1.999579 4.287937 _cons | 17.12626 2.7214 6.29 0.000 11.75927 22.49324 ------------------------------------------------------------------------------ /* ordinal variable and k-2 dummy variables */ regress write female math oread or3 or4 or5 or6 Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 7, 192) = 32.10 Model | 9641.32136 7 1377.33162 Prob > F = 0.0000 Residual | 8237.55364 192 42.9039252 R-squared = 0.5393 -------------+------------------------------ Adj R-squared = 0.5225 Total | 17878.875 199 89.843593 Root MSE = 6.5501 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.499503 .9381843 5.86 0.000 3.649032 7.349975 math | .3925443 .0659518 5.95 0.000 .2624612 .5226274 oread | -.6684935 6.72232 -0.10 0.921 -13.92757 12.59059 or3 | 4.389033 7.216154 0.61 0.544 -9.844084 18.62215 or4 | 9.799812 13.87258 0.71 0.481 -17.56241 37.16203 or5 | 12.64976 20.56805 0.62 0.539 -27.9186 53.21811 or6 | 12.98454 27.35685 0.47 0.636 -40.97402 66.94309 _cons | 24.28958 13.54601 1.79 0.075 -2.428525 51.00769 ------------------------------------------------------------------------------ test or3 or4 or5 or6 ( 1) or3 = 0 ( 2) or4 = 0 ( 3) or5 = 0 ( 4) or6 = 0 F( 4, 192) = 1.22 Prob > F = 0.3016 /* using factor variables */ regress regress write female math oread i.oread note: 6.oread omitted because of collinearity Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 7, 192) = 32.10 Model | 9641.32136 7 1377.33162 Prob > F = 0.0000 Residual | 8237.55364 192 42.9039252 R-squared = 0.5393 -------------+------------------------------ Adj R-squared = 0.5225 Total | 17878.875 199 89.843593 Root MSE = 6.5501 ------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | 5.499503 .9381843 5.86 0.000 3.649032 7.349975 math | .3925443 .0659518 5.95 0.000 .2624612 .5226274 oread | 1.928414 1.41807 1.36 0.175 -.868582 4.725409 | oread | 2 | -2.596907 5.47137 -0.47 0.636 -13.38862 8.194804 3 | -.8047818 4.107345 -0.20 0.845 -8.906095 7.296531 4 | 2.009091 3.074414 0.65 0.514 -4.054873 8.073054 5 | 2.262126 2.438056 0.93 0.355 -2.546686 7.070939 6 | (omitted) | _cons | 21.69268 8.326716 2.61 0.010 5.269092 38.11626 ------------------------------------------------------------------------------ testparm i.oread ( 1) 2.oread = 0 ( 2) 3.oread = 0 ( 3) 4.oread = 0 ( 4) 5.oread = 0 F( 4, 192) = 1.22 Prob > F = 0.3016 /* 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: The dummy coded variable for oread does not contain significant information that is not contained in the ordinal variable.