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]
Re: st: saving residuals for many regressions
From
Rodrigo Briceño <[email protected]>
To
[email protected]
Subject
Re: st: saving residuals for many regressions
Date
Fri, 26 Nov 2010 10:10:17 -0600
Nick, thanks for your advice. I actually bought "The workflow of data
analysis using stata" that has very useful information for me.
Please let me explain what I was doing:
1. run a regression, produce the residuals, list them and copy to
excel, produce the graph of residuals against time and copy in excel
2. I wrote a mail to the list and Maarten helped me to produce a loop
for doing this process automatically. The good: the 7 graphs were
produced automatically. The bad: the set of residuals for each
regression is replaced each time that the loop started again: at the
end Iam just able to get the last set of residuals (from my last
regression)
3. What is my last desire: to find a way to run the loop, collect each
set of residuals (don't know how) and produce the 7 graphs. My last
goal is to have the full set of residuals (for the 7 regressions) in
excel, and the 7 graphs.
So far I have:
set more off
loc X = "sap liqmk m2-m12 mes pprom"
loc X1= "sap liqmk m2-m12 mes pprom dv"
local isin "5 103 107"
local isin2 "164 274 282 214"
local b5 "CRALDSFH0070"
local b103 "CRCBANEA0019"
local b107 "CRCIMP0A0053"
local b164 "CRG0000B0210"
local b274 "US105756AR10"
local b282 "US195325BE41"
local b214 "CRGNACIB0043"
gen resid = .
foreach i of local isin {
quietly regress liq `X' if isin2==`i'
predict ehat if e(sample), res
replace resid=ehat if e(sample)
twoway (tsline ehat), name (gr_`b`i'')
list ehat if isin2==`i'
drop ehat
}
drop resid
gen resid = .
foreach i of local isin2 {
quietly regress liq `X1' if isin2==`i'
predict ehat if e(sample), res
replace resid=ehat if e(sample)
twoway (tsline ehat), name (gr_`b`i'')
list ehat if isin2==`i'
drop ehat
}
drop resid
Thanks for your time.
2010/11/26 Nick Cox <[email protected]>:
> Rodrigo might find going through an introductory text on Stata useful. There are several suggestions on the StataCorp website, but my personal favourite has to be Larry Hamilton's text, which got me into Stata in the first place.
>
> However, as Rodrigo is using 9.2, if I recall correctly, slightly out-of-date editions will be best for him.
>
> See http://www.stata.com/bookstore/statabooks.html for the present crop.
>
> Nick
> [email protected]
>
> Maarten buis
>
> --- On Thu, 25/11/10, Rodrigo Briceño wrote:
>> I don't know how to save the residuals of each
>> regression. In your example my question is which
>> command to use to save a table with the 74 residuals
>> estimated for each of the 4 regressions.
>
> If you want a display in the form of a table, type
> -list rep78 resid-, if you want to export it, use
> your favourite way of exporting Stata datasets,
> e.g. -outsheet- or -xmlsave-.
>
>
> *
> * 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/
>
--
Rodrigo Briceño
Economist
[email protected]
MSN: [email protected]
SKYPE: rbriceno1087
*
* 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/