Dear Statalisters,
I have an unbalanced panel data, where among many other variables, I have: p(current price), eps1, dps, eps2 and x(implied cost of capital). All variables, except x, are known and carry a value. An excerpt of first 20 observations is shown below.
My purpose is to find x using PEG model (by Easton (2004) by following formula:
I've searched previous posts and found this back in 2010: https://www.stata.com/statalist/arch.../msg01113.html
I made an effort to change the code to meet my setting:
To follow previous post, my intuition was that I should use the first non-missing observation, so I used observation number 8 in the code (in bold). The code is supposed to find the value of x between lower and upper bound of 0 and 1. Moremata is installed from SSC. But the code ends up with error:
Code:
I am unfamiliar with Mata and it is kind of complicated for me. So I will be grateful if you guide me through this.
Thanks in advance for your kind attention.
Best,
Mohsen
I have an unbalanced panel data, where among many other variables, I have: p(current price), eps1, dps, eps2 and x(implied cost of capital). All variables, except x, are known and carry a value. An excerpt of first 20 observations is shown below.
p | hvz1_eps | dps | hvz2_eps | ||
1. | . | . | . | . | |
2. | . | .1247489 | . | . | |
3. | . | . | . | . | |
4. | . | . | . | . | |
5. | 1.91 | . | 0 | . | |
6. | 3.72 | . | 0 | .1975022 | |
7. | 4.7 | .2124444 | 0 | .2172921 | |
8. | 5.37 | .2103094 | .19 | .2131406 | |
9. | 6.72 | .2066778 | .23 | .2100024 | |
10. | 6.57 | .2006544 | .22 | . | |
11. | 7.01 | . | .22 | . | |
12. | . | . | . | . | |
13. | . | . | . | .2131791 | |
14. | . | .208495 | . | . | |
15. | . | . | . | . | |
16. | 5.3 | .2281662 | .12 | .2314164 | |
17. | 5.39 | .2250118 | .27 | .2278917 | |
18. | 6.1 | .2258492 | .4 | .2257041 | |
19. | 6.71 | .2245243 | .32 | .2224477 | |
20. | 6.91 | .2251943 | .4 |
I've searched previous posts and found this back in 2010: https://www.stata.com/statalist/arch.../msg01113.html
I made an effort to change the code to meet my setting:
HTML Code:
gen x=. mata v=J(1,1,.) st_view(v,.,"x p hvz1_eps dps hvz2_eps") function y(x,a,b,c,d) { return((.2131406+(x*0.19)-.2103094)/x^2) } for (i=1;i<=rows(v);i++) { r=mm_root(x=.,&y(),0,1,1e-9,1000,v[i,2], v[i,3],v[i,4],v[i,5]) v[i,1]=x } end
Code:
Code:
<istmt>: 3499 mm_root() not found
Thanks in advance for your kind attention.
Best,
Mohsen
Comment