[R] help with integration
andrea.toreti at apat.it
andrea.toreti at apat.it
Wed Mar 4 16:09:51 CET 2009
Dear all,
I have a problem with the integration of the following function.
Could you please give some suggestions?
Thank you very much!!!
y<-rnorm(n=100)
f<-function(x,xi,h){
n<-length(xi)
Ke<-c()
for(t in 1:n) {
Ke[t]<-dnorm((x-xi[t])/h)
}
fke<-sum(Ke)*(1/(n*h))
fke<-fke^2
return(fke)
}
integrate(f,-Inf,Inf,xi=y,h=0.32)
I obtained this error:
evaluation of function gave a result of wrong length
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
50: In Ke[t] <- dnorm((x - xi[t])/h) :
number of items to replace is not a multiple of replacement length
More information about the R-help
mailing list