Dear all,
I am writing a code on some flexible estimation method and I wanted to use "qreg" as preliminary estimator. However I noticed that coefficients associated to factor variables are not (always) the same wether you use or not the xi: prefix (even if cathegories are the same).
See for example rep78 in the following example:
. sysuse auto
(1978 Automobile Data)
. qreg price mpg i.rep78 headroom weight
Iteration 1: WLS sum of weighted deviations = 57526.806
Iteration 1: sum of abs. weighted deviations = 87541.5
Iteration 2: sum of abs. weighted deviations = 58455.934
Iteration 3: sum of abs. weighted deviations = 53565.321
Iteration 4: sum of abs. weighted deviations = 53450.253
Iteration 5: sum of abs. weighted deviations = 53117.82
Iteration 6: sum of abs. weighted deviations = 52995.225
Iteration 7: sum of abs. weighted deviations = 52959.223
Iteration 8: sum of abs. weighted deviations = 52921.022
Iteration 9: sum of abs. weighted deviations = 52889.25
Median regression Number of obs = 69
Raw sum of deviations 65163 (about 5079)
Min sum of deviations 52889.25 Pseudo R2 = 0.1884
------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg | -70.95877 112.518 -0.63 0.531 -295.9524 154.0348
|
rep78 |
2 | 27.90316 2596.398 0.01 0.991 -5163.916 5219.723
3 | 61.36817 2386.773 0.03 0.980 -4711.28 4834.016
4 | 1584.145 2434.712 0.65 0.518 -3284.363 6452.653
5 | 2078.078 2523.327 0.82 0.413 -2967.627 7123.782
|
headroom | -154.3778 532.8143 -0.29 0.773 -1219.806 911.0503
weight | 1.272579 .8580482 1.48 0.143 -.4431944 2.988353
_cons | 2732.625 5098.427 0.54 0.594 -7462.31 12927.56
------------------------------------------------------------------------------
. xi: qreg price mpg i.rep78 headroom weight
i.rep78 _Irep78_1-5 (naturally coded; _Irep78_1 omitted)
Iteration 1: WLS sum of weighted deviations = 57526.806
Iteration 1: sum of abs. weighted deviations = 87541.5
Iteration 2: sum of abs. weighted deviations = 58455.934
Iteration 3: sum of abs. weighted deviations = 53565.321
Iteration 4: sum of abs. weighted deviations = 53450.253
Iteration 5: sum of abs. weighted deviations = 53117.82
Iteration 6: sum of abs. weighted deviations = 52995.225
Iteration 7: sum of abs. weighted deviations = 52959.223
Iteration 8: sum of abs. weighted deviations = 52921.022
Iteration 9: sum of abs. weighted deviations = 52889.25
Median regression Number of obs = 69
Raw sum of deviations 65163 (about 5079)
Min sum of deviations 52889.25 Pseudo R2 = 0.1884
------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg | -70.95877 112.518 -0.63 0.531 -295.9524 154.0348
_Irep78_2 | 733.5532 2596.398 0.28 0.778 -4458.266 5925.373
_Irep78_3 | 767.0182 2386.773 0.32 0.749 -4005.63 5539.666
_Irep78_4 | 2289.795 2434.712 0.94 0.351 -2578.713 7158.303
_Irep78_5 | 2783.728 2523.327 1.10 0.274 -2261.977 7829.432
headroom | -154.3778 532.8143 -0.29 0.773 -1219.806 911.0503
weight | 1.272579 .8580482 1.48 0.143 -.4431944 2.988353
_cons | 2026.975 5098.427 0.40 0.692 -8167.96 12221.91
------------------------------------------------------------------------------
I immagine I am doing a silly error somewhere but I cannot flag it. This does not happen with rreg for example.
Predicted y_hats are not identical either.
Thank you for the help
Best
Vincenzo
Related Posts with Factor variables in qreg
Covariance structure in generalized mixed modelsDear all, Using longitudinal data at prefecture level, I conducted multilevel analyses with a rando…
Stata job opportunity in Cmabridge MA NBER has an opening for a "professional to work with researchers to explore, procure, & curate …
Convex hulls on scatter plotsA search for discussions of convex hulls in Stata forums or outlets reveals various programs from 19…
Marginal effect for censored ordered probitI develop a censored ordered probit model to explain the level of education achieved. I should also …
Read list of numbers from txt to use in a macroI have a txt file containing some numbers, say 1 5 6 17 18. I would like to import this to Stata and…
Subscribe to:
Post Comments (Atom)
0 Response to Factor variables in qreg
Post a Comment