integral with error:non-finite function value

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

integral with error:non-finite function value

Balqis
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

Best wishes,
Al

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: integral with error:non-finite function value

Berend Hasselman
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