likelihood.jsodm_lv: Likelihood Computation for JSODM_LV Model

View source: R/likelihood_jsodm_lv.R

likelihood.jsodm_lvR Documentation

Likelihood Computation for JSODM_LV Model

Description

Computes the likelihood of observations at each ModelSite. At data in the fitted model, or on new data supplied. It uses likelihood_joint_LVvmarg_draw.jsodm_lv.

Usage

## S3 method for class 'jsodm_lv'
likelihood(
  fit,
  numlvsims = 1000,
  cl = NULL,
  simseed = NULL,
  reps = ceiling(numlvsims/100),
  chunksize = 100
)

Arguments

numlvsims

the number of simulated latent variable values to use for computing likelihoods

cl

a cluster created by parallel::makeCluster()

reps

divides the work into reps of lv.v simulations

chunksize

divides the work up by chunksize sets of sites

chains

is a vector indicator which mcmc chains to extract draws from. If NULL then all chains used.

Value

Returns a matrix. Each row corresponds to a draw of the parameters from the posterior. Each column to a ModelSite. The value in each cell is the probability density, given the parameters from the draw, evaluated at the observations for the model site.

Examples

fit <- readRDS("../sflddata/private/data/testdata/cutfit_7_4_11_2LV.rds")
fit <- translatefit(fit)
cl <- parallel::makeCluster(1)
lkl <- likelihood(fit, numlvsims = 10, cl = cl, chunksize = 2)

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