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

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

#include <lognormal_lpdf.hpp>

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

Public Member Functions

 LogNormalLPDF ()
 Constructor.
 
virtual ~LogNormalLPDF ()
 Destructor.
 
virtual const Type evaluate ()
 Evaluates the lognormal log probability density 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< Typelog_sd
 Natural log of the standard deviation of the distribution on the log scale. The argument can be a vector or scalar, where the latter is referenced for each instance through the use of get_force_scalar().
 
- 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::LogNormalLPDF< Type >

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

This implementation relies on TMB's R-style dnorm() utility for normal log-density calculations on log-transformed values. Specifically, when evaluating the lognormal likelihood, observations are transformed with log(x) and passed to dnorm(..., give_log = true) to obtain log-density values. For data inputs, the Jacobian adjustment -log(x) is applied where appropriate to convert from normal density on the log scale to the lognormal density on the original scale.

For data input, values equal to na_value are skipped and contribute zero to the objective. Per-observation contributions are stored in lpdf_vec; the summed total is returned by evaluate() and stored in lpdf.

Member Function Documentation

◆ evaluate()

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

Evaluates the lognormal log probability density function.

The following equation is the lognormal probability density function, and thus, the log of it is evaluated:

\[ f(x) = \frac{1.0}{ x\sigma\sqrt{2\pi} }\mathrm{exp}\Bigg(-\frac{(\mathrm{ln}(x) - \mu)^{2}}{2\sigma^{2}}\Bigg), \]

where \(\mu\) is the mean of the distribution of \(\mathrm{ln(x)}\) and \(\sigma^2\) is the variance of \(\mathrm{ln}(x)\).

Implements fims_distributions::DensityComponentBase< Type >.


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