extract_log_lik {ubms}R Documentation

Extract Pointwise Log-likelihood From Model

Description

Extracts the pointwise log-likelihood matrix or array from a model. This is useful as an input for functions in the loo package. If called on a ubmsFit object, the log-likelihood matrix or array is calculated using the posterior distributions of the parameters; the log-likelihood values are not actually saved inside the model object. If called on a stanfit object, loo::extract_log_lik is used. In this case, the log-likelihood must be saved as one of the output parameters in Stan.

Usage

extract_log_lik(object, parameter_name = "log_lik", merge_chains = TRUE)

Arguments

object

A ubmsFit or stanfit object

parameter_name

The name of the log-likelihood parameter in the Stan output; ignored when object is a ubmsFit

merge_chains

If TRUE (the default), all Markov chains are merged together (i.e., stacked) and a matrix is returned. If ‘FALSE’ they are kept separate and an array is returned.

Value

A matrix (samples x sites) or array (samples x chains x sites)


[Package ubms version 1.2.6 Index]