I am triing to integrate the following function accrding to h:
FUNCTION:
integralpos <- function(h){
(h)^(m-1)*exp(-x[4]*h-(r[v]-h-x[5]*x[3] + 0.5*(x[6]^2)*x[3])^2/
(2*x[6]^2*x[3]))}
CALL:
integrate(integralneg, -Inf, 0, abs.tol = 1e-08)$val
This works fine if i have example values for all variables (exept h).
The problem arises when i try to nest the integrate function in a loop where the variables change. I use bobyqa for max. likelihood estimation according to the x. The function bobyqa change the values of x[.] but since integralpos is not defined as a function of x it does not "enter" there.
Can somebody help me out here? Is there a way to run integrate with changing variables? Is there another function?
Thank you very much
solved the problem by passing the variables as follows:
integrate(integralneg, -Inf, 0, abs.tol = 1e-08,x=x,r=r,m=m)$val
thx for the help