15#ifndef DENSITY_COMPONENT_BASE_HPP
16#define DENSITY_COMPONENT_BASE_HPP
18#include "../../common/data_object.hpp"
19#include "../../common/model_object.hpp"
20#include "../../interface/interface.hpp"
21#include "../../common/fims_vector.hpp"
22#include "../../common/fims_math.hpp"
24namespace fims_distributions {
31template <
typename Type>
56 std::vector<fims::Vector<Type>*>
priors;
84 if (this->input_type ==
"data") {
87 if (this->input_type ==
"random_effects") {
90 if (this->input_type ==
"prior") {
92 throw std::runtime_error(
"No priors defined for this distribution.");
93 }
else if (
priors.size() == 1) {
95 }
else if (
priors.size() > 1) {
109 if (this->input_type ==
"data") {
123 if (this->input_type ==
"data") {
125 }
else if (this->use_mean ==
"yes") {
127 }
else if (this->input_type ==
"random_effects") {
139 if (this->input_type ==
"data") {
140 return this->data_observed_values->data.size();
142 if (this->input_type ==
"random_effects") {
145 if (this->input_type ==
"prior") {
146 return this->expected_values.
size();
156 if (this->input_type ==
"data") {
157 return (*data_expected_values).size();
159 if (this->input_type ==
"random_effects") {
160 return (*re_expected_values).size();
162 if (this->input_type ==
"prior") {
163 return this->expected_values.
size();
205 std::vector<uint32_t>
key;
211 ::objective_function<Type>* of;
220 this->priors.resize(1);
221 this->priors[0] = NULL;
235template <
typename Type>
Definition fims_vector.hpp:27
Type & get_force_scalar(size_t pos)
If this vector is size 1 and pos is greater than zero, the first index is returned....
Definition fims_vector.hpp:182
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:273
Base class for all module_name functors.
Definition density_components_base.hpp:32
std::vector< uint32_t > key
Unique ID for variable map that points to a fims::Vector.
Definition density_components_base.hpp:205
std::string use_mean
If "yes", expected_mean is used instead of expected_values. The default is "no" leading to the use of...
Definition density_components_base.hpp:72
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
bool osa_flag
Boolean; if true, one-step-ahead (OSA) residuals are calculated.
Definition density_components_base.hpp:195
Type lpdf
Total log probability density contribution of the distribution.
Definition density_components_base.hpp:180
fims::Vector< Type > * data_expected_values
Expected value vector for data pathways.
Definition density_components_base.hpp:53
DensityComponentBase()
Constructor, which initializes default prior pointer state and ID.
Definition density_components_base.hpp:217
virtual const Type evaluate()=0
Evaluate the distribution-specific log-likelihood contribution.
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
fims::Vector< Type > expected_values
Expected value vector for prior-based pathways.
Definition density_components_base.hpp:44
fims::Vector< Type > * re_expected_values
Expected value vector for random-effects pathways.
Definition density_components_base.hpp:50
std::shared_ptr< fims_data_object::DataObject< Type > > data_observed_values
Observed data.
Definition density_components_base.hpp:41
static uint32_t id_g
Global unique identifier for distribution modules.
Definition density_components_base.hpp:174
int observed_data_id_m
ID of observed data component.
Definition density_components_base.hpp:185
std::vector< fims::Vector< Type > * > priors
Vector of pointers where each entry points to a prior parameter.
Definition density_components_base.hpp:56
Type & get_observed(size_t i, size_t j)
Retrieve one observed matrix-like value based on input_type.
Definition density_components_base.hpp:108
fims::Vector< Type > expected_mean
The expected mean of the distribution; overrides expected values.
Definition density_components_base.hpp:66
FIMSObject struct that defines member types and returns the unique id.
Definition model_object.hpp:25