Hello everyone,
I would like to kindly ask the community for a help. I use STATA 16, Windows 10. When I run the code:
. capture program drop capm
. program define capm, rclass
1. syntax varlist(min=2 max=2 numeric) [if], RFrate(varname)
2. local stockret: word 1 of `varlist´
3. local mktret: word 2 of `varlist´
4. cap drop prem`stock´
5. qui gen prem`stock´=`stockret´-`rfrate´
6. cap drop mktpremium
7. qui gen mktpremium=`mktret´-`rfrate´
8. cap reg prem`stock´ mktpremium `if´
9. if _rc==0 & r(N)>30 {
10. matrix res= r(table)
11. local b1=res[1,1]
12. local b0=res[1,2]
13. local SEb1=res[2,1]
14. local SEb0=res[2,2]
15. local N=e(N)
16. dis "Market beta is " %3.2f `b1´ "; std. error of beta is " %8.6f `SEb1´
17. dis "Alpha is " %8.6f `b0´ "; std. error of alpha is " %8.6f `SEb0´
18. return scalar b1=`b1´
19. return scalar b0=`b0´
20. return scalar SEb1=`SEb1´
21. return scalar SEb0=`SEb0´
22. return scalar N=`N´
23. }
24. end
. qui freduse TB3MS, clear
. qui gen m_Rf = (TB3MS/100)/12
. qui gen m_rf = ln(1 + m_Rf)
. qui gen period =mofd(daten)
. format period %tm
. qui tsset period
. cap getsymbols ^GSPC CAG, fy(2014) freq(m) yahoo clear price(adjclose)
. qui merge 1:1 period using rfrate, keepusing(m_rf)
. qui drop if _merge!=3
. qui drop _merge
. capm r_CAG r__GSPC, rfrate(m_rf)
I get "invalid name r(198);" error. May I ask you ladies and gentlemen to tell me what is wrong? I tried with different .do files with and without saving and I still face the same problem. The code comes from a conference on measuring abnormal returns of stock and everything comes from a file shares with audience.
Best Regards,
Rafał
Related Posts with Invalid name
mlabel in scatter plotDear Stata users, I'm trying to produce a graph with both scatter and lfit commands. I would like t…
Solving nonlinear function in StataHi everyone, I'm trying to generate a variable (r) using an implicit expression. The equation is: (…
Interpretation on the Granger CausalityArray I am trying to characterise temporal sequence of influences in a VAR and wanted to use the Gra…
Convert categorical variable to dummy variables in a large datasetDear everyone, I have a dataset of 350 categorical variables, e.g: How satisfied are you with your …
generate separate group variables instead of categorical variable. Need your help!Hi everyone, I have a logistic model to test the effect of different individual characteristics on …
Subscribe to:
Post Comments (Atom)
0 Response to Invalid name
Post a Comment