On 15.02.2010 06:34, Roslina Zakaria wrote:
Hi r-users,

I hope somebody can help me to understand the error message.  Here is my code;

## Newton iteration
newton_gam<- function(z)
{ n<- length(z)
   r<- runif(n)
   tol<- 1E-6
   cdf<- vector(length=n, mode="numeric")
   fprime<- vector(length=n, mode="numeric")
   f<- vector(length=n, mode="numeric")

   for (i in 1:1000)
   { cdf<- integrate(fprime, lower = 0, upper = z)$value


fprime is a vector of zeros here, not a function...


     f<- cdf - r
     # Newton method
     z<- z - f/fprime

... and given fprime is a vector of zeros, f/fprime this is infinite or undefinied.



     if (any(f<  tol)) break
    }
   cbind(z,cdf)
}

alp<- 2.0165
bt1<- 29.107 ; bt2<- 41.517
x1<- d1d4pos[,1];x1[1:10]
x2<- d1d4pos[,2];x2[1:10]

x1<- d1d4pos[,1];x1[1:10]


We do not have d1d4pos.

Please ......!


Uwe Ligges


  [1] 28.4 53.6  1.3 29.5 52.1 65.9 72.6 67.6 58.7 34.5
x2<- d1d4pos[,2];x2[1:10]
  [1]  43.5  56.2   0.3  16.6  71.1  86.3 172.8 111.8  89.9  70.2

z<- (x1/bt1)+(x2/bt2); z

newton_gam(min(z))
newton_gam(max(z))

Error in -`*tmp*` : invalid argument to unary operator
newton_gam(min(z))
        z          cdf
[1,] Inf 1.141004e-05
newton_gam(max(z))
Error in integrate(fprime, lower = 0, upper = z) :
   non-finite function value

z[100]
[1] 7.544834
newton_gam(z[100])
Error in integrate(fprime, lower = 0, upper = z) :
   non-finite function value

Thank you.





        [[alternative HTML version deleted]]




______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to