I just started using Stata recently as I need to do some statistical analysis for my thesis project. I researched my question but couldn't quite find an answer to the problem I am facing, I hope somebody here can help me.
I am working with a dataset consisting of 5357 mutual funds (identified by wficn) with monthly return observations (mret_Rf) ranging between 12/1961 to 12/2019- to prevent survivorship bias also dead funds are included as well as later invented funds, hence, not all funds show observations for the entire period. Furthermore, each observation shows the value of the variables Mkt_RF SMB HML, which are the dependent variables in the regression analysis.
I want to run a regression as a loop for each of the funds and save the results for every regression for each fund including:
-Number of obs
- The Rsquared value
- Prob > F
- The coefficients
- The Std. Err.
- The t-statistic
- P>|t|
I have written following loop to run the regression in question, unfortunately this code only saves the coefficients (as shown below), which is good but I also need the other values.
I would be really grateful if somebody could help me out here- or indicate if what I am intending to do is simply not possible.
Thank you very much for your help in advance!
Best,
Lennart
Code used:
Code:
tempfile all_results statsby, by (wficn) saving (`all_results'): reg mret_Rf Mkt_RF SMB HML use`all_results'
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double wficn float(_b_Mkt_RF _b_SMB _b_HML _b_cons) 100001 .009468214 -.0018029775 .0006833521 -.0012695126 100003 .010128003 .003318744 .0012590317 -.00022445657 100004 .010225002 -.0010207522 -.002516641 -.001314697 100009 .010970508 .004605711 -.0035189984 .0004628504 100010 .008183149 -.001309696 .00228036 -.001595757 100012 .009820702 -.002918876 .0018024922 .0015416763 100016 .009509544 -.0014319367 -.002432401 -.0007382804 100017 .010104744 -.001968148 .0030095594 -.0021064063 100019 .009635613 .005213343 .0009328977 .0008780413 100030 .011012082 .002016491 -.003541881 -.0021347988
0 Response to Saving Rsquared, t-statistic, and other results in regression loop
Post a Comment