I'm using R 2.0.1 under Windows XP. I get the following message when I
run the code listed below. I don't seem to have any problems using the
function "slice" outside "integrate".
Error in integrate(slice, 0, Inf, , , , , , , a, b) * delta :
non-numeric argument to binary operator
[ By the way, I'm trying to evaluate a two-dimensional integral by
slicing it up into one-dimensional bits which I will loop over to evaluate.]
Here's the code:
mu <- 0.3
sig2 <- 0.01
alpha <- 20
beta <- 15.75
rho <- 0.1
k <- 1/(rho^2.5*gamma(rho)^2*sqrt(2*pi*sig2))
slice <- function(w,a,b)
{
g <- w^(1/rho)
g1 <- w1^(1/rho)
h <- g1^a*g^b
E <- -(y-rho*mu -g1/alpha + g/beta)^2/(2*sig2*rho)
k*h*exp(E- g1 - g)
}
hi <- 10
delta <- 0.05
grid <- seq(delta/2,hi,delta)
y <- -0.3
a <- 0
b <- 0
m <- length(grid)
A <- rep(0,m)
j <- 0
for (w1 in grid)
{
j <- j+1
A[j] <- integrate(slice,0,Inf,,,,,,,a,b)*delta
cat(A[j],"\n")
}
--
Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz Fax 7 838 4155
Phone +64 7 838 4773 wk Home +64 7 825 0441 Mobile 021 1395 862