Hi all. I'm writing a thesis and I need to calculate out-of-sample R-squared, taking the form:

rt is regressand; rt_bar is average of the reggresaand up to time t; rt_hat is the predicted value of r based on regression using data from t=1~t-1
I'll need an initial sample to for predicting r_hats. So basically, after using data on the first, say, 180 observations, I predict a r_181_hat, this is the r1_hat in the formula; then for each of the next observations, I regress r on regressors using all available data up to t, predict the next period's value, etc etc. So may I have some suggestion how to code in Stata to recursively do the regression using Stata and generate one-period ahead r_hat? Thank you.
rt is regressand; rt_bar is average of the reggresaand up to time t; rt_hat is the predicted value of r based on regression using data from t=1~t-1
I'll need an initial sample to for predicting r_hats. So basically, after using data on the first, say, 180 observations, I predict a r_181_hat, this is the r1_hat in the formula; then for each of the next observations, I regress r on regressors using all available data up to t, predict the next period's value, etc etc. So may I have some suggestion how to code in Stata to recursively do the regression using Stata and generate one-period ahead r_hat? Thank you.
Comment