Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: value labels when using factor variables


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: value labels when using factor variables
Date   Thu, 24 Sep 2009 21:17:49 +0200

<>

It is possible to do this manually, and there is the possibility of a bit
more automation with things like -colfullnames- applied to the "e(b)"...

**************
clear*
set obs 10000

gen pov= irecode(runiform(), 0 ,.2, /*
*/ .4, .6, .8, 1)

la def pov 1 "Below 100% FPL" 2 "100-150% FPL" /*
*/  3 "150-200% FPL" 4 "200-300% FPL"  5 "Over 300% FPL"
la val pov pov

gen y=1000+100*pov+rnormal()

reg y i.pov

esttab, /*
*/ coeflabels( 1b.pov "Below 100% FPL" /*
*/ 2.pov "100-150% FPL" /*
*/  3.pov "150-200% FPL" /*
*/ 4.pov "200-300% FPL" /*
*/  5.pov "Over 300% FPL")

**************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Paul Shattuck
Sent: Donnerstag, 24. September 2009 20:16
To: statalist@hsphsun2.harvard.edu
Subject: st: value labels when using factor variables

I am running regression models using Stata's factor variable option
(i.varname) to automatically create dummy variables for categorical
predictors <very cool feature>. However, the coefficient row labels in
the regression model output do not contain the value labels from the
original categorical variable. This makes it difficult to automate table
production using estout or other methods. Does anyone know how to use
the factor variable option AND have the factor variables be labeled with
the category value labels from the original categorical variable the
dummies were derived from?

For instance, if I run a regression on a dependent variable ("depvar")
and a 5-category predictor variable for poverty level ("pov") where the
value labels are defined as 1 "Below 100% FPL" 2 "100-150% FPL" 3
"150-200% FPL" 4 "200-300% FPL" and 5 "Over 300% FPL":

regress depvar i.pov

Then my regression output is labeled like this, with none of the value
labels from "depvar" being carried over into the final regression table
labels.

------------------------------------------------------------------------
-----------------
depvar	|	Coef.		Std. Err. 		t
------------------------------------------------------------------------
-----------------
     pov	|	<blank>
	2	|	<b>
	3	|	<b>
	4	|	<b>
	5	|	<b>
		|
   _cons	|
------------------------------------------------------------------------
-----------------


What I would like to end up with is this:


------------------------------------------------------------------------
-----------------
depvar		|	Coef.		Std. Err. 		t
------------------------------------------------------------------------
-----------------
Below 100% FPL	|	<blank>
100-150% FPL	|	<b>
150-200% FPL	|	<b>
200-300% FPL	|	<b>
Over 300% FPL	|	<b>
			|
   _cons		|
------------------------------------------------------------------------
-----------------






Thank you,

Paul T. Shattuck, Ph.D.



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index