Statalist


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

st: RE: Re: percent of time a


From   Howard Lempel <HLempel@brookings.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: percent of time a
Date   Wed, 11 Feb 2009 09:01:00 -0500

It would have been helpful if I'd been more explicit.  I have various income variables that are topcoded and censored at zero and would like to know how often that bites among many different subpopulations.  The censoring means that p(X_i=0) is not zero.  I guess it's also true that my variables are not strictly continuous in that they're rounded to the nearest integer.

I ended up doing something like the following:

Gen zero = .
foreach var in `vars' {
	local rowcount = 1
	foreach gend in `genders' {
		foreach yr in `yrs' {
			local colcount = 1
			*Do other things
			. . .
			. . .
			*Find out how often my variable is zero		
			replace zero = (`var'==0)
			sum zero [aw=wgt] if gender==`gend' & year==`yr', meanonly
			matrix `var'mat[`rowcount', `colcount'] = r(mean)
			local colcount = `colcount' + 1
			*Do more other things
			. . . 
			. . .
			}
		}
	}

Nick's method using the _gwtmean function for -egen- also works, but since there's no -ereplace- function, it would have involved either -dropping- a variable in each iteration of the loop, or -egenerating- lots of variables.

Howie
			

Howie Lempel
Research Assistant
The Brookings Institution | Economic Studies
 
1775 Massachusetts Ave NW | Washington DC 20036
hlempel@brookings.edu | p: (202) 238-3576
 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Kit Baum
Sent: Wednesday, February 11, 2009 7:06 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: Re: percent of time a

<>
Easy: for a continuous variable the probability that X_i = x is zero.


Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Feb 11, 2009, at 02:33 , Howie wrote:

> Is there a command that will give me the proportion of the time a  
> variable is equal to a certain value?  The command must accept  
> weights.  I'm looking for something like -tabcond-, from SSC, but  
> that returns proportions as well as counts.
>
> One option would be to -generate- a dummy equal to 1 when my  
> variable is equal to my value and zero otherwise and then to use - 
> svy: mean-, but I would prefer something that can be done in one  
> line (and without generating a new variable).  My variable is  
> continuous, so I don't want to -svy: tab- the whole thing.

*
*   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