“Stacked” Models

A new extension of the ubms package

Suppose you have a dataset of repeated detections/non detections or counts that are collected over several years, but do not want to fit a dynamic model
R
occupancy
ubms
Author
Affiliation

Diego J. Lizcano

WildMon

Published

July 17, 2024

Using random effects with ubms

One of the advantages of ubms is that it is possible to include random effects in your models, using the same syntax as lme4 (Bates et al. 2015). For example, if you have a group site covariate, you can fit a model with random intercepts by group by including + (1|group) in your parameter formula. Random slopes, or a combination of random slopes and intercepts, are also possible.

To illustrate the use of random effects of ubms, in this post fits we fit a model using a “stacked” model approach. Aditionally in ubms you can instead include, for example, random site intercepts to account for possible pseudoreplication.

The “stacked” model

An alternative approach is to fit multiple years of data into a single-season model is using the “stacked” approach. Essentially, you treat unique site-year combinations as sites.

There are several potential reasons for this:

    1. You don’t have enough data. Take in to account, Dail-Madsen type models are particularly data hungry.
    1. You are not interested in the transition probabilities.
    1. You have very few years (or seasons) and the occupancy did not changed.

Load packages

First we load some packages

Code

library(grateful) # Facilitate Citation of R Packages
library(patchwork) # The Composer of Plots
library(readxl) # Read Excel Files
library(sf) # Simple Features for R
library(mapview) # Interactive Viewing of Spatial Data in R
library(terra) # Spatial Data Analysis
library(elevatr) # Access Elevation Data from Various APIs
library(readr)

library(camtrapR) # Camera Trap Data Management and Preparation of Occupancy and Spatial Capture-Recapture Analyses 
library(ubms) 
library(lme4) 
library(DT)

library(kableExtra) # Construct Complex Table with 'kable' and Pipe Syntax
library(tidyverse) # Easily Install and Load the 'Tidyverse'

Load data

The data set is downloaded from Wildlife insights

image
Code

path <- "C:/CodigoR/CameraTrapCesar/data/katios/"
cameras <- read_csv(paste(path, "cameras.csv", sep=""))
deployment <- read_csv(paste(path, "deployments.csv", sep=""))
images <- read_csv(paste(path, "images.csv", sep=""))
project <- read_csv(paste(path, "projects.csv", sep=""))

# join_by(project_id, camera_id, camera_name)`
cam_deploy <- cameras |> left_join(deployment) |> 
  dplyr::mutate(year=lubridate::year(start_date)) #|> filter(year== 2023)
cam_deploy_image <- images  |> 
  left_join(cam_deploy) |> 
  mutate(scientificName= paste(genus, species, sep = " ")) |> 
   mutate(deployment_id_cam=paste(deployment_id, camera_id, sep = "-")) #|> 
  # filter(year==2022)

Select years and convert to stacked format

To do this we use the camtrapR package.

Code

# filter firs year and make uniques

CToperation  <- cam_deploy_image |> #multi-season data
  # filter(samp_year==2022) |> 
  group_by(deployment_id) |> 
  mutate(minStart=min(start_date), maxEnd=max(end_date)) |> 
  distinct(longitude, latitude, minStart, maxEnd, samp_year) |> 
  ungroup()


# camera operation matrix
# multi-season data
camop <- cameraOperation(CTtable= CToperation, # Tabla de operación
                         stationCol= "deployment_id", # Columna que define la estación
                         setupCol= "minStart", #Columna fecha de colocación
                         retrievalCol= "maxEnd", #Columna fecha de retiro
                         sessionCol = "samp_year", # multi-season column
                         #hasProblems= T, # Hubo fallos de cámaras
                         dateFormat= "%Y-%m-%d") #, # Formato de las fechas
                         #cameraCol="CT")
                         # sessionCol= "Year")

# Generar las historias de detección ---------------------------------------
## remove plroblem species
# ind <- which(datos_PCF$Species=="Marmosa sp.")
# datos_PCF <- datos_PCF[-ind,]

# filter y1
datay <- cam_deploy_image # |> 
  # filter(samp_year==2022) 

