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 hsb2 dataset and create an ordinal version of the write variable.
Example With Equal Intervals
use http://www.gseis.ucla.edu/courses/data/hsb2, 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) = 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
or2 | -.7310555 6.842787 -0.11 0.915 -14.22775 12.76563
or3 | 2.840241 6.740025 0.42 0.674 -10.45376 16.13424
or4 | 5.830803 6.771746 0.86 0.390 -7.525766 19.18737
or5 | 8.876471 6.837878 1.30 0.196 -4.610536 22.36348
or6 | 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 or2 or3 or4 or5 or6
( 1) or2 = 0
( 2) or3 = 0
( 3) or4 = 0
( 4) or5 = 0
( 5) or6 = 0
F( 5, 192) = 5.30
Prob > F = 0.0001
/* ordinal variable */
regress write female math oread
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
oread | 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 oread or3 or4 or5 or6
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
oread | -.7310555 6.842787 -0.11 0.915 -14.22775 12.76563
or3 | 4.302352 7.355962 0.58 0.559 -10.20652 18.81123
or4 | 8.02397 14.11177 0.57 0.570 -19.81003 35.85797
or5 | 11.80069 20.92866 0.56 0.574 -29.47892 53.08031
or6 | 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 or3 or4 or5 or6
( 1) or3 = 0
( 2) or4 = 0
( 3) or5 = 0
( 4) or6 = 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.