Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: caculate the implied cost of capital

 From dai_yunhao To statalist@hsphsun2.harvard.edu Subject st: caculate the implied cost of capital Date Tue, 30 Aug 2011 06:11:20 -0700 (PDT)

```Hello everybody,

I use the method which is found in the Statalist to caculate the implied
cost of capital, but when I run the program, something wrong with the
program.
The detail as follows:
mata
------------------------------------------------- mata (type end to exit)
----------------------------------------------------
: v=J(1,1,.)

:
: st_view(v,., "x,price,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,froe_1,froe_2
froe_3,froe_4,froe_5,froe_6,froe_7,froe_8,froe_9,f
> roe_10,froe_11,froe_12")

: function
y(x,p,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12)
{
>
> return(-p+b0+b0*(f1-x)/(1+x)+b1*(f2-x)/(1+x)^2+b2*(f3-x)/(1+x)^3+b3*(f4-x)/(1+x)^4+b4*(f5-x)/(1+x)^5+b5*(f6-x)/(1+x)^6+b6*(f
> 7-x)/(1+x)^7+b7*(f8-x)/(1+x)^8+b8*(f9-x)/(1+x)^9+b9*(f10-x)/(1+x)^10+b10*(f11-x)/(1+x)^11+b11*(f12-x)/((1+x)^11))
>
> }

: 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,6],v[i,7],v[i,8],v[i,9],v[i,10],v[i,11],v[i,12],v[i,13],v[i
> ,14],v[i,15],v[i,16],v[i,17],v[i,18],v[i,19],v[i,20],v[i,21],v[i,22],v[i,23],v[i,24],v[i,25],v[i,26])
>
> v[i,1]=x
>
> }
<istmt>:  3301  subscript invalid
r(3301);

could anybody tell me what's the problem and how to sovle the problem?
Thank you!

--
View this message in context: http://statalist.1588530.n2.nabble.com/caculate-the-implied-cost-of-capital-tp6741996p6741996.html
Sent from the Statalist mailing list archive at Nabble.com.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```