Hello Guys,

I'm trying to run a rolling time-series regression using mata and rangestat. The code that I'm using is the following:

Code:
 mata:
mata clear
mata set matastrict on
real rowvector myreg(real matrix Xall)
{
real colvector y, b, Xy
real matrix X, XX
real scalar ymean, tss, mss, r2, r2a

y = Xall[.,1] // dependent var is first column of Xall
X = Xall[.,2::cols(Xall)] // the remaining cols are the independent variables
X = X,J(rows(X),1,1) // add a constant

XX = quadcross(X, X) // linear regression
Xy = quadcross(X, y)
b = invsym(XX) * Xy

ymean = mean(y)
tss = sum((y :- ymean) :^ 2) // total sum of squares
mss = sum( (X * b :- ymean) :^ 2) // model sum of squares
r2 = mss / tss
r2a = 1 - (1 - r2) * (rows(X) - 1) / (rows(X) - cols(X))


return(rows(X), r2a, b')
}
end
/*************Mata end*********************************************************/

rangestat (myreg) rirf rmrf, interval(date -60 -1) by(fund_id) casewise
rename myreg* (obs AdjR2 b_rmrf b_cons)
I was wondering, how can I adjust the code so that new columns are created for st.error, t-statistics and p-value for each of the regressions?

Thanks