Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

st: Missing values in internal rate of return calculation

 From Tanja Berg To statalist@hsphsun2.harvard.edu Subject st: Missing values in internal rate of return calculation Date Wed, 23 May 2012 19:25:17 +0200

```Hi,

I want to do an internal rate of return calculation in Mata.

That is what I have programmed so far:

mata
v=J(4850,50,.)

pricenew=v[.,2];cf1=v[.,3];cf2=v[.,4];cf3=v[.,5];cf4=v[.,6];cf5=v[.,7];cf6=v[.,8];cf7=v[.,9];cf8=v[.,10];cf9=v[.,11];cf10=v[.,12];cf11=v[.,13];cf12=v[.,14];cf13=v[.,15];cf14=v[.,16];cf15=v[.,17];cf16=v[.,18];spot1=v[.,19];spot2=v[.,20];spot3=v[.,21];spot4=v[.,22];spot5=v[.,23];spot6=v[.,24];spot7=v[.,25];spot8=v[.,26];spot9=v[.,27];spot10=v[.,28];spot11=v[.,29];spot12=v[.,30];spot13=v[.,31];spot14=v[.,32];spot15=v[.,33];spot16=v[.,34];mat1=v[.,35];mat2=v[.,36];mat3=v[.,37];mat4=v[.,38];mat5=v[.,39];mat6=v[.,40];mat7=v[.,41];mat8=v[.,42];mat9=v[.,43];mat10=v[.,44];mat11=v[.,45];mat12=v[.,46];mat13=v[.,47];mat14=v[.,48];mat15=v[.,49];mat16=v[.,50]

}

for (i=1;i<=rows(v);i++) {
}
end

The variable "zspread" is the internal rate of return I want to get.
But I always get missing values for the zspread. I think this is the case because my data I imported from Stata includes missing values, but I can't just delete the observations with missing values because all the observations include at least one missing value.
I tried to replace the missing values by zero, but then I get zero as a result for the "zspread".

Is it possible that Mata can somehow ignores missing values and calculate only with the data available for each observation??

I really need your help! I am searching the web for hours and can't find any solution for this problem.
It has to work somehow.

Thanks and regards!

*
*   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/
```