Error in R: roundoff error is detected in the extrapolation table

514 views Asked by At

I'm trying to calculate consumer surplus with integrate function in R.

PID = 2040;
integrand <- function(x) {320000*x^(-0.1)} 
integrate(integrand, lower = PID, upper = Inf,  
          rel.tol=.Machine$double.eps^.05 )$value

Then an error shows "roundoff error is detected in the extrapolation table". If I change the exponent to -1, then no error shows and it emits a value. How can I fix the error with keeping the exponent value -0.1?

Thank you so much for your help in advance.

1

There are 1 answers

0
Antreas Stefopoulos On

Try this,

PID = 2040;
integrand <- function(x) {320000*x^(-0.1)} 
integrate(integrand, lower = PID, upper = .Machine$double.xmax, rel.tol=.Machine$double.eps^.05 )$value