Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Fwd: rolling regression with if var<mean


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Fwd: rolling regression with if var<mean
Date   Sun, 23 Mar 2014 11:38:06 +0000

Stata does not have a -mean()- function (outside of -egen- and that
does not apply here) and even if one existed it would, in this
context, just return the value of its argument in this context. The
point is that with

<any command> if <any condition>

<any condition> is applied observation by observation.

I suspect that you need to apply -rolling- twice, once to calculate a
variable that holds the means you want and then again to run
regressions conditionally on values of that variable.
Nick
[email protected]


On 23 March 2014 10:45, Sina Öfinger <[email protected]> wrote:
>> Hi,
>>
>> I have a question regarding the rolling operator.
>>
>> I have a data set with daily stock market data lets say:
>>
>> date                  Stock1          Stock2
>> 12.03.1990            .00056          aso.
>> 13.03.1990            .000789
>> 14.03.1990            .000457
>> .                             .
>> .                             .
>> .                             .
>>
>> If I now want to regress Stock1 on Stock2 on a rolling basis (window 260, step 20) I can do that easily with
>>
>> rolling , window(260) stepsize(20) : regress Stock1 Stock2
>>
>> but what if I want to perform a regression only if Stock2 < mean(Stock2) (for every period... so for the first regression over the first 260 time intervals I want Stock2 to be < than its mean during those first 260 day / for the second regression (20-280) I want to regress only if Stock2>mean(over period 20-280) ...  so the average in the if function needs to be recalculated for every regression)
>>
>> rolling , window(260) stepsize(20) : regress Stock1 Stock2 if Stock2<mean(Stock2) does not work
>>
>> is there a different mean function that I can use and that will work?
>>
>> Thanks alot in advance
>>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index