Statalist


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

st: AW: "skipping" missing data


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: "skipping" missing data
Date   Thu, 6 Aug 2009 18:12:44 +0200

<> 

Apart from your technical problem, have you considered a panel model for
your estimation? If you predicted out of a fixed effects panel model, that
would be much more straightforward then the current setup...


*************
/* 
Dataset from Baum(2006),
http://www.stata-press.com/books/imeus.html
*/ 

use /* 
*/ http://www.stata-press.com/data/imeus/traffic, /* 
*/ clear

//slim down substantially
keep if state<6

//individual regressions
qui levelsof state, loc(levels)
foreach sta of local levels{
	reg fatal beertax spircons /* 
	*/ unrate perincK /* 
	*/ if state==`sta'
}

//fixed effects
xtreg fatal beertax spircons /* 
*/ unrate perincK, fe
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von B. Timothy
Walsh
Gesendet: Donnerstag, 6. August 2009 17:39
An: [email protected]
Betreff: st: "skipping" missing data

I am attempting to generate predictions from regressions performed for each 
of a longish list of individuals. The problem is that, for some 
individuals, there are no dependent variable data (entries are missing), so 
the regression attempt fails. The problem is that the forvalues loop then 
exits. I would like to somehow "skip" these individuals. Loop seems to work 
fine if there are enough data to perform a regression. I'd be grateful for 
any suggestions.

Here's the code:
generate p1=.
forvalues i = 1/50 {		//50 individuals
	regress bperwk_ wk if ptnum == `i'
	predict p
	replace p1=p if ptnum == `i'
	drop p
}

I'm pretty much a Stata novice. So, I apologize if I am missing something 
obvious. Using version 10.1.

Many thanks!
Tim Walsh

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index