
This method is a wrapper for inla and provides multiple enhancements.
Easy usage of spatial covariates and automatic construction of inla projection matrices for (spatial) SPDE models.
This feature is accessible via the components
parameter.
Practical examples on how to use spatial data by means of the components parameter can also be found by looking at the lgcp
function's documentation.
Constructing multiple likelihoods is straight forward. See like for more information on how to provide additional
likelihoods to bru
using the ... parameter list.
Support for non-linear predictors. See example below.
Log Gaussian Cox process (LGCP) inference is available by using the cp
family or (even easier) by using the
lgcp function.
bru(components = y ~ Intercept, family = NULL, data = NULL, ...,
options = list())
a formula describing the latent components. See bru.components for details.
A string indicating the likelihood family. The default is gaussian
with
identity link. In addition to the likelihoods provided by inla
(see inla.models()$likelihood
) inlabru supports fitting Cox processes
via family = "cp"
. The latter requires contructing a likelihood using the like
function and providing it via the ... parameter list. As an alternative to bru, the lgcp
function provides a convenient interface to fitting Cox processes. See details.
A data.frame or SpatialPoints[DataFrame] object. See details.
Additional likelihoods, each constructed by a calling like. See details.
A list of name and value pairs that are either interpretable by bru.options or valid inla parameters.
bru returns an object of class "bru". A bru
object inherits from inla
(see the inla documentation for its properties) and adds additional information stored
in the sppa
field.
family and ... must either be parameters to like, or lhood
objects constructed by like.
data
must either be an lhood
object, a data container, or NULL
. If NULL
,
data must be supplied through direct calls to like.
# NOT RUN {
if (require("INLA", quietly = TRUE)) {
# Simulate some covariates x and observations y
input.df <- data.frame(x=cos(1:10))
input.df <- within(input.df, y <- 5 + 2*x + rnorm(10, mean=0, sd=0.1))
# Fit a Gaussian likelihood model
fit <- bru(y ~ x + Intercept, "gaussian", input.df)
# Obtain summary
fit$summary.fixed
}
if (require("INLA", quietly = TRUE)) {
# Alternatively, we can use the like() function to construct the likelihood:
lik = like(family = "gaussian", data = input.df)
fit <- bru(y ~ x + Intercept, lik)
fit$summary.fixed
}
# An important addition to the INLA methodology is bru's ability to use
# non-linear predictors. Such a predictor can be formulated via like()'s
# \code{formula} parameter. For instance
if (require("INLA", quietly = TRUE)) {
z = 2
input.df <- within(input.df, y <- 5 + exp(z)*x + rnorm(10, mean=0, sd=0.1))
lik = like(family = "gaussian", data = input.df, formula = y ~ exp(z)*x + Intercept, E = 10000)
fit <- bru( ~ z + Intercept, lik)
# Check the result (z posterior should be around 2)
fit$summary.fixed
}
# }
Run the code above in your browser using DataLab