[R] integral with error:non-finite function value

Berend Hasselman bhh at xs4all.nl
Tue Jul 3 19:48:03 CEST 2012


Al Ehan wrote
> 
> Hi guys,
> 
> I'm trying to use the the integral function to estimate the area under a
> PDF and a crossing curve. first I stated the function with several vectors
> in it:
> 
> fn=function(a,b,F,mu,alpha,xi)
>  {
> x<-vector()
> fs<-function(x)
> {
> c <- (mu+(alpha*(1-(1-F)^xi)/xi))
> tmp <- (1 + (xi * (x - mu))/alpha)
>     ((as.numeric(tmp > 0) * (tmp^(-1/xi - 1) *
> exp(-tmp^(-1/xi))))/alpha)*((a*(x-c)^0.5)+(b*(x-c)))
> }
> return(fs)}
> 
> #then I use the integral function
> 
> xn<-fn(1,2,0.98,824,300,-0.0098)
> horror<-integrate(xn,lower=2021,upper=Inf)
> 
> what I got is error message
> #Error in integrate(xn, lower = 2021, upper = Inf) :
> #  non-finite function value
> 
> can somebody help me by giving some light how to solve this problem? many
> thanks
> 

Try

xn(Inf)
xn(1e6)
xn(1e4)

and then

horror<-integrate(xn,lower=2021,upper=1e4) 
horror

Berend

--
View this message in context: http://r.789695.n4.nabble.com/integral-with-error-non-finite-function-value-tp4635309p4635316.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list