## ------------------------------------------------
## Method `specifySpecies$plot`
## ------------------------------------------------
if (FALSE) {
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()
}
}
## ------------------------------------------------
## Method `specifySpecies$addBias`
## ------------------------------------------------
if (FALSE) {
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')
}
}
## ------------------------------------------------
## Method `specifySpecies$updateFormula`
## ------------------------------------------------
if (FALSE) {
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')
}
}
## ------------------------------------------------
## Method `specifySpecies$changeComponents`
## ------------------------------------------------
if (FALSE) {
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')
}
}
## ------------------------------------------------
## Method `specifySpecies$priorsFixed`
## ------------------------------------------------
if (FALSE) {
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)
}
}
## ------------------------------------------------
## Method `specifySpecies$specifySpatial`
## ------------------------------------------------
if (FALSE) {
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))
}
}
## ------------------------------------------------
## Method `specifySpecies$changeLink`
## ------------------------------------------------
if (FALSE) {
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')
}
}
## ------------------------------------------------
## Method `specifySpecies$spatialBlock`
## ------------------------------------------------
if (FALSE) {
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)
}
}
## ------------------------------------------------
## Method `specifySpecies$addSamplers`
## ------------------------------------------------
if (FALSE) {
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)
}
}
## ------------------------------------------------
## Method `specifySpecies$specifyRandom`
## ------------------------------------------------
if (FALSE) {
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)))
}
}
Run the code above in your browser using DataLab