Statalist The Stata Listserver


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

RE: st: Calculating firm-specific rolling betas


From   "Nuno" <[email protected]>
To   <[email protected]>
Subject   RE: st: Calculating firm-specific rolling betas
Date   Sun, 25 Feb 2007 14:32:10 -0000

Thanks!  It takes lots of time (I have about 4000 firms) even running on a
C2D T7200 2ghz CPU, but that's exactly what I needed!
Cheers,
Nuno

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: domingo, 25 de Fevereiro de 2007 14:08
To: [email protected]
Subject: Re: st: Calculating firm-specific rolling betas

The 'rolling' command might work (I think its only available in Stata 9)

but the syntax is the following:

rolling window(#) stepsize(#) saving(pathname\results.dta), <command you
want to execute, such as regress>

what this does is it takes the first 'X' observations (this is what you
specify in the <window> option) and runs <command> on them, and saves the
estimated coefficients in results.dta. It then rolls the window forward by
the number of time period specified in <stepsize>, and then repeats the
estimation again, saves again.

Recursive estimation is also possible (keep the starting point fixed and
just keep expanding the estimation window forward).


Quoting Nuno <[email protected]>:

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


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

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