DetHist_list <- lapply(unique(datay$scientificName), FUN = function(x) {
  detectionHistory(
    recordTable         = datay, # Tabla de registros
    camOp                = camop, # Matriz de operación de cámaras
    stationCol           = "deployment_id",
    speciesCol           = "scientificName",
    recordDateTimeCol    = "timestamp",
    recordDateTimeFormat  = "%Y-%m-%d",
    species              = x,     # la función reemplaza x por cada una de las especies
    occasionLength       = 15, # Colapso de las historias a días
    day1                 = "station", #inicie en la fecha de cada survey
    datesAsOccasionNames = FALSE,
    includeEffort        = TRUE,
    scaleEffort          = FALSE,
    unmarkedMultFrameInput=TRUE,
    timeZone             = "America/Bogota" 
    )
  }
)

# names
names(DetHist_list) <- unique(datay$scientificName)

# Finalmente creamos una lista nueva donde estén solo las historias de detección
ylist <- lapply(DetHist_list, FUN = function(x) x$detection_history)
effortlist <- lapply(DetHist_list, FUN = function(x) x$effort)

### Danta, Jaguar
which(unique(datay$scientificName)=="Tapirus bairdii")
#> [1] 62
which(unique(datay$scientificName)=="Panthera onca")
#> [1] 4

Convert to sf and map

Code

datos_distinct <- cam_deploy_image |> distinct(longitude, latitude, deployment_id, samp_year)

projlatlon <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

datos_sf <-  st_as_sf(x = datos_distinct,
                         coords = c("longitude", 
                                    "latitude"),
                         crs = projlatlon)

mapview(datos_sf, zcol="samp_year")
Code
#load rasters
per_tree_cov <- rast("C:/CodigoR/WCS-CameraTrap/raster/latlon/Veg_Cont_Fields_Yearly_250m_v61/Perc_TreeCov/MOD44B_Perc_TreeCov_2021_065.tif")
road_den <- rast("C:/CodigoR/WCS-CameraTrap/raster/latlon/RoadDensity/grip4_total_dens_m_km2.asc")
# elev <- rast("D:/CORREGIDAS/elevation_z7.tif")
landcov <- rast("C:/CodigoR/WCS-CameraTrap/raster/latlon/LandCover_Type_Yearly_500m_v61/LC1/MCD12Q1_LC1_2021_001.tif") 
cattle <- rast("C:/CodigoR/WCS-CameraTrap/raster/latlon/Global cattle distribution/5_Ct_2010_Da.tif")
#river <- st_read("F:/WCS-CameraTrap/shp/DensidadRios/MCD12Q1_LC1_2001_001_RECLASS_MASK_GRID_3600m_DensDrenSouthAmer.shp")

# get elevation map
# elevation_detailed <- rast(get_elev_raster(sites, z = 10, clip="bbox", neg_to_na=TRUE))
# elevation_detailed <- get_elev_point (datos_sf, src="aws", overwrite=TRUE)


# extract covs using points and add to sites
# covs <- cbind(sites, terra::extract(SiteCovsRast, sites))
per_tre <- terra::extract(per_tree_cov, datos_sf)
roads <- terra::extract(road_den, datos_sf)
# eleva <- terra::extract(elevation_detailed, sites)
land_cov <- terra::extract(landcov, datos_sf)
cattle_den <-  terra::extract(cattle, datos_sf)

sites <- as.data.frame(datos_sf)

# remove decimals convert to factor
sites$land_cover <-  factor(land_cov$MCD12Q1_LC1_2021_001)
# sites$elevation <-  eleva$file3be898018c3
sites$per_tree_cov <- per_tre$MOD44B_Perc_TreeCov_2021_065 
#  fix 200 isue
ind <- which(sites$per_tree_cov== 200)
sites$per_tree_cov[ind] <- 0

# sites$elevation <- elevation_detailed$elevation
sites$roads <- roads$grip4_total_dens_m_km2
sites$cattle <- cattle_den[,2]

A simple occupancy model for jaguar

Lets use the ubms package to make an occupancy model pooling 2021 and 2022 data together and use the forest cover as covariate.

Create unmarked frame

Code

# fix NA spread
yj <- rbind(ylist[[4]][1:30,1:8],
            ylist[[4]][31:50,12:19])

ej <- rbind(effortlist[[4]][1:30,1:8],
            effortlist[[4]][31:50,12:19])
    
  
