0

i'm trying to integrate a density function but I'm getting the error

Error in integrate(approxfun(data_density), lower = strike_x, upper = strike_y) : 
  non-finite function value

I removed NAs from data_density already This is my code

data_density <- density(na.omit(data$AAPL.Close))

prob<-try(integrate(approxfun(data_density), lower=strike_x, upper=strike_y))

strike_x and strike_y are positive integers How can I fix this?

Filipe Ferminiano
  • 8,373
  • 25
  • 104
  • 174
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 07 '20 at 03:46
  • +1 For @MrFlick. From what you've given us so far, I don't think your problem is `NA`s. I think `approxfun` is returning `Inf` for some values of `datadensity`. – Limey Jun 07 '20 at 06:15

0 Answers0