Hi all,

Can anyone help me with below integrate function?

Basically, I want to calculate the integral of  the sum of two kernel
density functions.
But the error shows that:
 In x - a :
  longer object length is not a multiple of shorter object length

y1 = rnorm(10)
y2 = rnorm(10)
fhat <- function(x,a){h=density(a)$bw;sum(dnorm((x-a)/h)/h/length(a))}

 integrand1 <- function(p) {
             fhat(p,y1)+fhat(p,y2)
         }
integrate(integrand1,lower = -Inf, upper = Inf)


Thanks in advance,


Dan

	[[alternative HTML version deleted]]

