Dear Statalist community,
I have here panel data of about 5000 stocks with monthly return data, as well as accounting and binary sustainability data.
The model I have to run is a cross-sectional regression of the form Return(t,j) = acc1(t,j) + sust2(t,j) + ... at month t and stock j. I have to run this for every month in the sample period.
What I need from these regressions is a matrix that gives me the coefficients, t-statistics, and Rsquares (3 columns) for every month (216 rows), and then I need to calculate the average of each of these coefficients.
I have absolutely no idea how to go about it! I would know how to do this in eviews but for operational purposes I am now using stata. Here is the eviews code:
matrix(216,3) coefficients=na
for !n = 1 to 216
!k = !n+1
equation regression!n.ls ret!k c log(mv!n) log(pb!n) log(psales!n) log(dvol!n) dy!n env!n emp!n div!n sin!n
coefficients(!n,1)=regression!n.@coefs(1)
coefficients(!n,2)=regression!n.@coefs(2)
coefficients(!n,3)=regression!n.@coefs(3)
coefficients(!n,4)=regression!n.@coefs(4)
coefficients(!n,5)=regression!n.@coefs(5)
coefficients(!n,6)=regression!n.@coefs(6)
coefficients(!n,7)=regression!n.@coefs(7)
coefficients(!n,8)=regression!n.@coefs(8)
coefficients(!n,9)=regression!n.@coefs(9)
coefficients(!n,10)=regression!n.@coefs(10)
next
Thank you people!
I have here panel data of about 5000 stocks with monthly return data, as well as accounting and binary sustainability data.
The model I have to run is a cross-sectional regression of the form Return(t,j) = acc1(t,j) + sust2(t,j) + ... at month t and stock j. I have to run this for every month in the sample period.
What I need from these regressions is a matrix that gives me the coefficients, t-statistics, and Rsquares (3 columns) for every month (216 rows), and then I need to calculate the average of each of these coefficients.
I have absolutely no idea how to go about it! I would know how to do this in eviews but for operational purposes I am now using stata. Here is the eviews code:
matrix(216,3) coefficients=na
for !n = 1 to 216
!k = !n+1
equation regression!n.ls ret!k c log(mv!n) log(pb!n) log(psales!n) log(dvol!n) dy!n env!n emp!n div!n sin!n
coefficients(!n,1)=regression!n.@coefs(1)
coefficients(!n,2)=regression!n.@coefs(2)
coefficients(!n,3)=regression!n.@coefs(3)
coefficients(!n,4)=regression!n.@coefs(4)
coefficients(!n,5)=regression!n.@coefs(5)
coefficients(!n,6)=regression!n.@coefs(6)
coefficients(!n,7)=regression!n.@coefs(7)
coefficients(!n,8)=regression!n.@coefs(8)
coefficients(!n,9)=regression!n.@coefs(9)
coefficients(!n,10)=regression!n.@coefs(10)
next
Thank you people!
Comment