Recursive Linear Regression

Work note

Stata can perform recursive linear regression from the command line, primarily using the rolling prefix command. In a recursive regression, the starting observation is held fixed while the ending observation advances, causing the window size to grow with each iteration. [1, 2, 3]

Core Command Syntax

To run a recursive regression, you must first set your data as a time series using tsset. The basic syntax is: [4, 5, 6] rolling _b, window(#) recursive: regress depvar indepvar [7]

Advanced Options and Alternatives

Example Workflow

sysuse gnp96, clear tsset date rolling _b _se, window(20) recursive saving(myresults, replace): regress gnp f.gnp

This script initializes the data, runs a recursive regression starting with a 20-period window that grows by one period each step, and saves the coefficients and standard errors to myresults.dta. [1, 2] Would you like to see how to plot the coefficients over time once the recursive regression is complete?

[1] https://www.stata.com [2] https://www.stata.com [3] https://www.statalist.org [4] https://www.stata.com [5] https://www.projectguru.in [6] https://libguides.princeton.edu [7] https://www.stata.com [8] https://www.stata.com [9] https://www.reed.edu [10] https://www.statalist.org [11] https://www.stata.com [12] https://www.statalist.org