14#include "../../common/fims_vector.hpp"
15#include "../../common/def.hpp"
17namespace fims_distributions {
34template <
typename Type>
70 std::fill(this->
lpdf_vec.begin(), this->lpdf_vec.end(),
71 static_cast<Type
>(0));
72 this->
lpdf =
static_cast<Type
>(0);
76 if (n_x != n_expected) {
77 if (n_expected == 1) {
79 }
else if (n_x > n_expected) {
84 if (this->log_sd.
size() > 1 && n_x != this->log_sd.
size()) {
85 throw std::invalid_argument(
86 "LognormalLPDF::Vector index out of bounds. The size of observed "
87 "data does not equal the size of the log_sd vector. The observed "
88 "data vector is of size " +
89 fims::to_string(n_x) +
" and the log_sd vector is of size " +
90 fims::to_string(this->log_sd.
size()));
93 for (
size_t i = 0; i < n_x; i++) {
103 fims_math::exp(
log_sd.get_force_scalar(i)),
true) -
113 fims_math::exp(
log_sd.get_force_scalar(i)),
true);
117 fims_math::exp(
log_sd.get_force_scalar(i)),
true) -
129 fims_math::exp(
log_sd.get_force_scalar(i))));
132 (*this->
re)[i] = fims_math::exp(
134 fims_math::exp(
log_sd.get_force_scalar(i))));
137 (*(this->
priors[i]))[0] = fims_math::exp(
139 fims_math::exp(
log_sd.get_force_scalar(i))));
146 vector<Type> lognormal_observed_values = this->
observed_values.to_tmb();
Definition fims_vector.hpp:27
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:273
Declares the DensityComponentBase class, which is the base class for all distribution functors.
#define FIMS_SIMULATE_F(F)
TMB macro that simulates data.
Definition interface.hpp:70
Base class for all module_name functors.
Definition density_components_base.hpp:32
fims::Vector< Type > lpdf_vec
Vector storing observation-level log-likelihood contributions.
Definition density_components_base.hpp:190
fims::Vector< Type > observed_values
Input value of distribution function for priors or random effects.
Definition density_components_base.hpp:61
bool simulate_flag
Boolean; if true, data are simulated from the distribution.
Definition density_components_base.hpp:200
Type & get_expected(size_t i)
Retrieve one expected value based on input_type and use_mean.
Definition density_components_base.hpp:122
Type lpdf
Total log probability density contribution of the distribution.
Definition density_components_base.hpp:180
size_t get_n_expected()
Get length of the active expected input vector.
Definition density_components_base.hpp:155
size_t get_n_x()
Get length of the active observed input vector.
Definition density_components_base.hpp:138
Type & get_observed(size_t i)
Retrieve one observed value based on input_type.
Definition density_components_base.hpp:83
fims::Vector< Type > * re
Pointer to random effects vector.
Definition density_components_base.hpp:47
std::string input_type
Classification of the input pathway for this distribution object. Options used by accessor methods ar...
Definition density_components_base.hpp:38
std::shared_ptr< fims_data_object::DataObject< Type > > data_observed_values
Observed data.
Definition density_components_base.hpp:41
std::vector< fims::Vector< Type > * > priors
Vector of pointers where each entry points to a prior parameter.
Definition density_components_base.hpp:56
Implements the LogNormalLPDF distribution functor used by FIMS to evaluate observation-level and tota...
Definition lognormal_lpdf.hpp:35
virtual ~LogNormalLPDF()
Destructor.
Definition lognormal_lpdf.hpp:50
LogNormalLPDF()
Constructor.
Definition lognormal_lpdf.hpp:46
fims::Vector< Type > log_sd
Natural log of the standard deviation of the distribution on the log scale. The argument can be a vec...
Definition lognormal_lpdf.hpp:42
virtual const Type evaluate()
Evaluates the lognormal log probability density function.
Definition lognormal_lpdf.hpp:63