Skip to contents

A typical task in statistical inference to integrate a (multivariate) function along one or more dimensions of its domain. For this purpose, the function is evaluated at some points in the domain and the values are summed up using weights that depend on the area being integrated over. This function performs the weighting and summation conditional for each level of the dimensions that are not integrated over. The parameter dims states the the dimensions to integrate over. The set of dimensions that are held fixed is the set difference of all column names in data and the dimensions stated by dims.

Usage

int(data, values, dims = NULL)

Arguments

data

A data.frame or Spatial object. Has to have a weight column with numeric values.

values

Numerical values to be summed up, usually the result of function evaluations.

dims

Column names (dimension names) of the data object to integrate over.

Value

A data.frame of integrals, one for each level of the cross product of all dimensions not being integrated over.

Examples

# \donttest{
# ipoints needs INLA
if (bru_safe_inla(quietly = TRUE)) {
  # Create integration points in two dimensions, x and y

  ips <- cprod(
    ipoints(c(0, 10), 10, name = "x"),
    ipoints(c(1, 5), 10, name = "y")
  )

  # The sizes of the domains are 10 and 4 for x and y, respectively.
  # Integrating f(x,y) = 1 along x and y should result in the total
  # domain size 40

  int(ips, rep(1, nrow(ips)), c("x", "y"))
}
#>   .block integral
#> 1    1,1       40
# }