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]
st: Fwd: rolling regression with if var<mean
From 
 
Sina Öfinger <[email protected]> 
To 
 
[email protected] 
Subject 
 
st: Fwd: rolling regression with if var<mean 
Date 
 
Sun, 23 Mar 2014 11:45:35 +0100 
> 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/