Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
Hi,
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: loop using rolling, recursive
From
[email protected]
To
[email protected]
Subject
st: loop using rolling, recursive
Date
Tue, 14 Dec 2010 18:15:27 +0100
I'm trying to make a loop to calculate the standard deviation of a variable using the rolling, recursive command. My database is from 1990Q1-2009Q2. My final goal is to calculate the standard deviation of a set of variables using a recursive scheme (calculate for the second half of my sample using info from the first half while keeping the first observation fixed). So I want to compute the standard deviation for 1999Q4 using info from 1990Q1-1999Q3, then for 2000Q1 using info from 1990Q1-1999Q4 and so on.
The code below is only working for the first explanatory variable. Any ideas of how to create a loop to calculate the standard deviation using a recursive scheme?
foreach x x1 x2 x3 x4 {
rolling sd_`x'=r(sd), recursive window(39) : summarize `x'
gen sd_`x'= r(sd)
gen sd2_`x'=sd_`x'*2
gen date=end+1
format date %tq
}
Thank you in advance,
Lola Hernandez
Statistics Analyst
Please consider the environment before printing this email.
De informatie verzonden met dit e-mailbericht is vertrouwelijk en uitsluitend bestemd voor de geadresseerde. Indien u als niet-geadresseerde dit bericht ontvangt, wordt u verzocht direct de afzender hierover te informeren en het bericht te vernietigen. Gebruik van informatie door onbevoegden, openbaarmaking of vermenigvuldiging is verboden en kan leiden tot aansprakelijkheid. De afzender is niet aansprakelijk in geval van onjuiste overbrenging van het e-mailbericht en/of bij ontijdige ontvangst daarvan.
The information transmitted is confidential and intended only for the person or entity to whom or which it is addressed. If you are not the intended recipient of this communication, please inform us immediately and destroy this communication. Unauthorised use, disclosure or copying of information is strictly prohibited and may entail liability. The sender accepts no liability for improper transmission of this communication nor for any delay in its receipt.