artificial_runjags: Create a fully artificial fitted object

View source: R/simulate_fit.R

artificial_runjagsR Documentation

Create a fully artificial fitted object

Description

Create a fully artificial fitted object

Usage

artificial_runjags(
  nspecies = 4,
  nsites = 100,
  nvisitspersite = 2,
  OccFmla = "~ UpSite + Sine1 + Sine2",
  ObsFmla = "~ UpVisit + Step",
  occ.b.min = -1,
  occ.b.max = 1,
  det.b.min = -1,
  det.b.max = 1,
  lv.b.min = -0.5,
  lv.b.max = 0.5,
  modeltype = "jsodm_lv",
  seed = NULL,
  ...
)

artificial_covar_data(nsites, nvisitspersite)

simulate_iid_detections(nspecies, nvisits, p = 0.5)

Arguments

nspecies

is the number of species to simulate. Species are named A, B, C... (max of 26 allowed)

nsites

Number of ModelSites to simulate

nvisitspersite

Number of visits per site (the same number for each site)

OccFmla

Formula for occupancy. Available variables: UpSite, Sine1 and Sine2

ObsFmla

Formula for detection. Available variables: Upvisit, Step

occ.b.min,

occ.b.max, det.b.min, det.b.max The upper and lower bouonds of the occ.b and det.b parameters. May be a single number or an array with rows corresponding to species and columns to covariates.

lv.b.min,

lv.b.max Same as occ.b.min and occ.b.max for the latent variable loadings.

nvisits

Number of visits in total to simulate

p

The probability of detection, constant for all species and visits.

nlv

Number of latent variables. Must be 4 or less

Details

Occupancy covariate names are UpSite, Sine1 and Sine2. Detection dovariate names are UpVisit and Step.

Every species is equally likely to be detected at every visit.

Value

A list that has enough similarities to runjags objects that residual calculations are possible. The true parameter set is the first (and only row) of the first MCMC chain. It can be accessed using get_theta(fit, type = 1)

A list with elements Xocc, and Xobs for the occupancy and detection covariates respectively

A simulated dataframe of detections. Column names are the species names, each row is a visit. Elements of the data frame are either 1 (detected) or 0 (not detected).

Functions

  • artificial_covar_data: Generate fake covariate data.

  • simulate_iid_detections: Generate fake observation data.

Examples

artfit <- artificial_runjags(nspecies = 2, nsites = 20, nvisitspersite = 4, 
modeltype = "jsodm_lv", nlv = 2, seed = NULL)
\# with high correlation between occupancy of species
artfit <- artificial_runjags(nspecies = 2, nsites = 10, nvisitspersite = 4,
                              OccFmla = "~ 1",
                              occ.b.min = 0.8,
                              lv.b.min = 0.3,
                              modeltype = "jsodm_lv",
                              nlv = 2)
 cor(artfit$data$y)

sustainablefarms/msod documentation built on March 6, 2023, 7:17 a.m.