bru_model: Create an inlabru model object from model components

View source: R/model.R

bru_modelR Documentation

Create an inlabru model object from model components

Description

The inlabru syntax for model formulae is different from what INLA::inla considers a valid. In inla most of the effects are defined by adding an f(...) expression to the formula. In inlabru the f is replaced by an arbitrary (exceptions: const and offset) string that will determine the label of the effect. See Details for further information.

Usage

bru_model(components, lhoods)

## S3 method for class 'bru_model'
summary(object, ...)

## S3 method for class 'summary_bru_model'
print(x, ...)

Arguments

components

A component_list object

lhoods

A list of one or more lhood objects

object

Object to operate on

...

Arguments passed on to other methods

x

A summary_bru_model object to be printed

Details

For instance

y ~ f(myspde, ...)

in INLA is equivalent to

y ~ myspde(...)

in inlabru.

A disadvantage of the inla way is that there is no clear separation between the name of the covariate and the label of the effect. Furthermore, for some models like SPDE it is much more natural to use spatial coordinates as covariates rather than an index into the SPDE vertices. For this purpose inlabru provides the new main agument. For convenience, the main argument can be used like the first argument of the f function, e.g., and is the first argument of the component definition.

y ~ f(temperature, model = 'linear')

is equivalent to

y ~ temperature(temperature, model = 'linear') and y ~ temperature(main = temperature, model = 'linear') as well as y ~ temperature(model = 'linear') which sets main = temperature.

On the other hand, map can also be a function mapping, e.g the coordinates function of the sp package :

y ~ mySPDE(coordinates, ...)

This exctract the coordinates from the data object, and maps it to the latent field via the information given in the mapper, which by default is extracted from the model object, in the case of spde model objects.

Morevover, main can be any expression that evaluates within your data as an environment. For instance, if your data has columns 'a' and 'b', you can create a fixed effect of 'sin(a+b)' by setting map in the following way:

y ~ myEffect(sin(a+b))

Value

A bru_model object


inlabru documentation built on Nov. 2, 2023, 6:07 p.m.