FIMS  v0.8.1
Loading...
Searching...
No Matches
fims_distributions::MultinomialLPMF< Type > Struct Template Reference

Implements the MultinomialLPMF distribution functor used by FIMS to evaluate the observation-level and total log-likelihood contributions under a multinomial error model for data, priors, and random effects. More...

#include <multinomial_lpmf.hpp>

Inheritance diagram for fims_distributions::MultinomialLPMF< Type >:
fims_distributions::DensityComponentBase< Type > fims_model_object::FIMSObject< Type >

Public Member Functions

 MultinomialLPMF ()
 Constructor.
 
virtual ~MultinomialLPMF ()
 Destructor.
 
virtual const Type evaluate ()
 Evaluates the multinomial log probability mass function.
 
- Public Member Functions inherited from fims_distributions::DensityComponentBase< Type >
Typeget_observed (size_t i)
 Retrieve one observed value based on input_type.
 
Typeget_observed (size_t i, size_t j)
 Retrieve one observed matrix-like value based on input_type.
 
Typeget_expected (size_t i)
 Retrieve one expected value based on input_type and use_mean.
 
size_t get_n_x ()
 Get length of the active observed input vector.
 
size_t get_n_expected ()
 Get length of the active expected input vector.
 
 DensityComponentBase ()
 Constructor, which initializes default prior pointer state and ID.
 
- Public Member Functions inherited from fims_model_object::FIMSObject< Type >
uint32_t GetId () const
 Getter that returns the unique id for parameters in the model.
 
bool CheckDimensions (size_t actual, size_t expected)
 Check the dimensions of an object.
 

Public Attributes

fims::Vector< size_tdims
 Dimensions of the number of rows and columns of the multivariate dataset.
 
- Public Attributes inherited from fims_distributions::DensityComponentBase< Type >
std::string input_type
 Classification of the input pathway for this distribution object. Options used by accessor methods are, "prior", "random_effects", and "data".
 
std::shared_ptr< fims_data_object::DataObject< Type > > data_observed_values
 Observed data.
 
fims::Vector< Typeexpected_values
 Expected value vector for prior-based pathways.
 
fims::Vector< Type > * re = NULL
 Pointer to random effects vector.
 
fims::Vector< Type > * re_expected_values = NULL
 Expected value vector for random-effects pathways.
 
fims::Vector< Type > * data_expected_values = NULL
 Expected value vector for data pathways.
 
std::vector< fims::Vector< Type > * > priors
 Vector of pointers where each entry points to a prior parameter.
 
fims::Vector< Typeobserved_values
 Input value of distribution function for priors or random effects.
 
fims::Vector< Typeexpected_mean
 The expected mean of the distribution; overrides expected values.
 
std::string use_mean = fims::to_string("no")
 If "yes", expected_mean is used instead of expected_values. The default is "no" leading to the use of expected_values.
 
Type lpdf
 Total log probability density contribution of the distribution.
 
int observed_data_id_m = -999
 ID of observed data component.
 
fims::Vector< Typelpdf_vec
 Vector storing observation-level log-likelihood contributions.
 
bool osa_flag = false
 Boolean; if true, one-step-ahead (OSA) residuals are calculated.
 
bool simulate_flag = false
 Boolean; if true, data are simulated from the distribution.
 
std::vector< uint32_tkey
 Unique ID for variable map that points to a fims::Vector.
 
- Public Attributes inherited from fims_model_object::FIMSObject< Type >
uint32_t id
 
std::vector< Type * > parameters
 
std::vector< Type * > random_effects_parameters
 
std::vector< Type * > fixed_effects_parameters
 

Additional Inherited Members

- Static Public Attributes inherited from fims_distributions::DensityComponentBase< Type >
static uint32_t id_g = 0
 Global unique identifier for distribution modules.
 

Detailed Description

template<typename Type>
struct fims_distributions::MultinomialLPMF< Type >

Implements the MultinomialLPMF distribution functor used by FIMS to evaluate the observation-level and total log-likelihood contributions under a multinomial error model for data, priors, and random effects.

This implementation relies on TMB's R-style dmultinom() utility to compute row-wise multinomial log-probability mass contributions from observed counts (x_vector) and expected proportions (prob_vector). Specifically, when evaluating the multinomial likelihood, observations are passed to dmultinom(..., give_log = true).

For data input, if any element in a row is equal to na_value, the entire row is skipped and contributes zero to the objective. Contributions are stored in lpdf_vec. The summed total is returned by evaluate() and stored in lpdf.

Row observations could be counts of each age for a given time step, where additional time steps would be additional rows. Thus, columns are bins.

Member Function Documentation

◆ evaluate()

template<typename Type >
virtual const Type fims_distributions::MultinomialLPMF< Type >::evaluate ( )
inlinevirtual

Evaluates the multinomial log probability mass function.

The following equation is the multinomial probability mass function, and thus, the log of it is evaluated:

\[ f(\underline{y}) = \frac{n!}{y_{1}!... y_{k}!}p^{y_{1}}_{1}...p^{y_{k}}_{k}, \]

where \(k\) is the number of categories, \(n\) is the sample size, \(\mu_{i}\) is the mean of \(y_{i}\) and is equal to \(np_{i}\), and \(\sigma^{2}_{i}\) is the variance of \(y_{i}\) and is equal to \(np_{i}(1-p_{i})\).

< total log probability mass contribution of the distribution

< index for lpdf_vec vector

Implements fims_distributions::DensityComponentBase< Type >.


The documentation for this struct was generated from the following file: