| Title: | Fit Models Derived from Point Processes to Species Distributions using 'inlabru' |
|---|---|
| Description: | Integrated species distribution modeling is a rising field in quantitative ecology thanks to significant rises in the quantity of data available, increases in computational speed and the proven benefits of using such models. Despite this, the general software to help ecologists construct such models in an easy-to-use framework is lacking. We therefore introduce the R package 'PointedSDMs': which provides the tools to help ecologists set up integrated models and perform inference on them. There are also functions within the package to help run spatial cross-validation for model selection, as well as generic plotting and predicting functions. An introduction to these methods is discussed in Issac, Jarzyna, Keil, Dambly, Boersch-Supan, Browning, Freeman, Golding, Guillera-Arroita, Henrys, Jarvis, Lahoz-Monfort, Pagel, Pescott, Schmucki, Simmonds and O’Hara (2020) <doi:10.1016/j.tree.2019.08.006>. |
| Authors: | Philip Mostert [aut, cre], Bob O'hara [aut] |
| Maintainer: | Philip Mostert <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 2.1.4 |
| Built: | 2026-05-17 09:47:36 UTC |
| Source: | https://github.com/philipmostert/pointedsdms |
Dataset of setophaga caerulescens obtained from the Pennsylvania Atlas of Breeding Birds.
https://ebird.org/atlaspa/home
Dataset of setophaga caerulescens obtained from the North American Breeding Bird survey across Pennsylvania state.
https://www.pwrc.usgs.gov/bbs/
Dataset of Colinus Virginianus obtained from the North American Breeding Bird survey across Alabama state.
https://www.pwrc.usgs.gov/bbs/
This function is used to perform spatial blocked cross-validation with regards to model selection for the integrated model. It does so by leaving out a block of data in the full model, running a model with the remaining data, and then calculating the deviance information criteria (DIC) as a score of model fit.
blockedCV( data, options = list(), method = "DIC", predictName = NULL, datasetCombs = NULL )blockedCV( data, options = list(), method = "DIC", predictName = NULL, datasetCombs = NULL )
data |
An object produced by either |
options |
A list of INLA or inlabru options to be used in the model. Defaults to |
method |
Which cross-validation method to perform. Must be one of |
predictName |
Name of the dataset to predict onto if |
datasetCombs |
A list of vectors containing dataset combinations to include in each model run if |
An object of class blockedCV, which is essentially a list of DIC values obtained from each iteration of the model.
## Not run: if(requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, responsePA = 'Present', Projection = proj) #Set up spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1) #Run spatial block cross-validation blocked <- blockedCV(organizedData) #Print summary blocked } ## End(Not run)## Not run: if(requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, responsePA = 'Present', Projection = proj) #Set up spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1) #Run spatial block cross-validation blocked <- blockedCV(organizedData) #Print summary blocked } ## End(Not run)
An internal function used to change the coordinate names for datasets.
changeCoords(data, oldcoords, newcoords)changeCoords(data, oldcoords, newcoords)
data |
A list of datasets. |
oldcoords |
The old coordinate names. |
newcoords |
The new coordinate names. |
A list of data.frame or spatial objects with the coordinate names changed.
An internal function used to check if all the coordinates are the same.
checkCoords(data, coords)checkCoords(data, coords)
data |
A list of datasets. |
coords |
A vector of length 2 of the coordinate names. |
A logical variable.
Internal function used to check if variable is in dataset.
checkVar(data, var)checkVar(data, var)
data |
A list of datasets. |
var |
A variable name. |
A logical variable
Internal function: used to assign objects specified in bruSDM to the dataSDM/blockedCV function environments.
data2ENV(data, env)data2ENV(data, env)
data |
bruSDM data file to be used in the integrated model. |
env |
Environment where the objects should be assigned. |
Assignment of the relevant spatial fields to the specified environment.
Internal functions used to temporarily store data and other information before adding to dataSDM.
makeData()
dataOrganize$makeData( datapoints, datanames, coords, proj, marktrialname, paresp, countsresp, trialname, speciesname, marks, pointcovnames, markfamily, temporalvar, offsetname )
makeSpecies()
dataOrganize$makeSpecies(speciesname, repl = FALSE)
makeMultinom()
dataOrganize$makeMultinom(multinomVars, return, oldVars, repl = FALSE)
makeFormulas()
dataOrganize$makeFormulas( spatcovs, spatcovclass, speciesname, paresp, countresp, marks, marksspatial, speciesintercept, speciesenvironment, spatial, intercept, temporalname, speciesindependent, markintercept, pointcovs, speciesspatial, biasformula, covariateformula )
makeComponents()
dataOrganize$makeComponents( spatial, intercepts, datanames, marks, speciesname, multinomnames, pointcovariates, covariatenames, covariateclass, marksspatial, marksintercept, temporalname, speciesspatial, speciesenvironment, speciesintercept, numtime, temporalmodel, offsetname, copymodel, speciesindependent, biasformula, covariateformula, marksCopy )
makeLhoods()
dataOrganize$makeLhoods( mesh, ips, paresp, ntrialsvar, markstrialsvar, speciesname )
clone()
The objects of this class are cloneable with this method.
dataOrganize$clone(deep = FALSE)
deepWhether to make a deep clone.
Internal function used to assist in structuring the data.
dataSet( datapoints, datanames, coords = c("CoordLoc1", "CoordLoc2"), proj, pointcovnames, paresp, countsresp, trialname, speciesname, marks, marktrialname, markfamily, temporalvar, offsetname )dataSet( datapoints, datanames, coords = c("CoordLoc1", "CoordLoc2"), proj, pointcovnames, paresp, countsresp, trialname, speciesname, marks, marktrialname, markfamily, temporalvar, offsetname )
datapoints |
A list of datasets as sf objects |
datanames |
A vector of the names of the datasets. |
coords |
Names of the coordinates used in the model. |
proj |
The projection reference system used in the model. |
pointcovnames |
Name of the point covariates used in the model. |
paresp |
Name of the response variable used by the presence absence datasets. |
countsresp |
Name of the response variable used by the counts data. |
trialname |
Name of the trial variable used by the presence absence datasets. |
speciesname |
Name of the species name variable. |
marks |
Name of the marks considered in the model. |
marktrialname |
Name of the trial variable used by the binomial marks. |
markfamily |
A vector describing the distribution of the marks. |
temporalvar |
Name of the temporal variable. |
offsetname |
Name of the offset column in the datasets. |
A list of relevant metadata
This function calculates the difference in covariate values between a full integrated model and a model with one dataset left out, as well as some cross-validation score, which is used to obtain a score of the relative importance of the dataset in the full model. The score is calculated as follows:
Running a new model with one less dataset (from the main model) – resulting in a reduced model,
predicting the intensity function at the locations of the left-out dataset with the reduced model,
using the predicted values as an offset in a new model,
finding the difference between the marginal-likelihood of the main model (ie the model with all the datasets considered) and the marginal-likelihood of the offset model.
datasetOut(model, dataset, predictions = TRUE)datasetOut(model, dataset, predictions = TRUE)
model |
Model of class modISDM run with multiple datasets. |
dataset |
Names of the datasets to leave out. If missing, will run for all datasets used in the full model. |
predictions |
Will new models be used for predictions. If |
A list of inlabru models with the specified dataset left out. If predictions is FALSE, these objects will be missing their bru_info and call lists.
## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Choose dataset to leave out eBirdOut <- datasetOut(modelRun, dataset = 'eBird') #Print datasetOut summary eBirdOut } ## End(Not run)## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Choose dataset to leave out eBirdOut <- datasetOut(modelRun, dataset = 'eBird') #Print datasetOut summary eBirdOut } ## End(Not run)
data.frame object containing solitary tinamou observations from eBird
Raster object containing the elevation across Pennsylvania state.
https://cran.r-project.org/package=elevatr
This function takes a intModel object and produces an inlabru model object with additional lists and meta-data added.
fitISDM(data, options = list())fitISDM(data, options = list())
data |
A intModel object to be used in the integrated model. |
options |
A list of INLA options used in the model. Defaults to |
An inlabru model with additional lists containing some more metadata attached.
## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Print summary of model modelRun } ## End(Not run)## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Print summary of model modelRun } ## End(Not run)
data.frame object containing solitary tinamou observations from Gbif
This function is depreciated. Please use one of startISDM or startSpecies.
intModel( ..., spatialCovariates = NULL, Coordinates, Projection, Mesh, IPS = NULL, Boundary = NULL, speciesSpatial = "copy", speciesIndependent = FALSE, markNames = NULL, markFamily = NULL, pointCovariates = NULL, pointsIntercept = TRUE, marksIntercept = TRUE, speciesEffects = list(randomIntercept = FALSE, Environmental = TRUE), Offset = NULL, pointsSpatial = "copy", marksSpatial = TRUE, responseCounts = "counts", responsePA = "present", trialsPA = NULL, trialsMarks = NULL, speciesName = NULL, temporalName = NULL, temporalModel = list(model = "ar1"), copyModel = list(beta = list(fixed = FALSE)), Formulas = list(covariateFormula = NULL, biasFormula = NULL) )intModel( ..., spatialCovariates = NULL, Coordinates, Projection, Mesh, IPS = NULL, Boundary = NULL, speciesSpatial = "copy", speciesIndependent = FALSE, markNames = NULL, markFamily = NULL, pointCovariates = NULL, pointsIntercept = TRUE, marksIntercept = TRUE, speciesEffects = list(randomIntercept = FALSE, Environmental = TRUE), Offset = NULL, pointsSpatial = "copy", marksSpatial = TRUE, responseCounts = "counts", responsePA = "present", trialsPA = NULL, trialsMarks = NULL, speciesName = NULL, temporalName = NULL, temporalModel = list(model = "ar1"), copyModel = list(beta = list(fixed = FALSE)), Formulas = list(covariateFormula = NULL, biasFormula = NULL) )
... |
The datasets to be used in the model. May come as either |
spatialCovariates |
The spatial covariates used in the model. These covariates must be measured at every location (pixel) in the study area, and must be a |
Coordinates |
A vector of length 2 containing the names (class |
Projection |
The coordinate reference system used by both the spatial points and spatial covariates. Must be of class |
Mesh |
An |
IPS |
The integration points to be used in the model (that is, the points on the map where the intensity of the model is calculated). See |
Boundary |
A |
speciesSpatial |
Argument to specify if each species should have their own spatial effect with different hyperparameters to be estimated using INLA's "replicate" feature, of if a the field's should be estimated per species copied across datasets using INLA's "copy" feature. Possible values include: |
speciesIndependent |
Logical argument: Should species effects be made independent of one another. Defaults to |
markNames |
A vector with the mark names (class |
markFamily |
A vector with the statistical families (class |
pointCovariates |
The non-spatial covariates to be included in the integrated model (for example, in the field of ecology the distance to the nearest road or time spent sampling could be considered). These covariates must be included in the same data object as the points. |
pointsIntercept |
Logical argument: should the points be modeled with intercepts. Defaults to |
marksIntercept |
Logical argument: should the marks be modeled with intercepts. Defaults to |
speciesEffects |
List specifying if intercept terms and environments effects should be made for the species. Defaults to |
Offset |
Name of the offset variable (class |
pointsSpatial |
Argument to determine whether the spatial field is shared between the datasets, or if each dataset has its own unique spatial field. The datasets may share a spatial field with INLA's "copy" feature if the argument is set to |
marksSpatial |
Logical argument: should the marks have their own spatial field. Defaults to |
responseCounts |
Name of the response variable in the counts/abundance datasets. This variable name needs to be standardized across all counts datasets used in the integrated model. Defaults to |
responsePA |
Name of the response variable (class |
trialsPA |
Name of the trials response variable (class |
trialsMarks |
Name of the trials response variable (class |
speciesName |
Name of the species variable name (class |
temporalName |
Name of the temporal variable (class |
temporalModel |
List of model specifications given to the control.group argument in the time effect component. Defaults to |
copyModel |
List of model specifications given to the hyper parameters for the |
Formulas |
A named list with two objects. The first one, |
A specifyISDM object (class R6). Use ?specifyISDM to get a comprehensive description of the slot functions associated with this object.
The idea with this function is to describe the full model: that is, all the covariates and spatial effects will appear in all the formulas for the datasets and species.
If some of these terms should not be included in certain observation models in the integrated model, they can be thinned out using the .$updateFormula function.
Note: the point covariate and mark terms will only be included in the formulas for where they are present in a given dataset, and so these terms do not need to be thinned out if they are not required by certain observation models.
if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up #baseModel <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), # Projection = proj, responsePA = 'Present') #Print summary #baseModel }if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up #baseModel <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), # Projection = proj, responsePA = 'Present') #Print summary #baseModel }
Dataset of Eucalyptus globulus (common name: blue gum) sightings collected across the Koala conservation reserve on Phillip island (Australia) between 1993 and 2004. Two marks are considered from this dataset: "koala" which describes the number of koala visits to each tree, and "food" which is some index of the palatability of the leaves.
eucTrees is a data.frame object (1284 observations; 6 variables) with the following columns:
Latitude of the observation.
Longitude of the observation.
Some value of the palatability of the leaves of the trees.
The number of koala sightings per tree.
Total nitrogen (mg.g-1 DM).
Diameter at breast hight of the trees (cm).
Moore, B.D., Lawler, I.R., Wallis, I.R., Collin, B.M. and Foley, W.J. (2010). Palatability mapping: a koala’s eye view of spatial variation in habitat quality. Ecology 91 (11): 3165-3176.
An internal function used to make the formula components required for inlabru.
makeFormulaComps(form, species, speciesnames, type)makeFormulaComps(form, species, speciesnames, type)
form |
The formula which needs to be changed into a component. |
species |
Logical indicating if species occur in the model. |
speciesnames |
The names of the species occurring in the model. |
type |
What type of component is being created: one for the covariate formula or the bias formula. |
A vector of components required for inlabru.
Function to make the datasets into likelihoods.
makeLhoods( data, formula, family, mesh, ips, paresp, ntrialsvar, markstrialsvar, speciesname, speciesindex, samplers, pointcovs = NULL )makeLhoods( data, formula, family, mesh, ips, paresp, ntrialsvar, markstrialsvar, speciesname, speciesindex, samplers, pointcovs = NULL )
data |
A list of sf objects containing the datasets for which likelihoods need to be constructed. |
formula |
A list of formulas to add to the likelihoods. |
family |
A list of vectors containing the families within each dataset. |
mesh |
An |
ips |
Integration points used. |
paresp |
The response variable name for the presence absence datasets. |
ntrialsvar |
The trials variable name for the presence absence datasets. |
markstrialsvar |
The trial variable name for the binomial marks. |
speciesname |
The name of the species variable used. |
speciesindex |
A vector containing the numeric index of where the species occurs in the data |
samplers |
A list of integration domains for the datasets. |
pointcovs |
A vector of the point covariates used in the model. |
An internal function used to change the name of a variable.
nameChanger(data, oldName, newName)nameChanger(data, oldName, newName)
data |
A list of datasets. |
oldName |
The old variable name. |
newName |
The new variable name. |
A list of data.frame or spatial objects with the name of the variable changes.
Obtain the nearest covariate value at each of the species locations.
nearestValue(pts, r, ...)nearestValue(pts, r, ...)
pts |
The species location data |
r |
The raster file to extract the covariates at. |
... |
Extra arguments for knnx.index. |
Raster object containing the canopy cover across Pennsylvania state.
https://cran.r-project.org/package=FedData
data.frame object containing solitary tinamou observations from Parks
predict_bru_sdm.Plot for predict_bru_sdm
Plot for modISDM_predict
Plot for modMarks_predict
Plot for modSpecies_predict
## S3 method for class 'bruSDM_predict' plot( x, whattoplot = c("mean"), cols = NULL, layout = NULL, colourLow = NULL, colourHigh = NULL, plot = TRUE, ... ) ## S3 method for class 'modISDM_predict' plot(x, variable = "mean", plot = TRUE, ...) ## S3 method for class 'modMarks_predict' plot(x, variable = "mean", plot = TRUE, ...) ## S3 method for class 'modSpecies_predict' plot(x, variable = "mean", plot = TRUE, ...)## S3 method for class 'bruSDM_predict' plot( x, whattoplot = c("mean"), cols = NULL, layout = NULL, colourLow = NULL, colourHigh = NULL, plot = TRUE, ... ) ## S3 method for class 'modISDM_predict' plot(x, variable = "mean", plot = TRUE, ...) ## S3 method for class 'modMarks_predict' plot(x, variable = "mean", plot = TRUE, ...) ## S3 method for class 'modSpecies_predict' plot(x, variable = "mean", plot = TRUE, ...)
x |
A modSpecies_predict object. |
whattoplot |
One of the following statistics to plot: "mean", "sd", "q0.025", "median","q0.975", "smin", "smax", "cv", "var" |
cols |
Number of columns required for the plotting. Used by inlabru's multiplot function. |
layout |
Layout of the plots. Used by inlabru's multiplot function. |
colourLow |
Colour for the low values in the predictions (see ?scale_colour_gradient from |
colourHigh |
Colour for the high values in the predictions (see ?scale_colour_gradient from |
plot |
Should the plots be printed, defaults to |
... |
Argument not used |
variable |
One of the following statistics to plot: "mean", "sd", "q0.025", "median","q0.975", "smin", "smax", "cv", "var" |
A ggplot2 object.
A ggplot2 object.
A ggplot2 object.
A ggplot2 object.
## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions, colourHigh = 'red', colourLow = 'orange') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions, colourHigh = 'red', colourLow = 'orange') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb', diagonal = 1))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions) } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions, colourHigh = 'red', colourLow = 'orange') } ## End(Not run)## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions, colourHigh = 'red', colourLow = 'orange') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions, colourHigh = 'red', colourLow = 'orange') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb', diagonal = 1))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions) } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') #Make generic plot of predictions plot(predictions, colourHigh = 'red', colourLow = 'orange') } ## End(Not run)
bru_SDM objects.Predict function for the object produced by fitISDM. Should act identically to inlabru's generic predict function if wanted, but has additional arguments to help predict certain components created by the model. This is needed since intModel creates variable names which might not be directly apparent to the user.
Predict function for the object produced by fitISDM. Should act identically to inlabru's generic predict function if wanted, but has additional arguments to help predict certain components created by the model. This is needed since startISDM creates variable names which might not be directly apparent to the user.
Predict function for the object produced by fitISDM. Should act identically to inlabru's generic predict function if wanted, but has additional arguments to help predict certain components created by the model. This is needed since startMarks creates variable names which might not be directly apparent to the user.
Predict function for the object produced by fitISDM. Should act identically to inlabru's generic predict function if wanted, but has additional arguments to help predict certain components created by the model. This is needed since startSpecies creates variable names which might not be directly apparent to the user.
## S3 method for class 'bruSDM' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, temporal = FALSE, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, species = NULL, marks = NULL, biasfield = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", format = "sf", ... ) ## S3 method for class 'modISDM' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, bias = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", ... ) ## S3 method for class 'modMarks' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, marks = NULL, bias = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", ... ) ## S3 method for class 'modSpecies' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, species, bias = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", ... )## S3 method for class 'bruSDM' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, temporal = FALSE, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, species = NULL, marks = NULL, biasfield = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", format = "sf", ... ) ## S3 method for class 'modISDM' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, bias = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", ... ) ## S3 method for class 'modMarks' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, marks = NULL, bias = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", ... ) ## S3 method for class 'modSpecies' predict( object, data = NULL, formula = NULL, mesh = NULL, mask = NULL, covariates = NULL, spatial = FALSE, intercepts = FALSE, datasets = NULL, species, bias = FALSE, biasnames = NULL, predictor = FALSE, fun = "linear", ... )
object |
A |
data |
Data containing points of the map with which to predict on. May be |
formula |
Formula to predict. May be |
mesh |
An |
mask |
A mask of the study background. Defaults to |
temporal |
Make predictions for the temporal component of the model. |
covariates |
Name of covariates to predict. |
spatial |
Logical: include spatial effects in prediction. Defaults to |
intercepts |
Logical: include intercept terms in prediction. Defaults to |
datasets |
Names of the datasets to include intercept and spatial term. |
species |
Names of the species to predict. Default of |
marks |
Names of the marks to include intercept and spatial term. |
biasfield |
Logical include bias field in prediction. Defaults to |
biasnames |
Names of the datasets to include bias term. Defaults to |
predictor |
Should all terms (except the bias terms) included in the linear predictor be used in the predictions. Defaults to |
fun |
Function used to predict. Set to |
format |
Class of the data for which to predict on. Must be one of |
... |
Additional arguments used by the inlabru |
bias |
Logical include bias field in prediction. Defaults to |
Predict for bru_sdm
Predict for modISDM
Predict for modMarks
Predict for modSpecies
A list of inlabru predict objects.
A list of inlabru predict objects.
A list of inlabru predict objects.
A list of inlabru predict objects.
## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh data <- lapply(data, function(x) {x$mark = runif(nrow(x));x}) mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, markNames = 'mark', markFamily = 'gaussian', Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb', diagonal = 1))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, marks = 'mark', fun = 'linear') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb', diagonal = 1))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') } ## End(Not run)## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh data <- lapply(data, function(x) {x$mark = runif(nrow(x));x}) mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, markNames = 'mark', markFamily = 'gaussian', Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb', diagonal = 1))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, marks = 'mark', fun = 'linear') } ## End(Not run) ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') ##Run the model modelRun <- fitISDM(organizedData, options = list(control.inla = list(int.strategy = 'eb', diagonal = 1))) #Predict spatial field on linear scale predictions <- predict(modelRun, mesh = mesh, spatial = TRUE, fun = 'linear') } ## End(Not run)
blockedCV.Print for blockedCV
## S3 method for class 'blockedCV' print(x, ...)## S3 method for class 'blockedCV' print(x, ...)
x |
A blockedCV object. |
... |
Unused argument. |
blockedCV.Print for blockedCVpred
## S3 method for class 'blockedCVpred' print(x, ...)## S3 method for class 'blockedCVpred' print(x, ...)
x |
A blockedCV object. |
... |
Unused argument. |
bruSDM.Print method for bru_sdm
## S3 method for class 'bruSDM' print(x, ...)## S3 method for class 'bruSDM' print(x, ...)
x |
bruSDM object. |
... |
Un used argument. |
bru_sdm_predict.Generic print function for bru_sdm_predict.
## S3 method for class 'bruSDM_predict' print(x, ...)## S3 method for class 'bruSDM_predict' print(x, ...)
x |
bruSDM_predict object |
... |
Not used. |
datasetOut.Print for bru_sdm_leave_one_out
## S3 method for class 'datasetOut' print(x, ...)## S3 method for class 'datasetOut' print(x, ...)
x |
datasetOut object. |
... |
Unused argument. |
modISDM.Print method for modISDM
## S3 method for class 'modISDM' print(x, ...)## S3 method for class 'modISDM' print(x, ...)
x |
modISDM object. |
... |
Not used. |
modMarks.Print method for modMarks
## S3 method for class 'modMarks' print(x, ...)## S3 method for class 'modMarks' print(x, ...)
x |
modMarks object. |
... |
Not used. |
modSpecies.Print method for modSpecies
## S3 method for class 'modSpecies' print(x, ...)## S3 method for class 'modSpecies' print(x, ...)
x |
modSpecies object. |
... |
Not used. |
reduceComps: Reduce the components of the model.
reduceComps(componentsOld, pointsCopy, biasCopy, datasetName, reducedTerms)reduceComps(componentsOld, pointsCopy, biasCopy, datasetName, reducedTerms)
componentsOld |
The old components in the model. |
pointsCopy |
Logical: is the spatial model for the points copy. |
biasCopy |
Logical: is the bias model copy. |
datasetName |
Name of the dataset of interest. |
reducedTerms |
Terms to include in the new components. |
New components.
sf object containing the boundary region for solitary tinamouc
https://github.com/oharar/PointedSDMs
formulaChanger: Internal function used to remove formula terms.
removeFormula(formulaRemove, oldFormula)removeFormula(formulaRemove, oldFormula)
formulaRemove |
The formula with all the components to remove. |
oldFormula |
The formula which needs to change. |
This function takes a intModel object and produces an inlabru model object with additional lists and meta-data added.
runModel(data, options = list())runModel(data, options = list())
data |
A intModel object to be used in the integrated model. |
options |
A list of INLA options used in the model. Defaults to |
An inlabru model with additional lists containing some more metadata attached.
## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- runModel(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Print summary of model modelRun } ## End(Not run)## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- intModel(data, Mesh = mesh, Coordinates = c('X', 'Y'), Projection = proj, responsePA = 'Present') ##Run the model modelRun <- runModel(organizedData, options = list(control.inla = list(int.strategy = 'eb'))) #Print summary of model modelRun } ## End(Not run)
List of all data objects used for the Setophaga vignette.
List of all data objects used for the solitary tinamou vignette.
spatRaster object containing covariate values
https://github.com/oharar/PointedSDMs
startISDM object.A data object containing the data and the relevant information about the integrated model. The function startISDM acts as a wrapper in creating one of these objects. The output of this object has additional functions within the object which allow for further specification and customization of the integrated model.
help()
Function to provide documentation for a specifyISDM object.
specifyISDM$help(...)
...Not used
Documentation.
print()
Prints the datasets, their data type and the number of observations, as well as the marks and their respective families.
specifyISDM$print(...)
...Not used.
plot()
Makes a plot of the points surrounded by the boundary of the region where they were collected. The points may either be plotted based on which dataset they come from, or which species group they are part of (if speciesName is non-NULL in intModel).
specifyISDM$plot(datasetNames, Boundary = TRUE, ...)
datasetNamesName of the datasets to plot. If this argument is missing, the function will plot all the data available to the model.
BoundaryLogical: should a boundary (created using the Mesh object) be used in the plot. Defaults to TRUE.
...Not used.
A ggplot object.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
library(ggplot2)
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
Projection = proj,
responsePA = 'Present')
#Create plot of data
organizedData$plot()
}
}
addBias()
Function used to add additional spatial fields (called bias fields) to a selected dataset present in the integrated model. Bias fields are typically used to account for sampling biases in opportunistic citizen science data in the absence of any covariate to do such.
specifyISDM$addBias( datasetNames = NULL, allPO = FALSE, biasField = NULL, copyModel = TRUE, shareModel = FALSE, temporalModel = list(model = "ar1") )
datasetNamesA vector of dataset names (class character) for which a bias field needs to be added to. If NULL (default), then allPO has to be TRUE.
allPOLogical: should a bias field be added to all datasets classified as presence only in the integrated model. Defaults to FALSE.
biasFieldAn inla.spde object used to describe the bias field. Defaults to NULL which uses inla.spde2.matern to create a Matern model for the field.
copyModelCreate copy models for all the of the datasets specified with either datasetNames or allPO. The first dataset in the vector will have its own spatial effect, and the other datasets will "copy" the effect with shared hyperparameters. Defaults to TRUE.
shareModelShare a bias field across the datasets specified with datasetNames. Defaults to FALSE.
temporalModelList of model specifications given to the control.group argument in the time effect component. Defaults to list(model = 'ar1'); see control.group from the INLA package for more details. temporalName needs to be specified in intModel prior.
A bias field to the model.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
Projection = proj,
responsePA = 'Present')
#Add bias field to eBird records
organizedData$addBias(datasetNames = 'eBird')
}
}
updateFormula()
Function used to update the formula for a selected observation model. The function is designed to work similarly to the generic update formula, and should be used to thin terms out of a process from the full model specified in intModel. The function also allows the user to add their own formula to the model, such that they can include non-linear components in the model. The function can also be used to print out the formula for a process by not specifying the Formula or newFormula arguments.
specifyISDM$updateFormula( datasetName = NULL, Formula, newFormula, processLevel = FALSE )
datasetNameName of the dataset (class character) for which the formula needs to be changed.
FormulaAn updated formula to give to the process. The syntax provided for the formula in this argument should be identical to the formula specification as in base R. Should be used to thin terms out of a formula but could be used to add terms as well. If adding new terms not specified in intModel, remember to add the associated component using .$changeComponents as well.
newFormulaCompletely change the formula for a process – primarily used to add non-linear components into the formula. Note: all terms need to be correctly specified here.
processLevelLogical argument: if TRUE changes the formulas for all of the processes in a dataset. Defaults to FALSE.
An updated formula.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
spatialCovariates = Forest,
Projection = proj,
responsePA = 'Present',
pointsSpatial = 'individual')
#Remove Forest from eBird
organizedData$updateFormula(datasetName = 'eBird', Formula = ~ . - Forest)
#Add some scaling to Forest for Parks
organizedData$updateFormula('Parks', newFormula = ~ I(. +(Forest+1e-6)*scaling))
#Now dd scaling to components
organizedData$changeComponents(addComponent = 'scaling')
}
}
changeComponents()
Function to add and specify custom components to model, which are required by inlabru. The main purpose of the function is to re-specify or completely change components already in the model, however the user can also add completely new components to the model as well. In this case, the components need to be added to the correct formulas in the model using the .$updateFormula function. If addComponent and removeComponent are both missing, the function will print out the components to be supplied to inlabru's bru function.
specifyISDM$changeComponents(addComponent, removeComponent, print = TRUE)
addComponentComponent to add to the integrated model. Note that if the user is re-specifying a component already present in the model, they do not need to remove the old component using removeComponent.
removeComponentComponent (or just the name of a component) present in the model which should be removed.
printLogical: should the updated components be printed. Defaults to TRUE.
An updated components list.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present')
#Remove Forest from components
organizedData$changeComponents(removeComponent = 'Forest')
}
}
priorsFixed()
Function to change priors for the fixed (and possibly random) effects of the model.
specifyISDM$priorsFixed( Effect, datasetName = NULL, mean.linear = 0, prec.linear = 0.001 )
EffectName of the fixed effect covariate to change the prior for. Can take on 'intercept', which will change the specification for an intercept (specified by one of species or datasetName). If any factor covariates are provided or covariateFormula is set, setting prec.linear will fix the precision parameter of the effect to the specified precision.
datasetNameName of the dataset for which the prior of the intercept should change (if fixedEffect = 'intercept'). Defaults to NULL which will change the prior effect of the intercepts for all the datasets in the model.
mean.linearMean value for the prior of the fixed effect. Defaults to 0.
prec.linearPrecision value for the prior of the fixed effect. Defaults to 0.001.
New priors for the fixed effects.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present',
pointsSpatial = 'individual')
#Add prior to Forest
organizedData$priorsFixed(Effect = 'Forest', mean.linear = 2, prec.linear = 0.1)
}
}
specifySpatial()
Function to specify random fields in the model using penalizing complexity (PC) priors for the parameters.
specifyISDM$specifySpatial( sharedSpatial = FALSE, datasetName, Bias, PC = TRUE, Remove = FALSE, ... )
sharedSpatialLogical: specify the shared spatial field in the model. Requires pointsSpatial == 'shared' in intModel. Defaults to FALSE.
datasetNameName of which of the datasets' spatial fields to be specified. Requires pointsSpatial = 'individual' in intModel.
BiasLogical: specify the spatial field for the bias effect. If seperate fields are specified for different fields, the argument may be the name of the dataset for which the bias field to be specified.
PCLogical: should the Matern model be specified with pc priors. Defaults to TRUE, which uses inla.spde2.pcmatern to specify the model; otherwise uses inla.spde2.matern.
RemoveLogical: should the chosen spatial field be removed. Requires one of sharedSpatial, species, mark or bias to be non-missing, which chooses which field to remove.
...Additional arguments used by INLA's inla.spde2.pcmatern or inla.spde2.matern function, dependent on the value of PC.
A new model for the spatial effects.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present')
#Specify the shared spatial field
organizedData$specifySpatial(sharedSpatial = TRUE,
prior.range = c(1,0.001),
prior.sigma = c(1,0.001))
}
}
specifyFamily()
Function used to specify the family properties of a dataset.
specifyISDM$specifyFamily(datasetName, Family, Link)
datasetNameName of the dataset for which the link function needs to be changed.
FamilyThe statistical family.
LinkName of the link function to add to the process. If missing, will print the link function of the specified dataset.
A new link function of family for a process.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present')
#Specify the shared spatial field
organizedData$changeLink('Parks', 'logit')
}
}
spatialBlock()
Function to spatially block the datasets, which will then be used for model cross-validation with blockedCV. See the spatialBlock function from blockCV for how the spatial blocking works and for further details on the function's arguments.
specifyISDM$spatialBlock(k, rows_cols, plot = FALSE, seed = 1234, ...)
kInteger value reflecting the number of folds to use.
rows_colsInteger value by which the area is divided into longitudinal and latitudinal bins.
plotPlot the cross-validation folds as well as the points across the boundary. Defaults to FALSE.
seedSeed used by blockCV's spatialBlock to make the spatial blocking reproducible across different models. Defaults to 1234.
...Additional arguments used by blockCV's spatialBlock.
If plot = TRUE, a plot of the grid.
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present',
pointsSpatial = 'individual')
#Specify the spatial block
organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE)
}
addSamplers()
Function to add an integration domain for the PO datasets.
specifyISDM$addSamplers(datasetName, Samplers)
datasetNameName of the dataset for the samplers.
SamplersA Spatial* object representing the integration domain.
New samplers for a process.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
Projection = proj,
responsePA = 'Present')
#Add integration domain for the eBird records
organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region)
}
}
specifyRandom()
Function to specify the models and priors for the random effects included in the model.
specifyISDM$specifyRandom( temporalModel = list(model = "ar1"), copyModel = list(beta = list(fixed = FALSE)), copyBias = list(beta = list(fixed = FALSE)) )
temporalModelList of model specifications given to the control.group argument in the time effect component. Defaults to list(model = 'ar1'); see control.group from the INLA package for more details.
copyModelList of model specifications given to the hyper parameters for the "copy" model. Defaults to list(beta = list(fixed = FALSE)).
copyBiasList of model specifications given to the hyper parameters for the "copy" bias model. Defaults to list(beta = list(fixed = FALSE)).
An updated component list.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startISDM(data, Mesh = mesh,
Projection = proj,
responsePA = 'Present',
pointsSpatial = copy)
#Add integration domain for the eBird records
organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE)))
}
}
new()
specifyISDM$new( data, projection, Inlamesh, initialnames, responsecounts, responsepa, pointcovariates, trialspa, spatial, intercepts, spatialcovariates, boundary, ips, temporal, temporalmodel, offset, copymodel, formulas )
samplingBias()
specifyISDM$samplingBias(datasetName, Samplers)
## ------------------------------------------------ ## Method `specifyISDM$plot` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data library(ggplot2) data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Create plot of data organizedData$plot() } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$addBias` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Add bias field to eBird records organizedData$addBias(datasetNames = 'eBird') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$updateFormula` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Remove Forest from eBird organizedData$updateFormula(datasetName = 'eBird', Formula = ~ . - Forest) #Add some scaling to Forest for Parks organizedData$updateFormula('Parks', newFormula = ~ I(. +(Forest+1e-6)*scaling)) #Now dd scaling to components organizedData$changeComponents(addComponent = 'scaling') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$changeComponents` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Remove Forest from components organizedData$changeComponents(removeComponent = 'Forest') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$priorsFixed` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Add prior to Forest organizedData$priorsFixed(Effect = 'Forest', mean.linear = 2, prec.linear = 0.1) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$specifySpatial` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$specifySpatial(sharedSpatial = TRUE, prior.range = c(1,0.001), prior.sigma = c(1,0.001)) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$specifyFamily` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$changeLink('Parks', 'logit') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$spatialBlock` ## ------------------------------------------------ if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Specify the spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE) } ## ------------------------------------------------ ## Method `specifyISDM$addSamplers` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Add integration domain for the eBird records organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$specifyRandom` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present', pointsSpatial = copy) #Add integration domain for the eBird records organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE))) } ## End(Not run)## ------------------------------------------------ ## Method `specifyISDM$plot` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data library(ggplot2) data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Create plot of data organizedData$plot() } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$addBias` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Add bias field to eBird records organizedData$addBias(datasetNames = 'eBird') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$updateFormula` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Remove Forest from eBird organizedData$updateFormula(datasetName = 'eBird', Formula = ~ . - Forest) #Add some scaling to Forest for Parks organizedData$updateFormula('Parks', newFormula = ~ I(. +(Forest+1e-6)*scaling)) #Now dd scaling to components organizedData$changeComponents(addComponent = 'scaling') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$changeComponents` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Remove Forest from components organizedData$changeComponents(removeComponent = 'Forest') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$priorsFixed` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Add prior to Forest organizedData$priorsFixed(Effect = 'Forest', mean.linear = 2, prec.linear = 0.1) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$specifySpatial` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$specifySpatial(sharedSpatial = TRUE, prior.range = c(1,0.001), prior.sigma = c(1,0.001)) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$specifyFamily` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$changeLink('Parks', 'logit') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$spatialBlock` ## ------------------------------------------------ if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startISDM(data, Mesh = mesh, spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Specify the spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE) } ## ------------------------------------------------ ## Method `specifyISDM$addSamplers` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Add integration domain for the eBird records organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyISDM$specifyRandom` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present', pointsSpatial = copy) #Add integration domain for the eBird records organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE))) } ## End(Not run)
specifyMarks object.A data object containing the data and the relevant information about the integrated model. The function startMarks acts as a wrapper in creating one of these objects. The output of this object has additional functions within the object which allow for further specification and customization of the integrated model.
help()
Function to provide documentation for a specifyMarks object.
specifyMarks$help(...)
...Not used
Documentation.
print()
Prints the datasets, their data type and the number of observations, as well as the marks and their respective families.
specifyMarks$print(...)
...Not used.
plot()
Makes a plot of the points surrounded by the boundary of the region where they were collected. The points may either be plotted based on which dataset they come from, or which species group they are part of (if speciesName is non-NULL in intModel).
specifyMarks$plot(datasetNames, Boundary = TRUE, ...)
datasetNamesName of the datasets to plot. If this argument is missing, the function will plot all the data available to the model.
BoundaryLogical: should a boundary (created using the Mesh object) be used in the plot. Defaults to TRUE.
...Not used.
A ggplot object.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
library(ggplot2)
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set organizedData up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Create plot of data
organizedData$plot()
}
}
addBias()
Function used to add additional spatial fields (called bias fields) to a selected dataset present in the integrated model. Bias fields are typically used to account for sampling biases in opportunistic citizen science data in the absence of any covariate to do such.
specifyMarks$addBias( datasetNames = NULL, allPO = FALSE, biasField = NULL, copyModel = TRUE, shareModel = FALSE, temporalModel = list(model = "ar1") )
datasetNamesA vector of dataset names (class character) for which a bias field needs to be added to. If NULL (default), then allPO has to be TRUE.
allPOLogical: should a bias field be added to all datasets classified as presence only in the integrated model. Defaults to FALSE.
biasFieldAn inla.spde object used to describe the bias field. Defaults to NULL which uses inla.spde2.matern to create a Matern model for the field.
copyModelCreate copy models for all the of the datasets specified with either datasetNames or allPO. The first dataset in the vector will have its own spatial effect, and the other datasets will "copy" the effect with shared hyperparameters. Defaults to TRUE.
shareModelShare a bias field across the datasets specified with datasetNames. Defaults to FALSE.
temporalModelList of model specifications given to the control.group argument in the time effect component. Defaults to list(model = 'ar1'); see control.group from the INLA package for more details. temporalName needs to be specified in intModel prior.
A bias field to the model.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Add bias field to eBird records
organizedData$addBias(datasetNames = 'eBird')
}
}
updateFormula()
Function used to update the formula for a selected observation model. The function is designed to work similarly to the generic update formula, and should be used to thin terms out of a process from the full model specified in intModel. The function also allows the user to add their own formula to the model, such that they can include non-linear components in the model. The function can also be used to print out the formula for a process by not specifying the Formula or newFormula arguments.
specifyMarks$updateFormula( datasetName = NULL, Points = TRUE, Mark = NULL, Formula, newFormula )
datasetNameName of the dataset (class character) for which the formula needs to be changed.
PointsLogical: should the formula be changed for the points (or otherwise, a marked process). Defaults to TRUE.
MarkName of the mark (class character) to change the formula for. Defaults to NULL.
FormulaAn updated formula to give to the process. The syntax provided for the formula in this argument should be identical to the formula specification as in base R. Should be used to thin terms out of a formula but could be used to add terms as well. If adding new terms not specified in intModel, remember to add the associated component using .$changeComponents as well.
newFormulaCompletely change the formula for a process – primarily used to add non-linear components into the formula. Note: all terms need to be correctly specified here.
If Formula and newFormula are missing, will print out the formula for the specified processes.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- SolitaryTinamou$covariates$Forest
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Remove Forest from eBird
organizedData$updateFormula(datasetName = 'eBird', Mark = 'speciesName', Formula = ~ . - Forest)
}
}
changeComponents()
Function to add and specify custom components to model, which are required by inlabru. The main purpose of the function is to re-specify or completely change components already in the model, however the user can also add completely new components to the model as well. In this case, the components need to be added to the correct formulas in the model using the .$updateFormula function. If addComponent and removeComponent are both missing, the function will print out the components to be supplied to inlabru's bru function.
specifyMarks$changeComponents(addComponent, removeComponent, print = TRUE)
addComponentComponent to add to the integrated model. Note that if the user is re-specifying a component already present in the model, they do not need to remove the old component using removeComponent.
removeComponentComponent (or just the name of a component) present in the model which should be removed.
printLogical: should the updated components be printed. Defaults to TRUE.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- SolitaryTinamou$covariates$Forest
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Remove Forest from components
organizedData$changeComponents(removeComponent = 'Forest')
}
}
priorsFixed()
Function to change priors for the fixed (and possibly random) effects of the model.
specifyMarks$priorsFixed( Effect, datasetName = NULL, mean.linear = 0, prec.linear = 0.001 )
EffectName of the fixed effect covariate to change the prior for. Can take on 'intercept', which will change the specification for an intercept (specified by one of species or datasetName).
datasetNameName of the dataset for which the prior of the intercept should change (if fixedEffect = 'intercept'). Defaults to NULL which will change the prior effect of the intercepts for all the datasets in the model.
mean.linearMean value for the prior of the fixed effect. Defaults to 0.
prec.linearPrecision value for the prior of the fixed effect. Defaults to 0.001.
New priors for the fixed effects.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startMarks(data, Mesh = mesh, marksIntercept = FALSE,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Add prior to Forest
organizedData$priorsFixed(Effect = 'Intercept', mean.linear = 2, prec.linear = 0.1)
}
}
specifySpatial()
Function to specify random fields in the model using penalizing complexity (PC) priors for the parameters.
specifyMarks$specifySpatial( sharedSpatial = FALSE, datasetName, Mark, Bias, PC = TRUE, Remove = FALSE, ... )
sharedSpatialLogical: specify the shared spatial field in the model. Requires pointsSpatial == 'shared' in intModel. Defaults to FALSE.
datasetNameName of which of the datasets' spatial fields to be specified. Requires pointsSpatial = 'individual' in intModel.
MarkName of the marks to specify the spatial field for. If TRUE changes the spatial effect for all marks.
BiasLogical: specify the spatial field for the bias effect. If seperate fields are specified for different fields, the argument may be the name of the dataset for which the bias field to be specified.
PCLogical: should the Matern model be specified with pc priors. Defaults to TRUE, which uses inla.spde2.pcmatern to specify the model; otherwise uses inla.spde2.matern.
RemoveLogical: should the chosen spatial field be removed. Requires one of sharedSpatial, species, mark or bias to be non-missing, which chooses which field to remove.
...Additional arguments used by INLA's inla.spde2.pcmatern or inla.spde2.matern function, dependent on the value of PC.
A new model for the spatial effects.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Specify the shared spatial field
organizedData$specifySpatial(sharedSpatial = TRUE,
prior.range = c(1,0.001),
prior.sigma = c(1,0.001))
}
}
changeLink()
Function used to change the link function for a given process.
specifyMarks$changeLink(datasetName, Mark, Link, ...)
datasetNameName of the dataset for which the link function needs to be changed.
MarkName of the mark for which the link function needs to be changed.
LinkName of the link function to add to the process. If missing, will print the link function of the specified dataset.
...Not used
SpeciesName of the species for which the link function needs to be changed.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Specify the shared spatial field
organizedData$changeLink(datasetName = 'Parks',
Mark = 'speciesName',
Link = 'logit')
}
}
spatialBlock()
Function to spatially block the datasets, which will then be used for model cross-validation with blockedCV. See the spatialBlock function from blockCV for how the spatial blocking works and for further details on the function's arguments.
specifyMarks$spatialBlock(k, rows_cols, plot = FALSE, seed = 1234, ...)
kInteger value reflecting the number of folds to use.
rows_colsInteger value by which the area is divided into longitudinal and latitudinal bins.
plotPlot the cross-validation folds as well as the points across the boundary. Defaults to FALSE.
seedSeed used by blockCV's spatialBlock to make the spatial blocking reproducible across different models. Defaults to 1234.
...Additional arguments used by blockCV's spatialBlock.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- SolitaryTinamou$covariates$Forest
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Specify the spatial block
organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE)
}
}
addSamplers()
Function to add an integration domain for the PO datasets.
specifyMarks$addSamplers(datasetName, Samplers)
datasetNameName of the dataset for the samplers.
SamplersA Spatial* object representing the integration domain.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Add integration domain for the eBird records
organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region)
}
}
specifyRandom()
Function to specify the models and priors for the random effects included in the model.
specifyMarks$specifyRandom( temporalModel = list(model = "ar1"), copyModel = list(beta = list(fixed = FALSE)), copyBias = list(beta = list(fixed = FALSE)) )
temporalModelList of model specifications given to the control.group argument in the time effect component. Defaults to list(model = 'ar1'); see control.group from the INLA package for more details.
copyModelList of model specifications given to the hyper parameters for the "copy" model. Defaults to list(beta = list(fixed = FALSE)).
copyBiasList of model specifications given to the hyper parameters for the "copy" bias model. Defaults to list(beta = list(fixed = FALSE)).
An updated component list.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startMarks(data, Mesh = mesh,
Projection = proj, responsePA = 'Present',
markNames = 'speciesName',
markFamily = 'multinomial')
#Add integration domain for the eBird records
organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE)))
}
}
new()
specifyMarks$new( data, coordinates, projection, Inlamesh, initialnames, responsecounts, responsepa, marksnames, marksfamily, pointcovariates, trialspa, trialsmarks, marksspatial, spatial, intercepts, spatialcovariates, marksintercepts, boundary, ips, temporal, temporalmodel, offset, copymodel, formulas )
samplingBias()
specifyMarks$samplingBias(datasetName, Samplers)
## ------------------------------------------------ ## Method `specifyMarks$plot` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data library(ggplot2) data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set organizedData up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Create plot of data organizedData$plot() } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$addBias` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add bias field to eBird records organizedData$addBias(datasetNames = 'eBird') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$updateFormula` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- SolitaryTinamou$covariates$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Remove Forest from eBird organizedData$updateFormula(datasetName = 'eBird', Mark = 'speciesName', Formula = ~ . - Forest) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$changeComponents` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- SolitaryTinamou$covariates$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Remove Forest from components organizedData$changeComponents(removeComponent = 'Forest') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$priorsFixed` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, marksIntercept = FALSE, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add prior to Forest organizedData$priorsFixed(Effect = 'Intercept', mean.linear = 2, prec.linear = 0.1) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$specifySpatial` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Specify the shared spatial field organizedData$specifySpatial(sharedSpatial = TRUE, prior.range = c(1,0.001), prior.sigma = c(1,0.001)) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$changeLink` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Specify the shared spatial field organizedData$changeLink(datasetName = 'Parks', Mark = 'speciesName', Link = 'logit') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$spatialBlock` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- SolitaryTinamou$covariates$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Specify the spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$addSamplers` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add integration domain for the eBird records organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$specifyRandom` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add integration domain for the eBird records organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE))) } ## End(Not run)## ------------------------------------------------ ## Method `specifyMarks$plot` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data library(ggplot2) data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set organizedData up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Create plot of data organizedData$plot() } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$addBias` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add bias field to eBird records organizedData$addBias(datasetNames = 'eBird') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$updateFormula` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- SolitaryTinamou$covariates$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Remove Forest from eBird organizedData$updateFormula(datasetName = 'eBird', Mark = 'speciesName', Formula = ~ . - Forest) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$changeComponents` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- SolitaryTinamou$covariates$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Remove Forest from components organizedData$changeComponents(removeComponent = 'Forest') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$priorsFixed` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, marksIntercept = FALSE, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add prior to Forest organizedData$priorsFixed(Effect = 'Intercept', mean.linear = 2, prec.linear = 0.1) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$specifySpatial` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Specify the shared spatial field organizedData$specifySpatial(sharedSpatial = TRUE, prior.range = c(1,0.001), prior.sigma = c(1,0.001)) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$changeLink` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Specify the shared spatial field organizedData$changeLink(datasetName = 'Parks', Mark = 'speciesName', Link = 'logit') } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$spatialBlock` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- SolitaryTinamou$covariates$Forest #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Specify the spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$addSamplers` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add integration domain for the eBird records organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region) } ## End(Not run) ## ------------------------------------------------ ## Method `specifyMarks$specifyRandom` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') #Add integration domain for the eBird records organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE))) } ## End(Not run)
startSpecies object.A data object containing the data and the relevant information about the integrated model. The function startSpecies acts as a wrapper in creating one of these objects. The output of this object has additional functions within the object which allow for further specification and customization of the integrated model.
help()
Function to provide documentation for a specifySpecies object.
specifySpecies$help(...)
...Not used
Documentation.
print()
Prints the datasets, their data type and the number of observations, as well as the marks and their respective families.
specifySpecies$print(...)
...Not used.
plot()
Makes a plot of the points surrounded by the boundary of the region where they were collected.
specifySpecies$plot(datasetNames, Species = TRUE, Boundary = TRUE, ...)
datasetNamesName of the datasets to plot. If this argument is missing, the function will plot all the data available to the model.
SpeciesLogical: should the points be plotted based on the species name. Defaults to TRUE.
BoundaryLogical: should a boundary (created using the Mesh object) be used in the plot. Defaults to TRUE.
...Not used.
A ggplot object.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
library(ggplot2)
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
Projection = proj,
responsePA = 'Present')
#Create plot of data
organizedData$plot()
}
}
addBias()
Function used to add additional spatial fields (called bias fields) to a selected dataset present in the integrated model. Bias fields are typically used to account for sampling biases in opportunistic citizen science data in the absence of any covariate to do such.
specifySpecies$addBias( datasetNames = NULL, allPO = FALSE, biasField = NULL, copyModel = TRUE, shareModel = FALSE, temporalModel = list(model = "ar1") )
datasetNamesA vector of dataset names (class character) for which a bias field needs to be added to. If NULL (default), then allPO has to be TRUE.
allPOLogical: should a bias field be added to all datasets classified as presence only in the integrated model. Defaults to FALSE.
biasFieldAn inla.spde object used to describe the bias field. Defaults to NULL which uses inla.spde2.matern to create a Matern model for the field.
copyModelCreate copy models for all the of the datasets specified with either datasetNames or allPO. The first dataset in the vector will have its own spatial effect, and the other datasets will "copy" the effect with shared hyperparameters. Defaults to TRUE.
shareModelShare a bias field across the datasets specified with datasetNames. Defaults to FALSE.
temporalModelList of model specifications given to the control.group argument in the time effect component. Defaults to list(model = 'ar1'); see control.group from the INLA package for more details. temporalName needs to be specified in intModel prior.
A bias field to the model.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
Projection = proj,
responsePA = 'Present')
#Add bias field to eBird records
organizedData$addBias(datasetNames = 'eBird')
}
}
updateFormula()
Function used to update the formula for a selected observation model. The function is designed to work similarly to the generic update formula, and should be used to thin terms out of a process from the full model specified in intModel. The function also allows the user to add their own formula to the model, such that they can include non-linear components in the model. The function can also be used to print out the formula for a process by not specifying the Formula or newFormula arguments.
specifySpecies$updateFormula( datasetName = NULL, speciesName = NULL, Formula, processLevel = FALSE, newFormula )
datasetNameName of the dataset (class character) for which the formula needs to be changed.
speciesNameName of the species for which to change a formula for. Defaults to NULL which chnages the formula for all species present in datasetName.
FormulaAn updated formula to give to the process. The syntax provided for the formula in this argument should be identical to the formula specification as in base R. Should be used to thin terms out of a formula but could be used to add terms as well. If adding new terms not specified in intModel, remember to add the associated component using .$changeComponents as well.
processLevelLogical argument: if TRUE changes the formulas for all of the processes in a dataset. Defaults to FALSE.
newFormulaCompletely change the formula for a process – primarily used to add non-linear components into the formula. Note: all terms need to be correctly specified here.
An updated formula.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName',
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present',
pointsSpatial = 'individual')
#Remove Forest from eBird
organizedData$updateFormula(datasetName = 'eBird', Formula = ~ . - Forest)
#Add some scaling to Forest for Parks
organizedData$updateFormula(datasetName ='Parks', newFormula = ~ I(. +(Forest+1e-6)*scaling))
#Now dd scaling to components
organizedData$changeComponents(addComponent = 'scaling')
}
}
changeComponents()
Function to add and specify custom components to model, which are required by inlabru. The main purpose of the function is to re-specify or completely change components already in the model, however the user can also add completely new components to the model as well. In this case, the components need to be added to the correct formulas in the model using the .$updateFormula function. If addComponent and removeComponent are both missing, the function will print out the components to be supplied to inlabru's bru function.
specifySpecies$changeComponents(addComponent, removeComponent, print = TRUE)
addComponentComponent to add to the integrated model. Note that if the user is re-specifying a component already present in the model, they do not need to remove the old component using removeComponent.
removeComponentComponent (or just the name of a component) present in the model which should be removed.
printLogical: should the updated components be printed. Defaults to TRUE.
An updated components list.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
spatialCovariates = Forest,
Projection = proj,
responsePA = 'Present')
#Remove Forest from components
organizedData$changeComponents(removeComponent = 'speciesSpatial')
}
}
priorsFixed()
Function to change priors for the fixed (and possibly random) effects of the model.
specifySpecies$priorsFixed( Effect, Species = NULL, datasetName = NULL, mean.linear = 0, prec.linear = 0.001 )
EffectName of the fixed effect covariate to change the prior for. Can take on 'intercept', which will change the specification for an intercept (specified by one of species or datasetName). If any factor covariates are provided or covariateFormula is set, setting prec.linear will fix the precision parameter of the effect to the specified precision.
SpeciesName of the species (class character) for which the prior should change. Defaults to NULL which will change the prior for all species added to the model. Requires speciesEnvironment = FALSE.
datasetNameName of the dataset for which the prior of the intercept should change (if fixedEffect = 'intercept'). Defaults to NULL which will change the prior effect of the intercepts for all the datasets in the model.
mean.linearMean value for the prior of the fixed effect. Defaults to 0.
prec.linearPrecision value for the prior of the fixed effect. Defaults to 0.001.
New priors for the fixed effects.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present',
pointsSpatial = 'individual')
#Add prior to Forest
organizedData$priorsFixed(Effect = 'Forest', mean.linear = 2, prec.linear = 0.1)
}
}
specifySpatial()
Function to specify random fields in the model using penalizing complexity (PC) priors for the parameters.
specifySpecies$specifySpatial( sharedSpatial = FALSE, datasetName, Species, Bias, PC = TRUE, Remove = FALSE, ... )
sharedSpatialLogical: specify the shared spatial field in the model. Requires pointsSpatial == 'shared' in intModel. Defaults to FALSE.
datasetNameName of which of the datasets' spatial fields to be specified. Requires pointsSpatial = 'individual' in intModel.
SpeciesName of the species to change the spatial effect for. If TRUE then changes the spatial effect for the shared species field.
BiasLogical: specify the spatial field for the bias effect. If seperate fields are specified for different fields, the argument may be the name of the dataset for which the bias field to be specified.
PCLogical: should the Matern model be specified with pc priors. Defaults to TRUE, which uses inla.spde2.pcmatern to specify the model; otherwise uses inla.spde2.matern.
RemoveLogical: should the chosen spatial field be removed. Requires one of sharedSpatial, species, mark or bias to be non-missing, which chooses which field to remove.
...Additional arguments used by INLA's inla.spde2.pcmatern or inla.spde2.matern function, dependent on the value of PC.
A new model for the spatial effects.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present')
#Specify the shared spatial field
organizedData$specifySpatial(sharedSpatial = TRUE, PC = TRUE,
prior.range = c(1,0.001),
prior.sigma = c(1,0.001))
}
}
changeFamily()
Function used to specify the family properties of a dataset.
specifySpecies$changeFamily(datasetName, Family, Link)
datasetNameName of the dataset for which the link function needs to be changed.
FamilyThe statistical family.
LinkName of the link function to add to the process. If missing, will print the link function of the specified dataset.
A new link function for a process.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present')
#Specify the shared spatial field
organizedData$changeLink('Parks', 'logit')
}
}
spatialBlock()
Function to spatially block the datasets, which will then be used for model cross-validation with blockedCV. See the spatialBlock function from blockCV for how the spatial blocking works and for further details on the function's arguments.
specifySpecies$spatialBlock(k, rows_cols, plot = FALSE, seed = 1234, ...)
kInteger value reflecting the number of folds to use.
rows_colsInteger value by which the area is divided into longitudinal and latitudinal bins.
plotPlot the cross-validation folds as well as the points across the boundary. Defaults to FALSE.
seedSeed used by blockCV's spatialBlock to make the spatial blocking reproducible across different models. Defaults to 1234.
...Additional arguments used by blockCV's spatialBlock.
If plot = TRUE, a plot of the grid.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
Forest <- terra::rast(
system.file(
'extdata/SolitaryTinamouCovariates.tif',
package = "PointedSDMs"))$Forest
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
spatialCovariates = Forest,
Projection = proj, responsePA = 'Present',
pointsSpatial = 'individual')
#Specify the spatial block
organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE)
}
}
addSamplers()
Function to add an integration domain for the PO datasets.
specifySpecies$addSamplers(datasetName, Samplers)
datasetNameName of the dataset for the samplers.
SamplersA Spatial* object representing the integration domain.
New samplers for a process.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
Projection = proj, responsePA = 'Present')
#Add integration domain for the eBird records
organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region)
}
}
specifyRandom()
Function to specify the models and priors for the random effects included in the model.
specifySpecies$specifyRandom(
temporalModel = list(model = "ar1"),
copyModel = list(beta = list(fixed = FALSE)),
copyBias = list(beta = list(fixed = FALSE)),
speciesCopy = list(beta = list(fixed = FALSE)),
speciesIntercepts = list(prec = list(fixed = TRUE, initial =
log(INLA::inla.set.control.fixed.default()$prec))),
speciesGroup = list(model = "iid", hyper = list(prec = list(prior = "loggamma", param =
c(1, 5e-05))))
)temporalModelList of model specifications given to the control.group argument in the time effect component. Defaults to list(model = 'ar1'); see control.group from the INLA package for more details.
copyModelList of model specifications given to the hyper parameters for the "copy" model. Defaults to list(beta = list(fixed = FALSE)).
copyBiasList of model specifications given to the hyper parameters for the "copy" bias model. Defaults to list(beta = list(fixed = FALSE)).
speciesCopyList of model specifications given to the hyper parameters for the species "copy" model. Defaults to list(beta = list(fixed = FALSE)).
speciesInterceptsPrior distribution for precision parameter for the random species intercept term. Defaults to list(prec = list(fixed = TRUE, initial = log(INLA::inla.set.control.fixed.default()$prec))).
speciesGroupPrior distribution for the precision parameter for the iid group model. Defaults to INLA's default.
#' @return An updated component list.
\dontrun{
if (requireNamespace('INLA')) {
#Get Data
data("SolitaryTinamou")
proj <- "+proj=longlat +ellps=WGS84"
data <- SolitaryTinamou$datasets
mesh <- SolitaryTinamou$mesh
mesh$crs <- proj
#Set model up
organizedData <- startSpecies(data, Mesh = mesh,
speciesName = 'speciesName',
Projection = proj,
responsePA = 'Present',
pointsSpatial = copy)
#Add integration domain for the eBird records
organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE)))
}
}
new()
specifySpecies$new( data, projection, Inlamesh, initialnames, responsecounts, responsepa, pointcovariates, speciesintercept, trialspa, spatial, intercepts, spatialcovariates, boundary, ips, temporal, temporalmodel, offset, copymodel, formulas, speciesindependent, speciesname, speciesenvironment, speciesspatial )
samplingBias()
specifySpecies$samplingBias(datasetName, Samplers)
## ------------------------------------------------ ## Method `specifySpecies$plot` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data library(ggplot2) data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') #Create plot of data organizedData$plot() } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$addBias` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') #Add bias field to eBird records organizedData$addBias(datasetNames = 'eBird') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$updateFormula` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Remove Forest from eBird organizedData$updateFormula(datasetName = 'eBird', Formula = ~ . - Forest) #Add some scaling to Forest for Parks organizedData$updateFormula(datasetName ='Parks', newFormula = ~ I(. +(Forest+1e-6)*scaling)) #Now dd scaling to components organizedData$changeComponents(addComponent = 'scaling') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$changeComponents` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Remove Forest from components organizedData$changeComponents(removeComponent = 'speciesSpatial') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$priorsFixed` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Add prior to Forest organizedData$priorsFixed(Effect = 'Forest', mean.linear = 2, prec.linear = 0.1) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$specifySpatial` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$specifySpatial(sharedSpatial = TRUE, PC = TRUE, prior.range = c(1,0.001), prior.sigma = c(1,0.001)) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$changeFamily` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$changeLink('Parks', 'logit') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$spatialBlock` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Specify the spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$addSamplers` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') #Add integration domain for the eBird records organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$specifyRandom` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present', pointsSpatial = copy) #Add integration domain for the eBird records organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE))) } ## End(Not run)## ------------------------------------------------ ## Method `specifySpecies$plot` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data library(ggplot2) data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') #Create plot of data organizedData$plot() } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$addBias` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') #Add bias field to eBird records organizedData$addBias(datasetNames = 'eBird') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$updateFormula` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Remove Forest from eBird organizedData$updateFormula(datasetName = 'eBird', Formula = ~ . - Forest) #Add some scaling to Forest for Parks organizedData$updateFormula(datasetName ='Parks', newFormula = ~ I(. +(Forest+1e-6)*scaling)) #Now dd scaling to components organizedData$changeComponents(addComponent = 'scaling') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$changeComponents` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Remove Forest from components organizedData$changeComponents(removeComponent = 'speciesSpatial') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$priorsFixed` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Add prior to Forest organizedData$priorsFixed(Effect = 'Forest', mean.linear = 2, prec.linear = 0.1) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$specifySpatial` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$specifySpatial(sharedSpatial = TRUE, PC = TRUE, prior.range = c(1,0.001), prior.sigma = c(1,0.001)) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$changeFamily` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present') #Specify the shared spatial field organizedData$changeLink('Parks', 'logit') } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$spatialBlock` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj Forest <- terra::rast( system.file( 'extdata/SolitaryTinamouCovariates.tif', package = "PointedSDMs"))$Forest #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', spatialCovariates = Forest, Projection = proj, responsePA = 'Present', pointsSpatial = 'individual') #Specify the spatial block organizedData$spatialBlock(k = 2, rows = 2, cols = 1, plot = FALSE) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$addSamplers` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present') #Add integration domain for the eBird records organizedData$addSamplers(datasetName = 'eBird', Samplers = SolitaryTinamou$region) } ## End(Not run) ## ------------------------------------------------ ## Method `specifySpecies$specifyRandom` ## ------------------------------------------------ ## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set model up organizedData <- startSpecies(data, Mesh = mesh, speciesName = 'speciesName', Projection = proj, responsePA = 'Present', pointsSpatial = copy) #Add integration domain for the eBird records organizedData$specifyRandom(copyModel = list(beta = list(fixed = TRUE))) } ## End(Not run)
This function is used to create an object containing all the data, metadata and relevant components required for the integrated species distribution model and INLA to work.
As a result, the arguments associated with this function are predominantly related to describing variable names within the datasets that are relevant, and arguments related to what terms should be included in the formula for the integrated model. The output of this function is an R6 object, and so there are a variety of public methods within the output of this function which can be used to further specify the model (see ?specifyISDM or .$help() for a comprehensive description of these public methods).
startISDM( ..., spatialCovariates = NULL, Projection, Mesh, IPS = NULL, Boundary = NULL, pointCovariates = NULL, Offset = NULL, pointsIntercept = TRUE, pointsSpatial = "copy", responseCounts = "counts", responsePA = "present", trialsPA = NULL, temporalName = NULL, Formulas = list(covariateFormula = NULL, biasFormula = NULL) )startISDM( ..., spatialCovariates = NULL, Projection, Mesh, IPS = NULL, Boundary = NULL, pointCovariates = NULL, Offset = NULL, pointsIntercept = TRUE, pointsSpatial = "copy", responseCounts = "counts", responsePA = "present", trialsPA = NULL, temporalName = NULL, Formulas = list(covariateFormula = NULL, biasFormula = NULL) )
... |
The datasets to be used in the model. Must come as either |
spatialCovariates |
The spatial covariates used in the model. These covariates must be measured at every location (pixel) in the study area, and must be a |
Projection |
The coordinate reference system used by both the spatial points and spatial covariates. Must be of class |
Mesh |
An |
IPS |
The integration points to be used in the model (that is, the points on the map where the intensity of the model is calculated). See |
Boundary |
A |
pointCovariates |
The non-spatial covariates to be included in the integrated model (for example, in the field of ecology the distance to the nearest road or time spent sampling could be considered). These covariates must be included in the same data object as the points, and do not necessarily need to be present in all datasets. |
Offset |
Name of the offset variable (class |
pointsIntercept |
Logical argument: should the points be modeled with intercepts. Defaults to |
pointsSpatial |
Argument to determine whether the spatial field is shared between the datasets, or if each dataset has its own unique spatial field. The datasets may share a spatial field with INLA's "copy" feature if the argument is set to |
responseCounts |
Name of the response variable in the counts/abundance datasets. This variable name needs to be standardized across all counts datasets used in the integrated model. Defaults to |
responsePA |
Name of the response variable (class |
trialsPA |
Name of the trials response variable (class |
temporalName |
Name of the temporal variable (class |
Formulas |
A named list with two objects. The first one, |
A specifyISDM object (class R6). Use ?specifyISDM to get a comprehensive description of the slot functions associated with this object.
The idea with this function is to describe the full model: that is, all the covariates and spatial effects will appear in all the formulas for the datasets and species.
If some of these terms should not be included in certain observation models in the integrated model, they can be thinned out using the .$updateFormula function.
Note: the point covariate will only be included in the formulas for where they are present in a given dataset, and so these terms do not need to be thinned out if they are not required by certain observation models.
## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up baseModel <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Print summary baseModel #Set up model with dataset specific spatial fields indSpat <- startISDM(data, Mesh = mesh, Projection = proj, pointsSpatial = 'individual', responsePA = 'Present') #Model with offset variable offSet <- startISDM(data, Mesh = mesh, Projection = proj, Offset = 'area', responsePA = 'Present') #Add own formula quadModel <- startISDM(data, Mesh = mesh, Projection = proj, pointsSpatial = 'copy', responsePA = 'Present', Formulas = list(covariateFormula = ~ NPP + I(NPP^2))) } ## End(Not run)## Not run: if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up baseModel <- startISDM(data, Mesh = mesh, Projection = proj, responsePA = 'Present') #Print summary baseModel #Set up model with dataset specific spatial fields indSpat <- startISDM(data, Mesh = mesh, Projection = proj, pointsSpatial = 'individual', responsePA = 'Present') #Model with offset variable offSet <- startISDM(data, Mesh = mesh, Projection = proj, Offset = 'area', responsePA = 'Present') #Add own formula quadModel <- startISDM(data, Mesh = mesh, Projection = proj, pointsSpatial = 'copy', responsePA = 'Present', Formulas = list(covariateFormula = ~ NPP + I(NPP^2))) } ## End(Not run)
This function is used to create an object containing all the data, metadata and relevant components required for the integrated species distribution model and INLA to work.
As a result, the arguments associated with this function are predominantly related to describing variable names within the datasets that are relevant, and arguments related to what terms should be included in the formula for the integrated model. The output of this function is an R6 object, and so there are a variety of public methods within the output of this function which can be used to further specify the model (see ?specifyMarks for a comprehensive description of these public methods).
startMarks( ..., spatialCovariates = NULL, Projection, Mesh, IPS = NULL, Boundary = NULL, markNames = NULL, markFamily = NULL, marksSpatial = TRUE, pointCovariates = NULL, pointsIntercept = TRUE, marksIntercept = TRUE, Offset = NULL, pointsSpatial = "copy", responseCounts = "counts", responsePA = "present", trialsPA = NULL, trialsMarks = NULL, temporalName = NULL, Formulas = list(covariateFormula = NULL, biasFormula = NULL) )startMarks( ..., spatialCovariates = NULL, Projection, Mesh, IPS = NULL, Boundary = NULL, markNames = NULL, markFamily = NULL, marksSpatial = TRUE, pointCovariates = NULL, pointsIntercept = TRUE, marksIntercept = TRUE, Offset = NULL, pointsSpatial = "copy", responseCounts = "counts", responsePA = "present", trialsPA = NULL, trialsMarks = NULL, temporalName = NULL, Formulas = list(covariateFormula = NULL, biasFormula = NULL) )
... |
The datasets to be used in the model. Must come as either |
spatialCovariates |
The spatial covariates used in the model. These covariates must be measured at every location (pixel) in the study area, and must be a |
Projection |
The coordinate reference system used by both the spatial points and spatial covariates. Must be of class |
Mesh |
An |
IPS |
The integration points to be used in the model (that is, the points on the map where the intensity of the model is calculated). See |
Boundary |
A |
markNames |
A vector with the mark names (class |
markFamily |
A vector with the statistical families (class |
marksSpatial |
Logical argument: should the marks have their own spatial field. Defaults to |
pointCovariates |
The non-spatial covariates to be included in the integrated model (for example, in the field of ecology the distance to the nearest road or time spent sampling could be considered). These covariates must be included in the same data object as the points. |
pointsIntercept |
Logical argument: should the points be modeled with intercepts. Defaults to |
marksIntercept |
Logical argument: should the marks be modeled with intercepts. Defaults to |
Offset |
Name of the offset variable (class |
pointsSpatial |
Argument to determine whether the spatial field is shared between the datasets, or if each dataset has its own unique spatial field. The datasets may share a spatial field with INLA's "copy" feature if the argument is set to |
responseCounts |
Name of the response variable in the counts/abundance datasets. This variable name needs to be standardized across all counts datasets used in the integrated model. Defaults to |
responsePA |
Name of the response variable (class |
trialsPA |
Name of the trials response variable (class |
trialsMarks |
Name of the trials response variable (class |
temporalName |
Name of the temporal variable (class |
Formulas |
A named list with two objects. The first one, |
A specifyMarks object (class R6). Use ?specifyMarks of .$help() to get a comprehensive description of the slot functions associated with this object.
The idea with this function is to describe the full model: that is, all the covariates and spatial effects will appear in all the formulas for the datasets and species.
If some of these terms should not be included in certain observation models in the integrated model, they can be thinned out using the .$updateFormula function.
Note: the point covariate and mark terms will only be included in the formulas for where they are present in a given dataset, and so these terms do not need to be thinned out if they are not required by certain observation models.
if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up baseModel <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') }if (requireNamespace('INLA')) { #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up baseModel <- startMarks(data, Mesh = mesh, Projection = proj, responsePA = 'Present', markNames = 'speciesName', markFamily = 'multinomial') }
This function is used to create an object containing all the data, metadata and relevant components required for the multi-species integrated species distribution model and INLA to work.
As a result, the arguments associated with this function are predominantly related to describing variable names within the datasets that are relevant, and arguments related to what terms should be included in the formula for the integrated model. The output of this function is an R6 object, and so there are a variety of public methods within the output of this function which can be used to further specify the model (see ?specifySpecies or .$help() for a comprehensive description of these public methods).
startSpecies( ..., spatialCovariates = NULL, Projection, Mesh, speciesSpatial = "replicate", speciesIntercept = TRUE, speciesEnvironment = "stack", speciesName, IPS = NULL, Boundary = NULL, pointCovariates = NULL, Offset = NULL, pointsIntercept = TRUE, pointsSpatial = "copy", responseCounts = "counts", responsePA = "present", trialsPA = NULL, temporalName = NULL, Formulas = list(covariateFormula = NULL, biasFormula = NULL) )startSpecies( ..., spatialCovariates = NULL, Projection, Mesh, speciesSpatial = "replicate", speciesIntercept = TRUE, speciesEnvironment = "stack", speciesName, IPS = NULL, Boundary = NULL, pointCovariates = NULL, Offset = NULL, pointsIntercept = TRUE, pointsSpatial = "copy", responseCounts = "counts", responsePA = "present", trialsPA = NULL, temporalName = NULL, Formulas = list(covariateFormula = NULL, biasFormula = NULL) )
... |
The datasets to be used in the model. Must come as either |
spatialCovariates |
The spatial covariates used in the model. These covariates must be measured at every location (pixel) in the study area, and must be a |
Projection |
The coordinate reference system used by both the spatial points and spatial covariates. Must be of class |
Mesh |
An |
speciesSpatial |
Argument to specify if each species should have their own spatial effect with different hyperparameters to be estimated using INLA's "replicate" feature, of if a the field's should be estimated per species copied across datasets using INLA's "copy" feature. Possible values include: |
speciesIntercept |
Argument to control the species intercept term. Defaults to |
speciesEnvironment |
Argument to control the species environmental term. Defaults to |
speciesName |
Name of the species variable name (class |
IPS |
The integration points to be used in the model (that is, the points on the map where the intensity of the model is calculated). See |
Boundary |
A |
pointCovariates |
The non-spatial covariates to be included in the integrated model (for example, in the field of ecology the distance to the nearest road or time spent sampling could be considered). These covariates must be included in the same data object as the points. |
Offset |
Name of the offset variable (class |
pointsIntercept |
Logical argument: should the points be modeled with intercepts. Defaults to |
pointsSpatial |
Argument to determine whether the spatial field is shared between the datasets, or if each dataset has its own unique spatial field. The datasets may share a spatial field with INLA's "copy" feature if the argument is set to |
responseCounts |
Name of the response variable in the counts/abundance datasets. This variable name needs to be standardized across all counts datasets used in the integrated model. Defaults to |
responsePA |
Name of the response variable (class |
trialsPA |
Name of the trials response variable (class |
temporalName |
Name of the temporal variable (class |
Formulas |
A named list with two objects. The first one, |
A specifySpecies object (class R6). Use ?specifySpecies to get a comprehensive description of the slot functions associated with this object.
The idea with this function is to describe the full model: that is, all the covariates and spatial effects will appear in all the formulas for the datasets and species.
If some of these terms should not be included in certain observation models in the integrated model, they can be thinned out using the .$updateFormula function.
Note: the point covariate will only be included in the formulas for where they are present in a given dataset, and so these terms do not need to be thinned out if they are not required by certain observation models.
## Not run: if (requireNamespace('INLA')) { ##REDO WITH OTHER DATA #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up baseModel <- startSpecies(data, Mesh = mesh, Projection = proj, responsePA = 'Present', speciesName = 'speciesName') #Print summary baseModel #Set up model with dataset specific spatial fields indSpat <- startSpecies(data, Mesh = mesh, Projection = proj, pointsSpatial = 'individual', responsePA = 'Present', speciesName = 'speciesName') #Model with offset variable offSet <- startSpecies(data, Mesh = mesh, Projection = proj, Offset = 'area', responsePA = 'Present', speciesName = 'speciesName') #Non-random effects for the species speciesInt <- startSpecies(data, Mesh = mesh, Projection = proj, speciesIntercept = FALSE, responsePA = 'Present', speciesName = 'speciesName') #Turn off species level field speciesInt <- startSpecies(data, Mesh = mesh, Projection = proj, speciesSpatial = NULL, responsePA = 'Present', speciesName = 'speciesName') } ## End(Not run)## Not run: if (requireNamespace('INLA')) { ##REDO WITH OTHER DATA #Get Data data("SolitaryTinamou") proj <- "+proj=longlat +ellps=WGS84" data <- SolitaryTinamou$datasets mesh <- SolitaryTinamou$mesh mesh$crs <- proj #Set base model up baseModel <- startSpecies(data, Mesh = mesh, Projection = proj, responsePA = 'Present', speciesName = 'speciesName') #Print summary baseModel #Set up model with dataset specific spatial fields indSpat <- startSpecies(data, Mesh = mesh, Projection = proj, pointsSpatial = 'individual', responsePA = 'Present', speciesName = 'speciesName') #Model with offset variable offSet <- startSpecies(data, Mesh = mesh, Projection = proj, Offset = 'area', responsePA = 'Present', speciesName = 'speciesName') #Non-random effects for the species speciesInt <- startSpecies(data, Mesh = mesh, Projection = proj, speciesIntercept = FALSE, responsePA = 'Present', speciesName = 'speciesName') #Turn off species level field speciesInt <- startSpecies(data, Mesh = mesh, Projection = proj, speciesSpatial = NULL, responsePA = 'Present', speciesName = 'speciesName') } ## End(Not run)
bruSDM.Summary for bru_sdm
Summary for modSpecies
Summary for modISDM
Summary for modMarks
## S3 method for class 'bruSDM' summary(object, ...) ## S3 method for class 'modSpecies' summary(object, ...) ## S3 method for class 'modISDM' summary(object, ...) ## S3 method for class 'modMarks' summary(object, ...)## S3 method for class 'bruSDM' summary(object, ...) ## S3 method for class 'modSpecies' summary(object, ...) ## S3 method for class 'modISDM' summary(object, ...) ## S3 method for class 'modMarks' summary(object, ...)
object |
modMarks object. |
... |
Not used argument |