umf <- unmarkedFrameOccu(y=yj, 
                         siteCovs=data.frame(
                           per_tree_cov=sites$per_tree_cov,
                           road_den=sites$roads),
                         obsCovs=list(effort=ej)
                      )

plot(umf)

Fit models

and perform model selection.

Code
# fit_0 <- occu(~1~1, data=umf) # unmarked

fit_j0 <- stan_occu(~1~1, data=umf, chains=3, iter=1000, cores=3)
fit_j1 <- stan_occu(~scale(effort)~1, data=umf, chains=3, iter=1000, cores=3)
fit_j2 <- stan_occu(~scale(effort)~scale(per_tree_cov), data=umf, chains=3, iter=1000, cores=3)
fit_j3 <- stan_occu(~scale(effort)~scale(road_den), data=umf, chains=3, iter=1000, cores=3)

# compare
models <- list(Null = fit_j0,
                effort = fit_j1,
                effort_treecov = fit_j2,
                effort_road = fit_j3)

mods <- fitList(fits = models)


## see model selection as a table
datatable( 
  round(modSel(mods), 3)
  )

Best model is fit_j2 which has effort on detection and percent tree cover on occupancy.

Evaluate model fit

Statistic should be near 0.5 if the model fits well

Code
# eval
fit_top_gof <- gof(fit_j2, draws=100, quiet=TRUE)
fit_top_gof
#> MacKenzie-Bailey Chi-square 
#> Point estimate = 135.848
#> Posterior predictive p = 0.59

plot(fit_top_gof)

Model inference

Effort in detection and forest tree cover in occupancy

Code
ubms::plot_effects(fit_j2, "det")

Code
ubms::plot_effects(fit_j2, "state")

Package Citation

Code
pkgs <- cite_packages(output = "paragraph", out.dir = ".") #knitr::kable(pkgs)
pkgs

We used R version 4.3.2 (R Core Team 2023) and the following R packages: camtrapR v. 2.3.0 (Niedballa et al. 2016), devtools v. 2.4.5 (Wickham et al. 2022), DT v. 0.32 (Xie, Cheng, and Tan 2024), elevatr v. 0.99.0 (Hollister et al. 2023), kableExtra v. 1.4.0 (Zhu 2024), lme4 v. 1.1.35.3 (Bates et al. 2015), mapview v. 2.11.2 (Appelhans et al. 2023), patchwork v. 1.2.0 (Pedersen 2024), quarto v. 1.4 (Allaire and Dervieux 2024), rmarkdown v. 2.27 (Xie, Allaire, and Grolemund 2018; Xie, Dervieux, and Riederer 2020; Allaire et al. 2024), sf v. 1.0.15 (Pebesma 2018; Pebesma and Bivand 2023), styler v. 1.10.3 (Müller and Walthert 2024), terra v. 1.7.71 (Hijmans 2024), tidyverse v. 2.0.0 (Wickham et al. 2019), ubms v. 1.2.6 (Kellner et al. 2021).

Sesion info

