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

From |
Michael Hanson <mshanson@mac.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Extract sample start/end dates of time series regression? |

Date |
Sat, 07 Nov 2009 14:39:16 -0500 |

foreach c in local cc { ... // Estimation here summ date if e(sample), meanonly local Tbeg_`c' : disp %tm r(min) local Tend_`c' : disp %tm r(max) ... // More analysis here, using the start/end date macros }

Best, Mike On Nov 7, 2009, at 12:39 PM, Austin Nichols wrote:

Like this, maybe? use http://www.stata-press.com/data/r11/pennxrate.dta, clear egen i=group(country), label su i, mean g low=. g high=. qui forv i=1/`r(max)' { reg lnrxrate L.lnrxrate if i==`i' su year if e(sample), mean replace low=r(min) if i==`i' replace high=r(max) if i==`i' } bys i:g byte f=_n==1 li i low high if f==1, noo clean --could also put in a matrix or locals, but may be easier to have in variables for later reference via tin() etc.On Sat, Nov 7, 2009 at 12:24 PM, Michael Hanson <mshanson@mac.com>wrote:I have a series of regressions that I am estimating country-by-country,using a -foreach- loop. (The data are organized wide; this is toproduce atable of cross-country results, not for a panel estimation.) Thesample foreach country, however, has potentially different start and enddates, and Iwould like to somehow extract these dates from the estimates as Iloopthrough them. Ideally, I'd like to place the dates either in amatrix or(better) a series of local macros so that I can (1) list the start/end datesof each country's estimates in a custom-made table of results, and(2)reference them with -tin()- function calls for post-processing ofthe datacountry-by-country.Unfortunately, I have had no luck figuring out how to do this inStata. Thiskind of information is readily available in packages designed fromtheground up for time series analysis (RATS and EViews come to mind),but I'dlike to stay in Stata if possible. Suggestions are welcome; belowis anartificial example that gets at the issue. In it, I would like toreturnvalues that identify the sample start (`Tbeg') and end (`Tend')dates asfollows: country Tbeg Tend AFG 1971 2003 ANT 1972 2003 ARE 1971 2001 // Begin sample code use http://www.stata-press.com/data/r11/pennxrate.dta, clear keep in 1/102 keep country year lnrxrate reshape wide lnrxrate, i(year) j(country) string replace lnrxrateANT = . in 1 replace lnrxrateARE = . in -2/l tsset year local cc AFG ANT ARE foreach c of local cc { reg lnrxrate`c' L.lnrxrate`c' gen smpl`c' = e(sample) } list year smpl* in 1/3 list year smpl* in -3/l // End sample code Thanks, Mike

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

**References**:**st: Extract sample start/end dates of time series regression?***From:*Michael Hanson <mshanson@mac.com>

**Re: st: Extract sample start/end dates of time series regression?***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: Stata 10 is Malware (also version 11?)** - Next by Date:
**Re: st: referencing eresult matrices** - Previous by thread:
**Re: st: Extract sample start/end dates of time series regression?** - Next by thread:
**st: troubles with -moptimize-** - Index(es):

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