Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Calculating firm-specific rolling betas


From   "Nuno" <[email protected]>
To   <[email protected]>
Subject   st: Calculating firm-specific rolling betas
Date   Sun, 25 Feb 2007 11:06:54 -0000

Hi everyone,

I have a database that has the following structure:

Firmid	date	ret	mktret
A	011990	.1	.05
A	021990	.05	.02
A	031990	-.05	-.1
(...)
A	122000	.1	.1
B	082001	.2	.1
B	092001	.05	.2
(...)
B	122006	.1	.1
(...)

I need to calculate a simple regression of ret on mktret for each of the
last 24 months of data of each company, for each company, and save the
results in a separate file. 
If I use the command:
statsby _b , by(firmid) saving(c:\results.dta,replace): reg ret mktret
I get the coefficients using all the available observations, which is not
what I need. I've tried using
statsby _b , by(firmid date) saving(c:\results.dta,replace): reg ret mktret
in -1/-20
But this doesn't work as the -by- statement restricts the sample to the
month being analyzed, thus not including the last 20 months in the
estimation.
Any ideas of this can be done?

Best,

Nuno

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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