Numeric Integration in R
From ECON 520
In R, you can numerically integrate a function that has a scalar input, as follows.
First, if necessary, define the function:
> myfunction <- function(x) { [function body]}
Then, use
> integrate(myfunction, lower=L, upper=U)
where L is the lower bound of integration, and U is the upper bound. You can use -Inf and Inf for negative and positive infinity in the specification of the bounds of integration.
