Message-ID: <20090304160951.e98gncjkg8cwokw8@posta.apat.it>
Date: 2009-03-04T15:09:51Z
From: andrea.toreti at apat.it
Subject: help with integration
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