Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: predicting residuals in regression


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: predicting residuals in regression
Date   Wed, 9 May 2012 17:59:05 +0100

Note that your inner loop is 

foreach f of local firmnolist

whereas you started with 

levelsof permno, local(permnolist)

I guess you need 

levelsof firmno, local(firmnolist)

before your loops. Otherwise the macro -firmnolist- will be empty and no regressions will be carried out.

Nick 
[email protected] 

Rudy Hover

I have panel on thousands of firms over 6 years. I want to regress using the foreach command:

gen residuals=.
levelsof permno, local(permnolist)

forvalues y=1999/2006 {
foreach f of local firmnolist {
reg VarA VarB if firmno==`f' & year==`y'
predict temp, residuals
replace residuals=temp if firmno==`f' & year==`y'
drop temp 
}
}

However I'm getting a variable residuals only containing missing values (.)
What am I doing wrong?

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index