Stata 11 help for rolling

help rolling dialog: rolling -------------------------------------------------------------------------------

Title

[TS] rolling -- Rolling-window and recursive estimation

Syntax

rolling [exp_list] [if] [in] [, options] : command

options description ------------------------------------------------------------------------- Main * window(#) number of consecutive data points in each sample recursive use recursive samples rrecursive use reverse recursive samples

Options clear replace data in memory with results saving(filename, ...) save results to filename; save statistics in double precision; save results to filename every # replications stepsize(#) number of periods to advance window start(time_constant) period at which rolling is to start end(time_constant) period at which rolling is to end keep(varname[, start]) save varname along with results; optionally, use value at left edge of window

Reporting nodots suppress the replication dots noisily display any output from command trace trace command's execution

Advanced reject(exp) identify invalid results ------------------------------------------------------------------------- * window(#) is required. You must tsset your data before using rolling; see [TS] tsset. aweights are allowed in command if command accepts aweights; see weight.

Menu

Statistics > Time series > Rolling-window and recursive estimation

Description

rolling is a moving sampler that collects statistics from command by executing command on subsets of the data in memory. Typing

. rolling exp_list, window(50) clear: command

executes command on sample windows of span 50. That is, rolling will first execute command by using periods 1--50 of the dataset, and then using periods 2--51, 3--52, and so on. rolling can also perform recursive and reverse recursive analyses, in which the starting or ending period is held fixed and the window size grows.

command defines the statistical command to be executed. Most Stata commands and user-written programs can be used with rolling, as long as they follow standard Stata syntax and allow the if qualifier. The by prefix cannot be part of command.

exp_list specifies the statistics to be collected after the execution of command. If no expressions are given, exp_list assumes a default of _b if command stores results in e() and of all the scalars if command stores results in r() and not in e(). Otherwise, not specifying an expression in exp_list is an error.

Options

+------+ ----+ Main +-------------------------------------------------------------

window(#) defines the window size used each time command is executed. The window size refers to calendar periods, not the number of observations. If there are missing data (for example, because of weekends), the actual number of observations used by command may be less than window(#). window(#) is required.

recursive specifies that a recursive analysis be done. The starting period is held fixed, the ending period advances, and the window size grows.

rrecursive specifies that a reverse recursive analysis be done. Here the ending period is held fixed, the starting period advances, and the window size shrinks.

+---------+ ----+ Options +----------------------------------------------------------

clear specifies that Stata replace the data in memory with the collected statistics even though the current data in memory have not been saved to disk.

saving(filename [, suboptions]) creates a Stata data file (.dta file) consisting of (for each statistic in exp_list) a variable containing the replicates.

double specifies that the results for each replication be stored as doubles, meaning 8-byte reals. By default, they are stored as floats, meaning 4-byte reals.

every(#) specifies that results be written to disk every #th replication. every() should be specified only in conjunction with saving() when command takes a long time for each replication. This will allow recovery of partial results should your computer crash. See [P] postfile.

stepsize(#) specifies the number of periods the window is to be advanced each time command is executed.

start(time_constant) specifies the date on which rolling is to start. start() may be specified as an integer or as a date literal.

end(time_constant) specifies the date on which rolling is to end. end() may be specified as an integer or as a date literal.

keep(varname[, start]) specifies a variable to be posted along with the results. The value posted is the value that corresponds to the right edge of the window. Specifying the start() option requests that the value corresponding to the left edge of the window be posted instead. This option is often used to record calendar dates.

+-----------+ ----+ Reporting +--------------------------------------------------------

nodots suppresses the display of the replication dot for each window on which command is executed. By default, one dot character is printed for each window. A red `x' is printed if command returns with an error or if any value in exp_list is missing.

noisily causes the output of command to be displayed for each window on which command is executed. This option implies the nodots option.

trace causes a trace of the execution of command to be displayed. This option implies the noisily and nodots options.

+----------+ ----+ Advanced +---------------------------------------------------------

reject(exp) identifies an expression that indicates when results should be rejected. When exp is true, the saved statistics are set to missing values.

Example: Collecting coefficients

. webuse lutkepohl2 . tsset qtr . rolling _b, window(30): regress dln_inv dln_inc dln_consump

Same as above, _b is default for e-class commands . webuse lutkepohl2, clear . tsset qtr . rolling, window(30): regress dln_inv dln_inc dln_consump . list in 1/10, abbrev(14)

Example: Collecting standard errors

. webuse lutkepohl2, clear . tsset qtr . rolling _se, window(10): regress dln_inv dln_inc dln_consump . list in 1/10, abbrev(14)

Example: Collecting saved results

. webuse lutkepohl2, clear . tsset qtr . rolling mean=r(mean) median=r(p50), window(10): summarize inc, detail . list in 1/10

. webuse lutkepohl2, clear . tsset qtr . rolling ratio=(r(mean)/r(p50)), window(10): summarize inc, detail . list in 1/10

Saved results

rolling sets no r- or e-class macros. The results from the command used with rolling, depending on the last window of data used, are available after rolling has finished.

Also see

Manual: [TS] rolling

Help: [D] statsby


© Copyright 1996–2009 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index