integration {EstimationTools}R Documentation

Integration

Description

[Experimental]

This is a wrapper routine for integration in maxlogL framework. It is used in integration for compute detectability density functions and in computation of mean values, but it is also a general purpose integrator.

Usage

integration(fun, lower, upper, routine = "integrate", ...)

Arguments

fun

an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x.

lower

a numeric value for the lower limit of the integral.

upper

a numeric value for the upper limit of the integral.

routine

a character specifying the integration routine. integrate and gauss_quad are available, but the custom routines can be defined.

...

additional arguments to be passed to fun and to the integration routine specified in routine argument.

Details

The user can create custom integration routines through implementation of a wrapper function using three arguments

The output must be a numeric atomic value with the result of the integral.

Author(s)

Jaime Mosquera GutiƩrrez, jmosquerag@unal.edu.co

See Also

integrate, gauss_quad

Examples

library(EstimationTools)


#----------------------------------------------------------------------------
# Example 1: Mean of X ~ N(2,1) using 'integrate'.
mynorm <- function(x, mu, sigma) x*dnorm(x, mean = mu, sd = sigma)
i1 <- integration(mynorm, lower = -Inf, upper = Inf, mu = 2, sigma = 1)
i1

#----------------------------------------------------------------------------
# Example 2: Mean of X ~ N(2,1) using 'gauss_quad' (Gauss-Hermitie
#            quadrature).
g <- function(x, mu, sigma) sqrt(2)*sigma*x + mu
i2 <- integration(g, lower = -Inf, upper = Inf, routine = 'gauss_quad',
                  kind = 'hermite.h', normalized = FALSE,
                  mu = 2, sigma = 1)
i2 <- i2/sqrt(pi)
i2


#----------------------------------------------------------------------------
# Example 3: replicating integrate
i3 <- integrate(dnorm, lower=-1.96, upper=1.96)
i4 <- integration(dnorm, lower=-1.96, upper=1.96)
identical(i3$value, i4)

#----------------------------------------------------------------------------


[Package EstimationTools version 4.0.0 Index]