Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73275

Changing the base of a factor variable in a regression

$
0
0
I am trying to change the omitted dummy variable from the smallest to some other. In other areas I have found people using the char command to change the base variable, however I cannot get it to work quite right.

What I have essentially done:

preserve
sysuse auto, clear
xtile mpgTiles = mpg, nquantiles(5)

//changing the characteristics of mpgTiles based on the value
char mpgTiles[omit] 5
reg weight length i.mpgTiles

//Trying to label mpgTile
label define mpgs 1 "VHigh" 2 "High" 3 "Medium" 4 "Low" 5 "VLow"
label values mpgTiles mpgs

//Changing the characteristics of mpgTiles based on labels
char mpgTiles[omit] "VLow"
reg weight length i.mpgTiles

restore

both of these would include mpgTiles = 5 or "VLow" when I want that to be excluded and would exclude mpgTiles = 1 or "VHigh", as is the default.

I know I could do it myself by creating dummy variables based on mpgTiles, but I have been suprised not to find a more elegant solution.

Thanks,
Eric

Viewing all articles
Browse latest Browse all 73275

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>