Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: loop using rolling, recursive


From   L.Hernandez@dnb.nl
To   statalist@hsphsun2.harvard.edu
Subject   st: loop using rolling, recursive
Date   Tue, 14 Dec 2010 18:15:27 +0100

Hi,

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.



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index