asreg can easily estimate rolling regressions, betas, t-statistics and SE in Stata. To understand the syntax and basic use of asreg, you can watch this Youtube video. In this post, I show how to use asreg for reporting standard errors, fitted values, and t-statistics in a rolling window.
To install asreg, type the following on the Stata command window
ssc install asreg
Report standard errors and fitted values
We shall use the grunfeld data set for our examples. Using a rolling window of 15 observations, let us fit a regression model where our dependent variable is invest and independent variables are mvalue and kstock. We shall estimate the rolling regression separately for each company, therefore, we shall use the prefix bys company :
Please note that option se and fit are used for reporting standard errors and fitted values, respectively.
webuse grunfeld, clear bys company: asreg invest mvalue kstock, wind(year 15) fit se
Find t-statistics in the rolling window
Once we have the standard errors and coefficients, we can generate t-statistics by dividing respective coefficients on their standard errors. Therefore, to find t-values for the variable mvalue and kstock, we can generate new variables:
gen t_mvalue = _b_mvalue / _se_mvalue gen t_kstock = _b_kstock / _se_kstock