artificial_runjags: Create a fully artificial fitted object

Description Usage Arguments Details Value Functions Examples

View source: R/simulate_fit.R

Description

Create a fully artificial fitted object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
artificial_runjags(
  nspecies = 4,
  nsites = 100,
  nvisitspersite = 2,
  nlv = 2,
  OccFmla = "~ UpSite + Sine1 + Sine2",
  ObsFmla = "~ UpVisit + Step",
  u.b.min = -1,
  u.b.max = 1,
  v.b.min = -1,
  v.b.max = 1,
  lv.coef.min = -0.5,
  lv.coef.max = 0.5
)

simulate_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)

nlv

Number of latent variables. Must be 4 or less

OccFmla

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

ObsFmla

Formula for detection. Available variables: Upvisit, Step

u.b.min,

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

lv.coef.min,

lv.coef.max Same as u.b.min and u.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.

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

Examples

1
2
3
4
5
6
7
artfit <- artificial_runjags(nspecies = 2, nsites = 10, nvisitspersite = 4, nlv = 2)
\# with high correlation between occupancy of species
artfit <- artificial_runjags(nspecies = 2, nsites = 10, nvisitspersite = 4, nlv = 2,
                              OccFmla = "~ 1",
                              u.b.min = 0.8,
                              lv.coef.min = 0.3)
 cor(artfit$data$y)

sustainablefarms/linking-data documentation built on Oct. 28, 2020, 2:41 a.m.