Session info
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31 ucrt)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Spanish_Colombia.utf8
#>  ctype    Spanish_Colombia.utf8
#>  tz       America/Bogota
#>  date     2024-08-27
#>  pandoc   3.1.11 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  ! package           * version  date (UTC) lib source
#>    abind               1.4-5    2016-07-21 [1] CRAN (R 4.3.1)
#>    backports           1.4.1    2021-12-13 [1] CRAN (R 4.3.1)
#>    base64enc           0.1-3    2015-07-28 [1] CRAN (R 4.3.1)
#>    bit                 4.0.5    2022-11-15 [1] CRAN (R 4.3.2)
#>    bit64               4.0.5    2020-08-30 [1] CRAN (R 4.3.2)
#>    boot                1.3-28.1 2022-11-22 [2] CRAN (R 4.3.2)
#>    brew                1.0-10   2023-12-16 [1] CRAN (R 4.3.2)
#>    bslib               0.6.1    2023-11-28 [1] CRAN (R 4.3.2)
#>    cachem              1.0.8    2023-05-01 [1] CRAN (R 4.3.2)
#>    camtrapR          * 2.3.0    2024-02-26 [1] CRAN (R 4.3.3)
#>    cellranger          1.1.0    2016-07-27 [1] CRAN (R 4.3.2)
#>    checkmate           2.3.1    2023-12-04 [1] CRAN (R 4.3.2)
#>    class               7.3-22   2023-05-03 [2] CRAN (R 4.3.2)
#>    classInt            0.4-10   2023-09-05 [1] CRAN (R 4.3.2)
#>    cli                 3.6.2    2023-12-11 [1] CRAN (R 4.3.2)
#>    codetools           0.2-19   2023-02-01 [2] CRAN (R 4.3.2)
#>    colorspace          2.1-0    2023-01-23 [1] CRAN (R 4.3.2)
#>    crayon              1.5.2    2022-09-29 [1] CRAN (R 4.3.2)
#>    crosstalk           1.2.1    2023-11-23 [1] CRAN (R 4.3.2)
#>    curl                5.2.0    2023-12-08 [1] CRAN (R 4.3.2)
#>    data.table          1.15.0   2024-01-30 [1] CRAN (R 4.3.2)
#>    DBI                 1.2.2    2024-02-16 [1] CRAN (R 4.3.2)
#>    devtools            2.4.5    2022-10-11 [1] CRAN (R 4.3.2)
#>    digest              0.6.34   2024-01-11 [1] CRAN (R 4.3.2)
#>    distributional      0.4.0    2024-02-07 [1] CRAN (R 4.3.2)
#>    dplyr             * 1.1.4    2023-11-17 [1] CRAN (R 4.3.2)
#>    DT                * 0.32     2024-02-19 [1] CRAN (R 4.3.3)
#>    e1071               1.7-14   2023-12-06 [1] CRAN (R 4.3.2)
#>    elevatr           * 0.99.0   2023-09-12 [1] CRAN (R 4.3.2)
#>    ellipsis            0.3.2    2021-04-29 [1] CRAN (R 4.3.2)
#>    evaluate            0.23     2023-11-01 [1] CRAN (R 4.3.2)
#>    fansi               1.0.6    2023-12-08 [1] CRAN (R 4.3.2)
#>    farver              2.1.1    2022-07-06 [1] CRAN (R 4.3.2)
#>    fastmap             1.1.1    2023-02-24 [1] CRAN (R 4.3.2)
#>    forcats           * 1.0.0    2023-01-29 [1] CRAN (R 4.3.2)
#>    fs                  1.6.3    2023-07-20 [1] CRAN (R 4.3.2)
#>    generics            0.1.3    2022-07-05 [1] CRAN (R 4.3.2)
#>    ggplot2           * 3.5.1    2024-04-23 [1] CRAN (R 4.3.3)
#>    glue                1.7.0    2024-01-09 [1] CRAN (R 4.3.2)
#>    grateful          * 0.2.4    2023-10-22 [1] CRAN (R 4.3.3)
#>    gridExtra           2.3      2017-09-09 [1] CRAN (R 4.3.2)
#>    gtable              0.3.4    2023-08-21 [1] CRAN (R 4.3.2)
#>    hms                 1.1.3    2023-03-21 [1] CRAN (R 4.3.2)
#>    htmltools           0.5.7    2023-11-03 [1] CRAN (R 4.3.2)
#>    htmlwidgets         1.6.4    2023-12-06 [1] CRAN (R 4.3.2)
#>    httpuv              1.6.14   2024-01-26 [1] CRAN (R 4.3.2)
#>    inline              0.3.19   2021-05-31 [1] CRAN (R 4.3.2)
#>    jquerylib           0.1.4    2021-04-26 [1] CRAN (R 4.3.2)
#>    jsonlite            1.8.8    2023-12-04 [1] CRAN (R 4.3.2)
#>    kableExtra        * 1.4.0    2024-01-24 [1] CRAN (R 4.3.3)
#>    KernSmooth          2.23-22  2023-07-10 [2] CRAN (R 4.3.2)
#>    knitr               1.46     2024-04-06 [1] CRAN (R 4.3.3)
#>    labeling            0.4.3    2023-08-29 [1] CRAN (R 4.3.1)
#>    later               1.3.2    2023-12-06 [1] CRAN (R 4.3.2)
#>    lattice             0.22-5   2023-10-24 [1] CRAN (R 4.3.2)
#>    leafem              0.2.3    2023-09-17 [1] CRAN (R 4.3.2)
#>    leaflet             2.2.1    2023-11-13 [1] CRAN (R 4.3.2)
#>    leaflet.providers   2.0.0    2023-10-17 [1] CRAN (R 4.3.2)
#>    leafpop             0.1.0    2021-05-22 [1] CRAN (R 4.3.2)
#>    lifecycle           1.0.4    2023-11-07 [1] CRAN (R 4.3.2)
#>    lme4              * 1.1-35.3 2024-04-16 [1] CRAN (R 4.3.2)
#>    loo                 2.7.0    2024-02-24 [1] CRAN (R 4.3.2)
#>    lubridate         * 1.9.3    2023-09-27 [1] CRAN (R 4.3.2)
#>    magrittr            2.0.3    2022-03-30 [1] CRAN (R 4.3.2)
#>    mapview           * 2.11.2   2023-10-13 [1] CRAN (R 4.3.2)
#>    MASS                7.3-60   2023-05-04 [2] CRAN (R 4.3.2)
#>    Matrix            * 1.6-1.1  2023-09-18 [2] CRAN (R 4.3.2)
#>    matrixStats         1.2.0    2023-12-11 [1] CRAN (R 4.3.2)
#>    memoise             2.0.1    2021-11-26 [1] CRAN (R 4.3.2)
#>    mgcv                1.9-1    2023-12-21 [1] CRAN (R 4.3.3)
#>    mime                0.12     2021-09-28 [1] CRAN (R 4.3.1)
#>    miniUI              0.1.1.1  2018-05-18 [1] CRAN (R 4.3.2)
#>    minqa               1.2.6    2023-09-11 [1] CRAN (R 4.3.2)
#>    munsell             0.5.0    2018-06-12 [1] CRAN (R 4.3.2)
#>    nlme                3.1-163  2023-08-09 [2] CRAN (R 4.3.2)
#>    nloptr              2.0.3    2022-05-26 [1] CRAN (R 4.3.2)
#>    patchwork         * 1.2.0    2024-01-08 [1] CRAN (R 4.3.3)
#>    pbapply             1.7-2    2023-06-27 [1] CRAN (R 4.3.2)
#>    pillar              1.9.0    2023-03-22 [1] CRAN (R 4.3.2)
#>    pkgbuild            1.4.4    2024-03-17 [1] CRAN (R 4.3.3)
#>    pkgconfig           2.0.3    2019-09-22 [1] CRAN (R 4.3.2)
#>    pkgload             1.3.4    2024-01-16 [1] CRAN (R 4.3.2)
#>    png                 0.1-8    2022-11-29 [1] CRAN (R 4.3.1)
#>    posterior           1.5.0    2023-10-31 [1] CRAN (R 4.3.2)
#>    processx            3.8.3    2023-12-10 [1] CRAN (R 4.3.2)
#>    profvis             0.3.8    2023-05-02 [1] CRAN (R 4.3.2)
#>    progressr           0.14.0   2023-08-10 [1] CRAN (R 4.3.2)
#>    promises            1.2.1    2023-08-10 [1] CRAN (R 4.3.2)
#>    proxy               0.4-27   2022-06-09 [1] CRAN (R 4.3.2)
#>    ps                  1.7.6    2024-01-18 [1] CRAN (R 4.3.2)
#>    purrr             * 1.0.2    2023-08-10 [1] CRAN (R 4.3.2)
#>    quarto            * 1.4      2024-03-06 [1] CRAN (R 4.3.3)
#>    QuickJSR            1.1.3    2024-01-31 [1] CRAN (R 4.3.2)
#>    R.cache             0.16.0   2022-07-21 [1] CRAN (R 4.3.3)
#>    R.methodsS3         1.8.2    2022-06-13 [1] CRAN (R 4.3.3)
#>    R.oo                1.26.0   2024-01-24 [1] CRAN (R 4.3.3)
#>    R.utils             2.12.3   2023-11-18 [1] CRAN (R 4.3.3)
#>    R6                  2.5.1    2021-08-19 [1] CRAN (R 4.3.2)
#>    raster              3.6-26   2023-10-14 [1] CRAN (R 4.3.2)
#>    Rcpp                1.0.12   2024-01-09 [1] CRAN (R 4.3.2)
#>    RcppNumerical       0.6-0    2023-09-06 [1] CRAN (R 4.3.3)
#>  D RcppParallel        5.1.7    2023-02-27 [1] CRAN (R 4.3.2)
#>    readr             * 2.1.5    2024-01-10 [1] CRAN (R 4.3.2)
#>    readxl            * 1.4.3    2023-07-06 [1] CRAN (R 4.3.2)
#>    remotes             2.5.0    2024-03-17 [1] CRAN (R 4.3.3)
#>    renv                1.0.7    2024-04-11 [1] CRAN (R 4.3.3)
#>    rlang               1.1.3    2024-01-10 [1] CRAN (R 4.3.2)
#>    rmarkdown           2.27     2024-05-17 [1] CRAN (R 4.3.3)
#>    RSpectra            0.16-1   2022-04-24 [1] CRAN (R 4.3.2)
#>    rstan               2.32.6   2024-03-05 [1] CRAN (R 4.3.3)
#>    rstantools          2.4.0    2024-01-31 [1] CRAN (R 4.3.2)
#>    rstudioapi          0.16.0   2024-03-24 [1] CRAN (R 4.3.3)
#>    sass                0.4.8    2023-12-06 [1] CRAN (R 4.3.2)
#>    satellite           1.0.5    2024-02-10 [1] CRAN (R 4.3.2)
#>    scales              1.3.0    2023-11-28 [1] CRAN (R 4.3.3)
#>    secr                4.6.6    2024-02-29 [1] CRAN (R 4.3.3)
#>    sessioninfo         1.2.2    2021-12-06 [1] CRAN (R 4.3.2)
#>    sf                * 1.0-15   2023-12-18 [1] CRAN (R 4.3.2)
#>    shiny               1.8.0    2023-11-17 [1] CRAN (R 4.3.2)
#>    sp                  2.1-3    2024-01-30 [1] CRAN (R 4.3.2)
#>    StanHeaders         2.32.5   2024-01-10 [1] CRAN (R 4.3.2)
#>    stringi             1.8.3    2023-12-11 [1] CRAN (R 4.3.2)
#>    stringr           * 1.5.1    2023-11-14 [1] CRAN (R 4.3.2)
#>    styler            * 1.10.3   2024-04-07 [1] CRAN (R 4.3.3)
#>    svglite             2.1.3    2023-12-08 [1] CRAN (R 4.3.2)
#>    systemfonts         1.0.5    2023-10-09 [1] CRAN (R 4.3.2)
#>    tensorA             0.36.2.1 2023-12-13 [1] CRAN (R 4.3.2)
#>    terra             * 1.7-71   2024-01-31 [1] CRAN (R 4.3.2)
#>    tibble            * 3.2.1    2023-03-20 [1] CRAN (R 4.3.2)
#>    tidyr             * 1.3.1    2024-01-24 [1] CRAN (R 4.3.2)
#>    tidyselect          1.2.1    2024-03-11 [1] CRAN (R 4.3.3)
#>    tidyverse         * 2.0.0    2023-02-22 [1] CRAN (R 4.3.2)
#>    timechange          0.3.0    2024-01-18 [1] CRAN (R 4.3.2)
#>    tzdb                0.4.0    2023-05-12 [1] CRAN (R 4.3.2)
#>    ubms              * 1.2.6    2023-09-11 [1] CRAN (R 4.3.2)
#>    units               0.8-5    2023-11-28 [1] CRAN (R 4.3.2)
#>    unmarked          * 1.4.1    2024-01-09 [1] CRAN (R 4.3.2)
#>    urlchecker          1.0.1    2021-11-30 [1] CRAN (R 4.3.2)
#>    usethis             2.2.3    2024-02-19 [1] CRAN (R 4.3.2)
#>    utf8                1.2.4    2023-10-22 [1] CRAN (R 4.3.2)
#>    uuid                1.2-0    2024-01-14 [1] CRAN (R 4.3.2)
#>    V8                  4.4.2    2024-02-15 [1] CRAN (R 4.3.3)
#>    vctrs               0.6.5    2023-12-01 [1] CRAN (R 4.3.2)
#>    viridisLite         0.4.2    2023-05-02 [1] CRAN (R 4.3.2)
#>    vroom               1.6.5    2023-12-05 [1] CRAN (R 4.3.2)
#>    withr               3.0.0    2024-01-16 [1] CRAN (R 4.3.2)
#>    xfun                0.44     2024-05-15 [1] CRAN (R 4.3.3)
#>    xml2                1.3.6    2023-12-04 [1] CRAN (R 4.3.2)
#>    xtable              1.8-4    2019-04-21 [1] CRAN (R 4.3.2)
#>    yaml                2.3.8    2023-12-11 [1] CRAN (R 4.3.2)
#> 
#>  [1] C:/Users/usuario/AppData/Local/R/win-library/4.3
#>  [2] C:/Program Files/R/R-4.3.2/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

