Hi all,
I want to run a rolling regression using a probit model for a fixed window of 20 quarters, and then estimate the fitted and residual values for the last observation in the window. I have a time series (not panel data).
A similar code has been developed by Robert Picard in post #18 of this link http://www.statalist.org/forums/foru...l-values/page2
His code applies an OLS regression rather than a probit. I adjust the model by dropping "by (company)" as I do not have panel data and my new dataset here is time series, and I also change the 5 year window to 20 (quarterly periods).
My question is now:
How can I amend the model below in order to apply it for:
1- A probit model rather than an OLS regression
2- And then calculate out-of-sample predicted probabilities...I think this might be straight forward if the probit model is estimated and would be the same as fitted below.
Thank you
I want to run a rolling regression using a probit model for a fixed window of 20 quarters, and then estimate the fitted and residual values for the last observation in the window. I have a time series (not panel data).
A similar code has been developed by Robert Picard in post #18 of this link http://www.statalist.org/forums/foru...l-values/page2
His code applies an OLS regression rather than a probit. I adjust the model by dropping "by (company)" as I do not have panel data and my new dataset here is time series, and I also change the 5 year window to 20 (quarterly periods).
My question is now:
How can I amend the model below in order to apply it for:
1- A probit model rather than an OLS regression
2- And then calculate out-of-sample predicted probabilities...I think this might be straight forward if the probit model is estimated and would be the same as fitted below.
Code:
* define a linear regression in Mata using quadcross() - help mata cross(), example 2 mata: mata clear mata set matastrict on real rowvector myreg(real matrix Xall) { real colvector y, b, Xy real matrix X, XX y = Xall[.,1] X = Xall[.,2::cols(Xall)] XX = quadcross(X, X) Xy = quadcross(X, y) b = invsym(XX) * Xy return(rows(X), b') } end * regressions over a rolling window of 20 quarters gen double constant = 1 rangestat (myreg) recession lDRGDP3 lshock constant, interval(fqdate -20 0) casewise rename myreg1 nobs rename myreg2 b_lDRGDP3 rename myreg3 b_lshock rename myreg4 b_constant * calculate fitted value and residual for each observation gen double fitted2= b_constant +b_lDRGDP3*DRGDP3+b_lshock*shock gen double residual2 = recession- fitted replace fitted2=. if nobs<21 replace residual2=. if nobs<21
Comment