Dear Stata users,
I am doing a thesis on mutual fund performance for which I use the Carhart and Fama-French factor models
So three or four explanatory variables (RMRF, SMB, HML and the Carhart factor MOM) to generate fund alphas (the constant), using the returns of mutual funds as dependent variable.
Lucky enough, I found an online thesis that did a similar research as I did (Martineer, 2013). He uses the following code (starting at line 1060 in the do.file):
**Running the model and saving results:
**The model was also run using Newey-West adjusted standard errors for the t-statistics
tempfile abc
tempname def
postfile `def' str32 fund alpha_b alpha_se mkt_b mkt_se smb_b smb_se hml_b hml_se mom_b mom_se rsquared
adjrsquared sic obs normal_p heterosked_p bg1_p bg6_p bg12_p using "`abc'", replace
foreach x of varlist ipaustraliansmallcompanies-zurichinvausvalueretailshrfd {
reg `x' RM_RF SMB HML MOM
quietly predict res, residual
quietly sktest res
scalar skpval = r(P_chi2)
estat hettest
scalar bppval = r(p)
estat bgodfrey, lags(1)
matrix bg1 = r(p)
estadd scalar bg1 = bg1[1,1]
estat bgodfrey, lags(6)
matrix bg6 = r(p)
estadd scalar bg6 = bg6[1,1]
estat bgodfrey, lags(12)
matrix bg12 = r(p)
estadd scalar bg12 = bg12[1,1]
mat ci = e(ci_bc)
quietly ereturn list
estat ic
matrix ic = r(S)
estadd scalar sic = ic[1,6]
post `def' ("`e(depvar)'") (_b[_cons]) (_se[_cons]) (_b[RM_RF]) (_se[RM_RF]) (_b[SMB]) (_se[SMB]) (_b
[HML]) (_se[HML]) (_b[MOM]) (_se[MOM]) (e(r2)) (e(r2_a)) (e(sic)) (e(N)) (skpval) (bppval) (e(bg1)) (e
(bg6)) (e(bg12))
drop res
}
postclose `def'
use "`abc'", clear
*Summarising the coefficients on the four factors, for each fund:
sum alpha_b mkt_b smb_b hml_b mom_b
gsort -alpha_b
gen rank=_n
However, when translating the code to my own dataset I get error codes and Stata remains 'too busy' to execute new orders.
Can anyone help me make the translation to my dataset? For me the varlist is AddVaue-Allianz (these are the different mutual funds).
The only other variables are the time-series data of RM_RF, SMB, HML and MOM.
I am not an experienced Stata user and I could really use some help.
Kind regards,
Melvin Kool
I am doing a thesis on mutual fund performance for which I use the Carhart and Fama-French factor models
So three or four explanatory variables (RMRF, SMB, HML and the Carhart factor MOM) to generate fund alphas (the constant), using the returns of mutual funds as dependent variable.
Lucky enough, I found an online thesis that did a similar research as I did (Martineer, 2013). He uses the following code (starting at line 1060 in the do.file):
**Running the model and saving results:
**The model was also run using Newey-West adjusted standard errors for the t-statistics
tempfile abc
tempname def
postfile `def' str32 fund alpha_b alpha_se mkt_b mkt_se smb_b smb_se hml_b hml_se mom_b mom_se rsquared
adjrsquared sic obs normal_p heterosked_p bg1_p bg6_p bg12_p using "`abc'", replace
foreach x of varlist ipaustraliansmallcompanies-zurichinvausvalueretailshrfd {
reg `x' RM_RF SMB HML MOM
quietly predict res, residual
quietly sktest res
scalar skpval = r(P_chi2)
estat hettest
scalar bppval = r(p)
estat bgodfrey, lags(1)
matrix bg1 = r(p)
estadd scalar bg1 = bg1[1,1]
estat bgodfrey, lags(6)
matrix bg6 = r(p)
estadd scalar bg6 = bg6[1,1]
estat bgodfrey, lags(12)
matrix bg12 = r(p)
estadd scalar bg12 = bg12[1,1]
mat ci = e(ci_bc)
quietly ereturn list
estat ic
matrix ic = r(S)
estadd scalar sic = ic[1,6]
post `def' ("`e(depvar)'") (_b[_cons]) (_se[_cons]) (_b[RM_RF]) (_se[RM_RF]) (_b[SMB]) (_se[SMB]) (_b
[HML]) (_se[HML]) (_b[MOM]) (_se[MOM]) (e(r2)) (e(r2_a)) (e(sic)) (e(N)) (skpval) (bppval) (e(bg1)) (e
(bg6)) (e(bg12))
drop res
}
postclose `def'
use "`abc'", clear
*Summarising the coefficients on the four factors, for each fund:
sum alpha_b mkt_b smb_b hml_b mom_b
gsort -alpha_b
gen rank=_n
However, when translating the code to my own dataset I get error codes and Stata remains 'too busy' to execute new orders.
Can anyone help me make the translation to my dataset? For me the varlist is AddVaue-Allianz (these are the different mutual funds).
The only other variables are the time-series data of RM_RF, SMB, HML and MOM.
I am not an experienced Stata user and I could really use some help.
Kind regards,
Melvin Kool
Comment