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

# Re: st: multiple rolling regressions

 From "Erasmo Giambona" To statalist@hsphsun2.harvard.edu Subject Re: st: multiple rolling regressions Date Fri, 9 May 2008 12:20:35 +0200

```Thanks Austin. There is still something I don't quite grasp. Thanks in
advance for your patience. 1. If I insert another row of data for firm
1 in the dataset from your example, say: 1 2004 33 45, then I noticed
that the code does not create missing values from 1988-2003, but
rather uses data from 1984-1987 and 2004 to estimate d for 2004, while
I would like to get a missing d in this case; 2. When I run the code
with my data I cannot obtain any results, despite the fact that the
data look very similar to the example at least to me. Here is an
excerpt from the real data:

1 1984 1.061948 3.49672
1 1985 1.83066 4.003654
2 1984 0.5492768 2.696585
2 1985 0.5056121 3.226407
2 1986 1.076026 3.619208
2 1987 -0.3400373 3.646911
2 1988 -1.6812 3.520697
2 1989 -1.200567 3.008994

On Thu, May 8, 2008 at 7:33 PM, Austin Nichols <austinnichols@gmail.com> wrote:
> clear
> input firm year y x
> 1 1980 20 23
> 1 1981 22 34
> 1 1982 20 19
> 1 1984 22 34
> 1 1985 20 19
> 1 1986 28 34
> 1 1987 30 19
> 2 1980 15 23
> 2 1981 55 34
> 2 1982 29 19
> 2 1983 15 23
> 2 1984 55 34
> 2 1985 29 19
> 2 1986 28 34
> 2 1987 30 19
> end
> fillin firm year
> 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'] {
>  reg y year in `f'/`l' if firm==firm[`i']
>  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)
>
>
> On Thu, May 8, 2008 at 1:21 PM, Erasmo Giambona <e.giambona@gmail.com> wrote:
>> Hi Austin,
>>
>> Thanks very much. Your code really gets me very very close to what I
>> want to achieve.
>>
>> Here are some additional clarifications that you required. Yes, I am
>> only interested in saving the estimated coefs d of reg ye xe. If there
>> are missing data in the 5 year window, I would still like to get the
>> estimates with whatever data is available. If there are gaps, for
>> instance for a company I have data for the window 1980-1984 and
>> 1990-1994, then I would like to get estimates for the first window and
>> independently for the second window.
>>
>> I noticed that you code calculates d based on observations from -2 to +2.
>> For instance, d=.15129763 for 1982 is based on data from 1980-1984.
>> What I would really like to achieve is for instance that d for 1984 is
>> based on the data from 1980-1984.
>>
>> Hope you can provide some additional hints on how I could obtain what I need.
>> Thanks very much,
>> Erasmo
> *
> *   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–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index