Attaullah Shah unfortunately, I can't share the data but this is the code:

And then I merged icc_ct_ and icc_ct. I still have to verify, whether I did it correctly, so I better don't post that part of the code

Code:

generate icc_ct_=. mata z=J(1,1,.) st_view(z,., "icc_ct_ price bv_t0 feps_t1 feps_t2 feps_t3 feps_t4 feps_t5 growth payoutratio") function y(x,p,b0,f1,f2,f3,f4,f5,g,dv) { tf = f1+f2+f3+f4 t1 = (f1-x*b0)/(1+x) t2 = (f2-x*(b0+f1*(1-dv)))/(1+x)^2 t3 = (f3-x*(b0+(1-dv)*(f1+f2)))/(1+x)^3 t4 = (f4-x*(b0+(1-dv)*(f1+f2+f3)))/(1+x)^4 t5 = (f5-x*(b0+(1-dv)*tf))/(1+x)^5 tv = ((f5-x*(b0+(1-dv)*tf))*(1+g))/((x-g)*(1+x)^5) return(-p+b0+t1+t2+t3+t4+t5+tv) } for (i=1;i<=rows(z);i++) { r=mm_root(icc_ct_=.,&y(),smallestdouble(),z[i,9]-epsilon(1),1e-9,1000,z[i,2],z[i,3],z[i,4],z[i,5],z[i,6],z[i,7],z[i,8],z[i,9],z[i,10]) z[i,1]=icc_ct_ } end generate icc_ct=. mata z=J(1,1,.) st_view(z,., "icc_ct price bv_t0 feps_t1 feps_t2 feps_t3 feps_t4 feps_t5 growth payoutratio") function s(x,p,b0,f1,f2,f3,f4,f5,g,dv) { tf = f1+f2+f3+f4 t1 = (f1-x*b0)/(1+x) t2 = (f2-x*(b0+f1*(1-dv)))/(1+x)^2 t3 = (f3-x*(b0+(1-dv)*(f1+f2)))/(1+x)^3 t4 = (f4-x*(b0+(1-dv)*(f1+f2+f3)))/(1+x)^4 t5 = (f5-x*(b0+(1-dv)*tf))/(1+x)^5 tv = ((f5-x*(b0+(1-dv)*tf))*(1+g))/((x-g)*(1+x)^5) return(-p+b0+t1+t2+t3+t4+t5+tv) } for (i=1;i<=rows(z);i++) { r=mm_root(icc_ct=.,&s(),z[i,9]+epsilon(1),1-epsilon(1),1e-9,1000,z[i,2],z[i,3],z[i,4],z[i,5],z[i,6],z[i,7],z[i,8],z[i,9],z[i,10]) z[i,1]=icc_ct } end

## Comment