LLK_GOF: A function to estimate log likelihood (LLK) goodness-of-fit

View source: R/goodness_of_fit.R

LLK_GOFR Documentation

A function to estimate log likelihood (LLK) goodness-of-fit

Description

A function to estimate log likelihood (LLK) goodness-of-fit

Usage

LLK_GOF(
  .samples,
  .func,
  .args = list(NULL),
  .l_targets,
  .maximise = TRUE,
  .optim = FALSE,
  ...
)

Arguments

.samples

A table or vector of sampled parameter values

.func

A function defining the model to be calibrated

.args

A list of arguments to be passed to .func

.l_targets

A list containing a vector of targets' names, a vector of targets' weights, a vector of targets' distributions, and a table for each target that contains the values (column name 'value') and standard errors (column name 'sd') of the corresponding target.

.maximise

Logical for whether the output of the function is used in a maximising optimisation function. Default is TRUE.

.optim

Logical for whether the function is used by an optimisation algorithm. Default is FALSE.

...

Extra arguments, e.g. seed number and vector of calibrated parameters' names or .sample_method (for labelling purposes).

Value

A table with proposed parameter sets and their corresponding summed overall likelihood values sorted in descending order.

Examples

## Not run: 
library(calibR)
data("CRS_targets")
Surv <- CRS_targets$Surv
v_targets_names <- c("Surv")
v_targets_dists <- c('norm')
v_targets_weights <- c(1)
l_targets <- list('v_targets_names' = v_targets_names, 'Surv' = Surv,
                  'v_targets_dists' = v_targets_dists,
                  'v_targets_weights' = v_targets_weights)

v_params_names <- c("p_Mets", "p_DieMets")
v_params_dists <- c("unif", "unif")
args <- list(list(min = 0.04, max = 0.16),
             list(min = 0.04, max = 0.12))
l_params = list(v_params_names = v_params_names,
                v_params_dists = v_params_dists,
                args = args)

samples <- sample_prior_LHS(.l_params = l_params,
                            .n_samples = 10)

GOF_llik <- LLK_GOF(.func = CRS_markov, .samples = samples,
                           .l_targets = l_targets)

## End(Not run)

W-Mohammed/calibrater documentation built on Oct. 14, 2023, 1:57 a.m.