A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

PointedSDMs

Simplify the construction of integrated species distribution models (ISDMs) for large collections of heterogeneous data.
https://github.com/philipmostert/pointedsdms

Category: Biosphere
Sub Category: Species Distribution Modeling

Last synced: about 14 hours ago
JSON representation

Repository metadata

Wrapper function for 'inlabru' for modeling species distribution models from disparate datasets.

README.Rmd

          ---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# PointedSDMs



[![R-CMD-check](https://github.com/PhilipMostert/PointedSDMs/actions/workflows/R-CMD-check.yaml/badge.svg?branch=main)](https://github.com/PhilipMostert/PointedSDMs/actions/workflows/R-CMD-check.yaml)[![Codecov test coverage](https://codecov.io/gh/PhilipMostert/PointedSDMs/branch/main/graph/badge.svg)](https://app.codecov.io/gh/PhilipMostert/PointedSDMs?branch=ChangingToR6) [![DOI](https://zenodo.org/badge/368823136.svg)](https://zenodo.org/badge/latestdoi/368823136)



The goal of *PointedSDMs* is to simplify the construction of integrated species distribution models (ISDMs) for large collections of heterogeneous data. It does so by building wrapper functions around [inlabru](https://besjournals.onlinelibrary.wiley.com/doi/abs/10.1111/2041-210X.13168), which uses the [INLA methodology](https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/j.1467-9868.2008.00700.x) to estimate a class of latent Gaussian models.

## Installation

You can install the development version of PointedSDMs from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("PhilipMostert/PointedSDMs")
```

or directly through CRAN using:

``` r
install.packages('PointedSDMs')
```

## Package functionality

*PointedSDMs* includes a selection of functions used to streamline the construction of ISDMs as well and perform model cross-validation. The core functions of the package are:

| Function name | Function description |
|-------------------|-----------------------------------------------------|
| `startISDM()` | Initialize and specify the components used in the integrated model. |
| `startSpecies()` | Initialize and specify the components used in the multi-species integrated model. |
| `blockedCV()` | Perform spatial blocked cross-validation. |
| `fitISDM()` | Estimate and preform inference on the integrated model. |
| `datasetOut()` | Perform dataset-out cross-validation, which calculates the impact individual datasets have on the full model. |

The function `intModel()` produces an [R6](https://github.com/r-lib/R6) object, and as a result there are various *slot functions* available to further specify the components of the model. These *slot functions* include:

| `intModel()` slot function | Function description |
|--------------------|----------------------------------------------------|
| `` `.$help()` `` | Show documentation for each of the slot functions. |
| `` `.$plot()` `` | Used to create a plot of the available data. The output of this function is an object of class [`gg`](https://github.com/tidyverse/ggplot2). |
| `` `.$addBias()` `` | Add an additional spatial field to a dataset to account for sampling bias in unstructured datasets. |
| `` `.$updateFormula()` `` | Used to update a formula for a process. The idea is to start specify the full model with `startISDM()`, and then thin components per dataset with this function. |
| `` `.$updateComponents()` `` | Change or add new components used by [inlabru](https://besjournals.onlinelibrary.wiley.com/doi/abs/10.1111/2041-210X.13168) in the integrated model. |
| `` `.$priorsFixed()` `` | Change the specification of the prior distribution for the fixed effects in the model. |
| `` `.$specifySpatial()` `` | Specify the spatial field in the model using penalizing complexity (PC) priors. |
| `` `.$spatialBlock()` `` | Used to specify how the points are spatially blocked. Spatial cross-validation is subsequently performed using `blockedCV()`. |
| `` `.$addSamplers()` `` | Function to add an integration domain for the PO datasets. |
| `` `.$specifyRandom()` `` | Specify the priors for the random effects in the model. |
| `` `.$changeLink()` `` | Change the link function of a process. |

## Example

This is a basic example which shows you how to specify and run an integrated model, using three disparate datasets containing locations of the solitary tinamou (*Tinamus solitarius)*.

```{r setup, include=FALSE}
knitr::opts_chunk$set(warning = FALSE, message = FALSE) 
```

```{r example}

library(PointedSDMs)
library(ggplot2)
library(terra)

```

```{r data}

bru_options_set(inla.mode = "experimental")

#Load data in

data("SolitaryTinamou")

projection <- "+proj=longlat +ellps=WGS84"

species <- SolitaryTinamou$datasets

covariates <- terra::rast(system.file('extdata/SolitaryTinamouCovariates.tif', 
                                      package = "PointedSDMs"))

mesh <- SolitaryTinamou$mesh


```

Setting up the model is done easily with `startISDM()`, where we specify the required components of the model:

```{r intModel, message = FALSE, warning = FALSE}

#Specify model -- here we run a model with one spatial covariate and a shared spatial field

model <- startISDM(species, spatialCovariates = covariates,
                 Projection = projection, Mesh = mesh, responsePA = 'Present')

```

We can also make a quick plot of where the species are located using `` `.$plot()` ``:

```{r plot, warning = FALSE, message = FALSE, fig.width=8, fig.height=5}

region <- SolitaryTinamou$region

model$plot(Boundary = FALSE) + 
  geom_sf(data = st_boundary(region))

```

To improve stability, we specify priors for the intercepts of the model using `` `.$priorsFixed()` ``

```{r specifyPriors}

model$priorsFixed(Effect = 'Intercept',
                  mean.linear = 0, 
                  prec.linear = 1)

```

And *PC* priors for the spatial field using `` `.$specifySpatial()` ``:

```{r specifySpatial}

model$specifySpatial(sharedSpatial = TRUE,
                     prior.range = c(0.2, 0.1),
                     prior.sigma = c(0.1, 0.1))

```

We can then estimate the parameters in the model using the `fitISDM()` function:

```{r fitISDM, warning = FALSE, message = FALSE}

modelRun <- fitISDM(model, options = list(control.inla = 
                                            list(int.strategy = 'eb'), 
                                          safe = TRUE))
summary(modelRun)

```

*PointedSDMs* also includes generic predict and plot functions:

```{r predict_and_plot, warning = FALSE, message = FALSE, fig.width=8, fig.height=5}

predictions <- predict(modelRun, mesh = mesh,
                       mask = region, 
                       spatial = TRUE,
                       fun = 'linear')

plot(predictions, variable = c('mean', 'sd'))

```

        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 1,354
Total Committers: 44
Avg Commits per committer: 30.773
Development Distribution Score (DDS): 0.623

Commits in past year: 176
Committers in past year: 3
Avg Commits per committer in past year: 58.667
Development Distribution Score (DDS) in past year: 0.051

Name Email Commits
Philip Mostert p****t@n****o 511
Philip Mostert p****m@d****o 69
Philip Mostert p****m@d****o 62
Philip Mostert p****m@d****o 54
Philip Mostert p****m@d****o 52
Philip Mostert p****m@d****o 52
Philip Mostert p****m@d****o 50
Philip Mostert p****m@d****o 48
Philip Mostert p****m@d****o 45
Philip Mostert p****m@d****o 42
Philip Mostert p****m@P****l 37
Philip Mostert p****m@d****o 36
Philip Mostert p****m@d****o 32
Philip Mostert p****m@d****o 26
Philip Mostert p****m@d****o 25
Philip Mostert p****m@d****o 24
Philip Mostert p****m@d****o 19
Philip Mostert p****m@d****o 17
Philip Mostert p****m@d****o 17
Philip Mostert p****m@d****o 16
Philip Mostert p****m@d****o 15
Philip Mostert p****m@d****o 14
Philip Mostert p****m@d****o 12
Philip Mostert p****m@d****o 12
Philip Mostert p****m@d****o 10
Philip Mostert p****m@d****o 9
Philip Mostert p****m@d****o 7
Finn Lindgren F****n@g****m 6
Philip Mostert p****m@d****o 4
RRTogunov r****v@g****m 3
and 14 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 24
Total pull requests: 2
Average time to close issues: 21 days
Average time to close pull requests: about 13 hours
Total issue authors: 15
Total pull request authors: 2
Average comments per issue: 2.63
Average comments per pull request: 1.0
Merged pull request: 2
Bot issues: 0
Bot pull requests: 0

Past year issues: 11
Past year pull requests: 2
Past year average time to close issues: 2 days
Past year average time to close pull requests: about 13 hours
Past year issue authors: 5
Past year pull request authors: 2
Past year average comments per issue: 1.73
Past year average comments per pull request: 1.0
Past year merged pull request: 2
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/philipmostert/pointedsdms

Top Issue Authors

  • melissaminter1602 (4)
  • klaassenmo (3)
  • RRTogunov (3)
  • rondon-d (2)
  • sjbonner (2)
  • lgamador (1)
  • harshadkarandikar (1)
  • ManuelSpinola (1)
  • rsbivand (1)
  • hrlai (1)
  • oharar (1)
  • RPJorge (1)
  • laurawhipple (1)
  • BrentPease1 (1)
  • thomasp85 (1)

Top Pull Request Authors

  • RRTogunov (1)
  • finnlindgren (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

cran.r-project.org: PointedSDMs

Fit Models Derived from Point Processes to Species Distributions using 'inlabru'

  • Homepage: https://github.com/PhilipMostert/PointedSDMs
  • Documentation: http://cran.r-project.org/web/packages/PointedSDMs/PointedSDMs.pdf
  • Licenses: GPL (≥ 3)
  • Latest release: 2.1.3 (published 4 months ago)
  • Last Synced: 2025-04-26T19:03:24.536Z (1 day ago)
  • Versions: 12
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 316 Last month
  • Rankings:
    • Stargazers count: 10.949%
    • Dependent packages count: 18.134%
    • Forks count: 20.985%
    • Average: 23.64%
    • Dependent repos count: 23.828%
    • Downloads: 44.301%
  • Maintainers (1)

Dependencies

DESCRIPTION cran
  • R >= 4.1 depends
  • ggplot2 * depends
  • inlabru >= 2.5 depends
  • methods * depends
  • stats * depends
  • R.devices * imports
  • R6 * imports
  • blockCV * imports
  • raster * imports
  • sp >= 1.4 imports
  • INLA >= 21.08.31 suggests
  • RColorBrewer * suggests
  • USAboundaries * suggests
  • covr * suggests
  • cowplot * suggests
  • ggmap * suggests
  • ggpolypath * suggests
  • kableExtra * suggests
  • knitr * suggests
  • rasterVis * suggests
  • rmarkdown * suggests
  • sf * suggests
  • sn * suggests
  • spocc * suggests
  • testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/pr-fetch v1 composite
  • r-lib/actions/pr-push v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite

Score: 13.015116639502832