References

Allaire, JJ, and Christophe Dervieux. 2024. quarto: R Interface to Quarto Markdown Publishing System. https://CRAN.R-project.org/package=quarto.
Allaire, JJ, Yihui Xie, Christophe Dervieux, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, et al. 2024. rmarkdown: Dynamic Documents for r. https://github.com/rstudio/rmarkdown.
Appelhans, Tim, Florian Detsch, Christoph Reudenbach, and Stefan Woellauer. 2023. mapview: Interactive Viewing of Spatial Data in r. https://CRAN.R-project.org/package=mapview.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.” Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Hijmans, Robert J. 2024. terra: Spatial Data Analysis. https://CRAN.R-project.org/package=terra.
Hollister, Jeffrey, Tarak Shah, Jakub Nowosad, Alec L. Robitaille, Marcus W. Beck, and Mike Johnson. 2023. elevatr: Access Elevation Data from Various APIs. https://doi.org/10.5281/zenodo.8335450.
Kellner, Kenneth F., Nicholas L. Fowler, Tyler R. Petroelje, Todd M. Kautz, Dean E. Beyer, and Jerrold L. Belant. 2021. ubms: An R Package for Fitting Hierarchical Occupancy and n-Mixture Abundance Models in a Bayesian Framework.” Methods in Ecology and Evolution 13: 577–84. https://doi.org/10.1111/2041-210X.13777.
Müller, Kirill, and Lorenz Walthert. 2024. styler: Non-Invasive Pretty Printing of r Code. https://CRAN.R-project.org/package=styler.
Niedballa, Jürgen, Rahel Sollmann, Alexandre Courtiol, and Andreas Wilting. 2016. camtrapR: An r Package for Efficient Camera Trap Data Management.” Methods in Ecology and Evolution 7 (12): 1457–62. https://doi.org/10.1111/2041-210X.12600.
Pebesma, Edzer. 2018. Simple Features for R: Standardized Support for Spatial Vector Data.” The R Journal 10 (1): 439–46. https://doi.org/10.32614/RJ-2018-009.
Pebesma, Edzer, and Roger Bivand. 2023. Spatial Data Science: With applications in R. Chapman and Hall/CRC. https://doi.org/10.1201/9780429459016.
Pedersen, Thomas Lin. 2024. patchwork: The Composer of Plots. https://CRAN.R-project.org/package=patchwork.
R Core Team. 2023. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wickham, Hadley, Jim Hester, Winston Chang, and Jennifer Bryan. 2022. devtools: Tools to Make Developing r Packages Easier. https://CRAN.R-project.org/package=devtools.
Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.
Xie, Yihui, Joe Cheng, and Xianying Tan. 2024. DT: A Wrapper of the JavaScript Library DataTables. https://CRAN.R-project.org/package=DT.
Xie, Yihui, Christophe Dervieux, and Emily Riederer. 2020. R Markdown Cookbook. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown-cookbook.
Zhu, Hao. 2024. kableExtra: Construct Complex Table with kable and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.

Citation

BibTeX citation:
@online{j._lizcano2024,
  author = {J. Lizcano, Diego},
  title = {“{Stacked}” {Models}},
  date = {2024-07-17},
  url = {https://dlizcano.github.io/cametrap/posts/2024-07-17-stackmodel/},
  langid = {en}
}
For attribution, please cite this work as:
J. Lizcano, Diego. 2024. ‘Stacked’ Models.” July 17, 2024. https://dlizcano.github.io/cametrap/posts/2024-07-17-stackmodel/.