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
Does STATA REG provide test statistic for Fitness of model and/or homogeneity of residuals and or misspecification?Hello everyone, Does STATA REG provide test statistic for Fitness of model and/or homogeneity of re…
determine an uninterrupted string of n positive yearly valuesHi, I need to compute a variable x corresponding to the first year of an uninterrupted string of 10…
Tagging individuals who migrated in panel dataI have data in long form with information on individual id, time period and cities where they worked…
Encountering an error when using local macros in the xtqreg packageGood Evening, I am attempting to pass a varlist into a local macro as follows: Code: local predic…
Reshape problem: values of variable j not unique within idHi all, I am trying to generate Dummy variables from a question with multiple responses. Lamentably…
Subscribe to:
Post Comments (Atom)
0 Response to Invalid name
Post a Comment