bru_obs()
as a replacement to like()
, to help avoid namespace
clashes with e.g. data.table::like()
(version 2.11.1.9026
)like
/bru_obs(allow_combine)
to allow user override, and
add warnings for ambiguous cases (version 2.11.1.9011
)bru_response_size()
method for extracting the response size for each
observation bru_like
object (version 2.11.1.9013
)sf
output format support for sline
and spoly
(version 2.11.1.9006
)[
and ]
to special character set in bru_standardise_names()
(version 2.11.1.9012
)bru_index()
method for accessing predictor index information for
sub-models, and a tag
argument for bru_obs()
to identify individual
sub-models by name, which is also propagated to lists of bru_like
objects
(version 2.11.1.9017
and 2.12.0
)bru_mapper_multi()
sub-mappers to have non-zero offsets, that are
added to generate the combined offset (version 2.11.1.9019
)bru_mapper_fmesher()
mapper, for indexed mapping of
all objects supporting fm_dof()
and fm_basis()
(version 2.11.1.9021
)bru_mapper_repeat()
mapper, for automated single-mapper sums
(version 2.11.1.9022
)mrsea
to sf
format (version 2.11.1.9009
)shrimp
data set to sf
format (version 2.11.1.9007
)seals_sp
data set due to excessive size (version 2.11.1.9010
)mexdolphin
dataset with a function mexdolphin_sp()
to avoid sp
data objects in the package (version 2.11.1.9015
)gorillas
dataset with a function gorillas_sp()
to avoid sp
data objects in the package (version 2.11.1.9016
)sp
from Imports
to Suggests
. Component definitions using
coordinates
as input require either sp::coordinates
or sp
having been
already loaded with e.g. library(sp)
(version 2.11.1.9003
)ggmap
support (version 2.11.1.9002
)INLA
namespace loading in ggplot
methods
(version 2.11.1.9008
)terra
from Imports
to Suggests
(version 2.11.1.9014
)fmesher
methods (version 2.11.1.9020
)is.inside()
have been removed.
Use fmesher::fm_is_within()
instead.bru_mapper.default()
to define new mapper classes
has been removed. Use bru_mapper_define()
instead.bru_mapper_offset()
method has been removed.
Use bru_mapper_const()
instead."list"
class inheritance from solitary classes
(version 2.11.1.9001
)summary
and print
method class coverage (version 2.11.1.9002
)bru_safe_inla()
(version 2.11.1.9005
)component
and component_list
methods to bru_component
and bru_component_list
(version 2.11.1.9026
)scale
parameter to like()
.inla.mdata()
and inla.surv()
,
when INLA version > 24.06.02
(for mdata
) or > 24.06.26
(for surv
) are
available (version 2.10.1.9011
)toypoints
example data set, for basic modelling examples
(version 2.10.1.9003
)2.10.1.9004
)bru_convergence_plot()
to control the number of iterations
shown, and optionally show the initial values that are stored from this version
(version 2.10.1.9005
)Sys.time()
to proc.time()
to capture CPU time
instead of elapsed clock time. Added bru_timings()
method to extract the timings
safely from a fitted bru
object (version 2.10.1.9007
and 2.10.1.9010
)2.10.1.9012
)"bym"
model support, where the latent state size
wasn't correctly handled by the mapper system (version 2.10.1.9002
)2.10.1.9006
)sp
data input for family = "cp"
(version 2.10.1.9008
)ipoints(samplers, domain)
is no longer available.
Use fmesher::fm_int(domain, samplers)
instead.allow_latent
, include_latent
arguments to like()
have been deprecated in favour
of the general bru_used()
framework, that auto-detects what component effects and
latent effects are used by a predictor expression.cprod()
method now gives a warning and will be removed in a future version.
Use fmesher::fm_cprod()
instead.integration_weight_aggregation
method has been removed (deprecated since 2.8.0).
Use fmesher::fm_vertex_projection()
instead.mesh_triangle_integration
method has been removed (deprecated since 2.8.0).
Use fmesher::fm_int()
instead.bru_mapper.default()
to define new mapper classes has been disabled
(deprecated since 2.7.0). Use bru_mapper_define()
instead.is.inside()
, vertices.inla.mesh()
, and
pixels()
have been disabled. Use fmesher::fm_is_within()
, fmesher::fm_vertices()
,
and fmesher::fm_pixels()
instead.ggpolypath
package, and the
ggplot2::fortify.SpatialPolygons/DataFrame()
methods that were deprecated in
ggplot2
version 3.4.4
. Code using gg.SpatialPolygons()
together with
coord_fixed()
/coord_equal()
for coordinate axis control needs to use
coord_sf()
instead.bru_forward_transformation
to
allow bru_mapper_marginal
to be applied with e.g. spatially varying parameters.
(version 2.10.0.9001
)terra
version >= 1.7-66
that removes the need for
detecting special cases (nrow(where) == 1
and terra::nlyr(data) == 1
).
Workaround code used for versions < 1.7-66
. (version 2.10.0.9002
)
(Thanks to Robert J. Hijmans)ibm_simplify()
generic to handle mapper simplification more generally;
needed to properly support non-linear component mappers. (version 2.9.0.9004
)bru_mapper_marginal()
mapper class that can be used as part of component
mapper pipelines. (version 2.9.0.9004
)ibm_eval2()
generic that computes both evaluation and Jacobian,
avoiding double-computing of the Jacobian, when practical. (version 2.9.0.9005
)bru_timings_plot()
function that plots the time used for each nonlinear iteration
(version 2.9.0.9007
)bru_fill_missing()
(by orders of magnitude) by changing method for
finding the nearest available data point. (version 2.9.0.9011
)bru_mapper_shift()
mapper class that works like bru_mapper_scale()
but for additive shifts instead of multiplicative scaling. (version 2.9.0.9012
)2.9.0.9013
)bru_mapper_matrix
, previously used only for component model = "fixed"
,
to allow integer indexing in addition to the previous factor/character-only indexing.
(version 2.9.0.9014
)is_linear
flag wasn't correctly set for bru_mapper_logsumexp
mappers.
Since previous versions did not accept non-linear component mappers, this
is unlikely to have affected any user code. (Fixed in version 2.9.0.9001
)2.9.0.9002
and 2.9.0.9006
)NULL
in automatic component usage detection. (version 2.9.0.9003
)gorillas$plotsample$counts
and
gorillas_sf$plotsample$counts
from +units=m
to +units=km
. (version 2.9.0.9010
)
The geometry information in counts
is unlikely to have been used in examples
or analysis code, as the problem would have been immediately obvious;
plotting or other geometric operations that use the crs information would
heve been completely wrong, and is only detected now that more code uses the
crs information at all. Thanks to Dmytro Perepolkin for reporting in issue #205bru_fill_missing()
for cases where the input data object also
has missing values. (version 2.9.0.9011
)eval_spatial()
transform the where
coordinates to the same crs as the
input data, for SpatRaster
and sf
inputs, to allow different crs specifications.
(version 2.9.0.9012
)Conversion of code to use fmesher
for mesh and geometry handling;
the interface supports existing objects and methods.
See https://inlabru-org.github.io/fmesher/articles/inla_conversion.html for
more information.
General speed improvements, see below for details.
Added gg.sf()
method.
Add experimental support for stars
via eval_spatial()
.
(version 2.8.0.9007
)
Move the sp
package from 'Depends' to 'Imports'. This means that user code
should either use sp::
or library("sp")
to access sp
methods.
The bru_safe_sp()
helper function can be used to check for a safe
sp
package configuration during the transition from rgdal
to sf
, and
is only needed if you may run on systems with sp
installations older than
"2.0-0" or with sp::get_evolution_status() < 2
. (version 2.8.2011
)
Now preserves the previous log output when using bru_rerun()
,
and bru_log()
is now a set of S3 methods, supporting extracting the
full inlabru log as well bru
-object specific logs (version 2.8.0.9008
).
Note: From version 2.9.0
, use bru_log()
to access the global log, and
bru_log(fit)
to access a stored estimation log.
Up to version 2.8.0
, bru_log()
was a deprecated alias for
bru_log_message()
. When running on 2.8.0
or earlier, use bru_log_get()
to access the global log, and cat(fit$bru_iinla$log, sep = "\n")
to print
a stored estimation object log.
SpatialPolygonsDataFrame
were not automatically passed on to eval_spatial()
. The logic has now changed
so that any object with a eval_spatial()
method will trigger a call to
eval_spatial()
. See ?input_eval
for further information.
(version 2.8.0.9001
)fm_crs_is_null()
, fm_transform()
now supports oblique fm_crs
CRS objects,
and is.na()
methods for the fm_crs
and inla.CRS
classes have been added.
(version 2.8.0.9003
)predict()
by using quantile(..., names = FALSE)
.
(version 2.8.0.9004
)row_kron()
code, causing speedups of a factor 2-30 in randomised
test cases. (version 2.8.0.9005
)sf
method for eval_spatial()
, causing failure
when extracting from multiple layers in a single call.
(version 2.8.0.9007
)generate()
and predict()
. Now much faster for large models. (version 2.8.0.9009
)*_latent
form of a component.
(version 2.8.0.9015
)bru_fill_missing()
. (version 2.8.0.9016
, fixes #200)eval_SpatialDF
removed, deprecated since 2.8.0
. See eval_spatial
instead.stransform
, ibm_amatrix
, ibm_valid_input
removed, deprecated since 2.7.0
.
See fm_transform
and ibm_jacobian
instead.bru_mapper_offset
, deprecated since 2.6.0
now returns a pure bru_mapper_const
object, and all bru_mapper_offset
ibm_*
methods have been removed.init.tutorial
removed, deprecated since 2.5.0
generate.inla
and predict.inla
removed, deprecated since 2.1.0
The iterative inla method has been given both sharper internal inla()
optimisation
criteria for the iterations (thanks to Haavard Rue), and a more relaxed
nonlinear iteration stopping criterion; the default bru_method$rel_tol
values has been changed from 1 to 10 percent change. The iterations are
terminated when all latent and hyper-parameter mode changes fullfil
|change|/SD < rel_tol
, and the non-linear line search is inactive.
This seems to strike a useful balance between the different optimisation
criteria, allowing the iterations to converge faster and also detect that
convergence sooner.
The logic for which components are needed for a predictor expression
(in like()
or generate()
/predict()
) has been updated to when possible
extract the list of components from the expression itself.
The user can override this default if necessary, using the include
/exclude
arguments.
The bru_used()
methods are used to guess the needed component names, applied
to the right-hand side of the formula
arguments. The allow_latent
argument
to like()
has been deprecated in favour of include_latent
(by default auto-detected for use of _latent
and _eval
).
The internal information storage is handled by the new bru_used()
methods, that can also be used directly by the user and supplied via the
used
argument to like()
/generate()
/predict()
.
Add fm_int()
integration methods, replacing the old ipmaker()
and ipoints()
methods.
Supports both sf
and sp
sampler objects.
Add fm_pixels()
methods for gridded points. The old
pixels()
method now calls fm_pixels(..., format = "sp")
eval_spatial
support for sf objects (for point-in-polygon data lookups)
Allow precomputed spatial covariates in the data for point process observations
Add edge|int|ext.linewidth
arguments to gg.inla.mesh
#188
Rename the predict()
and generate()
data
arguments to newdata
, for
better compatibility with other predict()
methods. The old argument name
will still be accepted, but give a warning. Code that does not name the data
argument is not affected.
Note: Coordinate names for Spatial*
objects have been inconsistently
available in the predictor expression evaluation. However, due to how internal
conversions might inadvertently change these names, they can not be relied
on, and they are no longer being made available to the predictor expression.
As a side effect, this change also speeds up some bru()
runs by around a
factor 2, since it avoids converting the Spatial*
to a regular data.frame
in time-sensitive core evaluation code.
If you need access to the raw coordinate values, use explicit calls to
sp::coordinates(.data.)
(e.g. for custom spatial covariate evaluation.).
When possible, use the built-in covariate evaluation method, eval_spatial()
,
either implicitly with comp(covariate, ...)
or explicitly,
comp(eval_spatial(covariate, where = .data.), ...)
, that handles crs
information
correctly. Also consider transitioning from sp
to sf
data storage, using
geometry
instead of raw coordinates.
rgdal
and maptools
dependencies #178bru_safe_sp()
to check if sp
can be used safely (checks rgdal
availability
and sp
evolution status, optionally forcing use of sf
) #178rgl.*
functions to *3d
. Thanks to Duncan Murdoch #181ibm_jacobian.bru_mapper_harmonics
for large modelssf::st_*
calls that don't account for the geos
canonical representation being CW,
whereas the canonical Simple Features representation being CCW. See
https://github.com/r-spatial/sf/issues/2096sf
and terra
inputs to most methodsbru_mapper()
systembru_convergence_plot()
Allow NA
input for default 1D mappers to generate effect zero, like
in inla()
.
New and expanded methods fm_crs()
, fm_CRS()
, fm_transform()
,
fm_ellipsoid_radius()
, and fm_length_unit()
to further support sf
objects.
The fm_crs()
extraction method also supports terra
objects.
bru_fill_missing()
now supports terra
SpatRaster
data and and sf
locations.
New experimental methods fm_evaluator()
and fm_evaluate()
, replacing the
INLA
inla.mesh.projector
and inla.mesh.project
methods.
Experimental integration support for sphere and globe meshes.
Allow sf
input to family="cp"
models.
Further bru_mapper()
method updates;
ibm_amatrix()
and names()
methods, replaced by ibm_jacobian()
and ibm_names()
.bru_mapper_pipe()
, used to link mappers in sequence.bru_mapper_aggregate()
and bru_mapper_logsumexp()
,
used for blockwise weighted sums and log-sum-exp mappings,
output[k] = sum(weights[block==k]*state[block==k])))
and
output[k] = log(sum(weights[block==k]*exp(state[block==k])))
,
with optional weight normalisation within each block. Allows
providing the weights as log-weights, and uses block-wise shifts to
avoid potential overflow.summary
methods for bru_mapper
objects (summary.bru_mapper()
)methods
argument from bru_mapper_define()
. Implementations
should register S3 methods instead.spatstat.core
dependency. Fixes #165ibm_eval.default()
and ibm_eval.bru_mapper_collect()
methods, where they would return zeros
instead of the intended values.
The main component evaluation and estimation code was not directly affected
as that is based on the bru_mapper_multi()
class methods that rely on the
Jacobians instead. The bug would therefore mainly have impacted the future,
not yet supported nonlinear mapper extensions.eval_spatial.SpatRaster
; Work around inconsistent logic in
terra::extract(..., layer)
when length(layer)==1
or nrow(where)==1
.
Fixes #169indexed
logical option to bru_mapper_factor()
, to allow
factor inputs to be mapped to index values, as needed for group
and
replicate
. Fixes #174Add bru_get_mapper
generic, and associated methods for inla.spde
and
inla.rgeneric
objects. This allows inlabru
to automatically extract
the appropriate bru_mapper
object for each model component, and can be used
as a hook by external packages implementing new INLA object classes.
Add a weights
argument for like()
, for likelihood-specific log-likelihood
weights, passed on to the INLA::inla()
weights argument. Evaluated in the
data context.
The <component>_eval()
methods available in predictor expressions
now handle optional scaling weights, like in ordinary component effect
evaluation.
Add terra
support for covariate inputs
The component *_layer
arguments are now evaluated in the data context,
to allow dynamic layer selection for spatial raster covariates. A new
generic eval_spatial()
provides support for grid/pixel based
Spatial*DataFrame
evaluation, and SpatRaster
. Expanded support
is in progress.
New vignettes on the bru_mapper
system, component
definitions,
and prediction_scores
General overhaul of the bru_mapper
and linearised predictor system,
to prepare for new features.
ibm_eval
generic for evaluating mappers for given states.bru_mapper_taylor
, used as an internal mapper for linearised
mappers. This and ibm_eval
is aimed at future support for nonlinear
mappers. Associated new generic methods: ibm_{is_linear,jacobian,linear}
.ibm_jacobian
instead of ibm_amatrix
.
This allows defining a linearised mapper via
ibm_eval(input, state0) + ibm_jacobian(input, state0) %*% (state - state0)
.bru_mapper_const
, which replaces bru_mapper_offset
.
bru_mapper_offset
is now deprecated and will produce warnings.epsg:4326
. Fixes #154Tsparse
assumptions in row_kron
to prepare for Matrix 1.5-2
.
Fixes #162bru_mapper_harmonics
mapper for cos
and sin
basis sets.predict()
input data to be be a list.predict()
cv
, var
, smin
, smax
summaries from predict()
mean.mc_std_err
and sd.mc_std_err
output to predict()
robins_subset
data set and associated variable coefficient web vignettebru_mapper_collect
models.inla.mode="classic"
to use proper line search.unique
method. Fixes #145strategy="gaussian"
during iterations.bru()
timing information in $bru_timings
and $bru_iinla$timings
SpatialPolygonsDataFrame
support to gg()
methodsE
and Ntrials
from response_data
and data
(further special arguments remain to be added)deltaIC
improvementsbru_{forward/inverse}_transformation()
~ name(~ -1 + a + b + a:b, model = "fixed")
, covariate fixed effect interaction
specifications can be made. For formula input, MatrixModels::model.Matrix()
is called to construct matrix input that is then used as the A-matrix for
fixed effects, one per column, added up to form the combined effect.evaluate_model()
for cases where the inla_f
argument mattersdata
argument
is now allowed to be a list()
, and the new argument response_data
allows separate
specification of component inputs and response variables.bru_mapper_collect
class for handling sequential collections of
mappers, including collections where all but the first mapper is hidden from the
INLA::f()
arguments n
and values
, as needed to support e.g. "bym2" models.control.family
as a direct argument to like()
. Gives a warning if a
control.family
argument is supplied to the the options
argument of bru()
,
but at least one likelihood has control.family
information. (Issue #109)SpatialPointsDataFrame
and SpatialGridDataFrame
input
to bru_fill_missing()
model = "offset"
components instead of special options, to
avoid interfering with the linearisation system (Issue #123)bru_method$stop_at_max_rel_deviation
to bru_method$rel_tol
.
Automatic conversion to the new name, but a warning is given.bru_method$max_step
to control the largest allowed line search
scaling factor. See ?bru_options
bru_compress_cp
set to TRUE
to compress the predictor
expression for family="cp"
to use a single element for the linear predictor sum.map
has been deprecated. Use main
to specify
the main component input, ~ elev(main = elevation, model = "rw2")
.
Unlike the old map
argument, main
is the first one, so the shorter version
~ elev(elevation, model = "rw2")
also works.~ Intercept(1)
to avoid accidental confusion with other variables.bru()
has been simplified, so that all arguments except
components
and options
must either be outputs from calls to like()
, or
arguments that can be sent to a single like()
call.?bru_options()
for details.samplers
and domain
system for lgcp
models is now stricter, and
requires explicit domain
definitions for all the point process dimensions.
Alternatively, user-defined integration schemes can be supplied via the ips
argument.main
, group
, replicate
, and weights
can now take general R expressions using the data inputs. Special cases are detected:
SpatialPixels/GridDataFrame
objects are evaluated at spatial locations if
the input data is a SpatialPointsDataFrame
object. Functions are evaluated
on the data object, e.g. field(coordinates, model = spde)
mapper
, group_mapper
, and replicate_mapper
can be
used for precise control of the mapping between inputs and latent variables.
See ?bru_mapper
for more details. Mapper information is automatically extracted
from INLA::inla.spde2.pcmatern()
model objects.weights
and copy
features are now supported..data.
allow_combine = TRUE
argument must be supplied to like()
include
and exclude
arguments to like()
, generate()
, and predict()
can be used to specify which components are used for a given likelihood model
or predictor expression. This can be used to prevent evaluation of components
that are invalid for a likelihood or predictor._latent
to the component name, e.g. name_latent
.
For like()
, this requires
allow_latent = TRUE
to activate the needed linearisation code for this._eval
to access special evaluator functions, e.g.
name_eval(1:10)
. This is useful for evaluating the 1D effect of spatial covariates.
See the NEWS item for version 2.2.8 for further details.Add _eval
suffix feature for generate.bru
and predict.bru
, that
provides a general evaluator function for each component, allowing evaluation
of e.g. nonlinear effects of spatial covariates as a function of the covariate
value instead of the by the spatial evaluator used in the component definition.
For example, with components = ~ covar(spatial_grid_df, model = "rw1")
, the
prediction expression can have ~ covar_eval(covariate)
, where covariate
is a data column in the prediction data object.
For components with group
and replicate
features, these also need to be
provided to the _eval
function, with
..._eval(..., group = ..., replicate = ...)
This feature is built on top of the _latent
suffix feature, that gives
direct access to the latent state variables of a component, so in order to
use _eval
in the model predictor itself, you must use
like(..., allow_latent = TRUE)
in the model definition.
ngroup
and nrep
in component definitionsmexdolphin
and mrsea
data sets, with consistent km units and
improved mesh designspredict(..., include)
discussion to distance sampling vignette, for
handling non-spatial prediction in spatial models.gg.SpatialLines
Spatial*
object handling and plottingpredict()
logic for converting output to Spatial*DataFrame
control.mode=list(restart=FALSE)
in the final inla run for nonlinear
models, to avoid an unnecessary optimisation.pixels()
and bru_fill_missing()
for Spatial*DataFrame
objects with ncol=0
data frame parts.comp2(input, copy = "comp1")
comp(input, weights, ...)
.data.
, allowing e.g. covar(fun(.data.), ...)
for a complex
covariate extractor method fun()
bru_mapper
objects"factor_contrast"
model, or all levels with model "factor_full"
.
Further options planned (e.g. a simpler options to fix the precision
parameter). The estimated coefficients appear as random effects in the
inla()
output.map=
to main=
or unnamed first argument;
Since main
is the first parameter, it doesn't need to be a named argument.int.args
option to control spatial integration resolution,
thanks to Martin Jullum (martinju
)VignetteBuilder
entry from DESCRIPTION
int.polygon
from integrating outside the mesh domain,
and generally more robust integration scheme construction.bru()
to like()
parameter logic. (Thanks to Peter Vesk for bug example)NEWS.md
file to track changes to the package.inla
methods for predict()
and generate()
that convert
inla
output into bru
objects before calling the bru
prediction
and posterior sample generator.sample.lgcp
output formatting, extended CRS support, and more efficient sampling algorithmiinla()
tracks convergence of both fixed and random effectsgg.matrix()