Statalist


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

Re: st: multiple rolling regressions


From   "Erasmo Giambona" <[email protected]>
To   [email protected]
Subject   Re: st: multiple rolling regressions
Date   Wed, 14 May 2008 16:52:53 +0200

My data ranges from 1984 to 2005. For some firms the time series is
complete, for others only a portion of the time series is available
(say from 1990-1998 or 2000-2005), for others data are availables with
gaps. There is a firm-id that comes with the data ranging from 1001 to
266319 with gaps, but I also created a group id, which ranges from 1
to 9249. I get the problems with both ids. In particular, the codes
stops producing d when the first firm_id>=25564 or the second
firm_id>=5918. I also did the following: I output the data with
firm_id>=5918 and created a new firm_id starting from 1. This does not
solve the problem. I get an error message saying insufficient
observations. Here is an example of the data. If I run your code (the
one prior to the one you just sent), I get d. However, if I use the
entire dataset, I get missing value for d starting from firm=5918.
Thanks for your patience:

firm year y x
5917 1992 1.708197 4.035585
5917 1993 2.172363 4.32233
5917 1994 3.368399 5.044998
5917 1995 4.356901 5.807374
5918 1992 -.7870928 .1204462
5918 1993 -.9869356 .
5918 1994 -1.746588 .
5918 1995 .1283932 2.479978
5918 1996 -.891178 3.046901
5918 1997 -.4561582 3.944122
5919 1993 -2.120343 4.833421
5919 1994 -2.698135 5.280759
5919 1995 1.528011 5.551051
5919 1996 1.248181 5.860456
5919 1997 -2.45522 5.953046




On Wed, May 14, 2008 at 4:15 PM, Austin Nichols <[email protected]> wrote:
> Erasmo Giambona <[email protected]>:
>
> Is this the kind of setup you are talking about?  Firms with id number
> higher than 5918 present no problem.
>
> clear
> range year 1980 2005 26
> expand 6000
> bys year: g firm=_n
> g y=uniform()
> g x=uniform()
> tsset firm year
> sort firm year
> g double d=.
> qui forv i=3/`=_N-2' {
>  loc f=`i'-2
>  loc l=`i'+2
>  if firm[`f']==firm[`i'] & firm[`l']==firm[`i'] {
>  cap reg y year in `f'/`l' if firm==firm[`i']
>  if _rc==0 {
>   if e(N)>2 {
>    predict double ye if e(sample), resid
>    reg x year in `f'/`l' if firm==firm[`i']
>    predict double xe if e(sample), resid
>    reg ye xe
>    replace d=_b[xe] in `l'
>    drop ye xe
>   }
>  }
>  }
> }
> li, noo sepby(firm)
> g ok=d<.
> tab year ok
> *
> *   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