9#ifndef FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_DISTRIBUTION_HPP
10#define FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_DISTRIBUTION_HPP
18#include "../../../distributions/distributions.hpp"
37 std::shared_ptr<std::vector<uint32_t>>
key_m;
71 static std::map<uint32_t, std::shared_ptr<DistributionsInterfaceBase>>
86 this->key_m = std::make_shared<std::vector<uint32_t>>();
124 Rcpp::IntegerVector ids) {
183 const std::vector<std::pair<std::string, VariableVector *>> ¶meters) {
184 std::vector<std::string> entries;
185 for (
const auto ¶meter : parameters) {
187 if (values ==
nullptr || values->
size() == 0) {
190 std::stringstream entry;
192 entry <<
" \"name\": \"" << parameter.first <<
"\",\n";
193 entry <<
" \"id\": " << values->
id_m <<
",\n";
194 entry <<
" \"type\": \"vector\",\n";
195 entry <<
" \"dimensionality\": {\n";
196 entry <<
" \"header\": [null],\n";
197 entry <<
" \"dimensions\": [" << values->
size() <<
"]\n";
199 entry <<
" \"values\": " << *values <<
"\n";
201 entries.push_back(entry.str());
203 if (entries.empty()) {
206 std::stringstream ss;
207 ss <<
" \"parameters\": [\n";
208 for (
size_t i = 0; i < entries.size(); i++) {
209 ss << (i == 0 ?
" " :
",\n ") << entries[i];
226 std::stringstream ss;
227 ss <<
" \"linked_ids\": [";
228 for (
size_t i = 0; i < this->key_m->size(); i++) {
229 ss << (i == 0 ?
"" :
", ") << this->key_m->at(i);
272 std::make_shared<DnormDistributionsInterface>(*
this);
314 this->expected_mean[0].initial_value_m = input_value;
315 this->expected_mean[0].estimation_type_m.
set(
"fixed_effects");
324 Rcpp::IntegerVector ids) {
326 this->
key_m->resize(ids.size());
327 for (R_xlen_t i = 0; i < ids.size(); i++) {
328 this->
key_m->at(i) = ids[i];
345 for (
size_t i = 0; i < this->observed_values.
size(); i++) {
348 for (
size_t i = 0; i < this->expected_values.
size(); i++) {
351 for (
size_t i = 0; i < this->log_sd.
size(); i++) {
352 dnorm.
log_sd[i] = this->log_sd[i].initial_value_m;
354 for (
size_t i = 0; i < this->expected_mean.
size(); i++) {
355 dnorm.
expected_mean[i] = this->expected_mean[i].initial_value_m;
369 " has been finalized already.");
374 std::shared_ptr<fims_info::Information<double>> info =
384 " not found in Information.");
387 std::shared_ptr<fims_distributions::NormalLPDF<double>> dnorm =
388 std::dynamic_pointer_cast<fims_distributions::NormalLPDF<double>>(
393 size_t n_x = dnorm->get_n_x();
397 if (this->log_sd.
size() != n_x) {
399 if (this->log_sd.
size() == 1) {
400 auto tmp = this->log_sd[0];
402 for (
size_t i = 0; i < n_x; ++i) {
403 this->log_sd[i] = tmp;
408 "log_sd size does not match number of observations and is not "
412 for (
size_t i = 0; i < n_x; i++) {
413 if (this->log_sd[i].estimation_type_m.
get() ==
"constant") {
414 this->log_sd[i].final_value_m = this->log_sd[i].initial_value_m;
416 this->log_sd[i].final_value_m = dnorm->log_sd.get_force_scalar(i);
420 for (
size_t i = 0; i < this->expected_mean.
size(); i++) {
421 if (this->expected_mean[i].estimation_type_m.
get() ==
"constant") {
422 this->expected_mean[i].final_value_m =
423 this->expected_mean[i].initial_value_m;
425 this->expected_mean[i].final_value_m = dnorm->expected_mean[i];
430 if (this->expected_values.
size() == 1) {
431 this->expected_values.
resize(n_x);
433 if (this->observed_values.
size() == 1) {
434 this->observed_values.
resize(n_x);
437 for (
size_t i = 0; i < this->lpdf_vec.
size(); i++) {
438 this->lpdf_vec[i] = dnorm->lpdf_vec[i];
439 this->expected_values[i].final_value_m = dnorm->get_expected(i);
440 this->observed_values[i].final_value_m = dnorm->get_observed(i);
453 std::stringstream ss;
456 ss <<
" \"module_name\": \"density\",\n";
457 ss <<
" \"module_id\": " << this->
id_m <<
",\n";
458 ss <<
" \"module_type\": \"normal\",\n";
461 ss <<
" \"input_type\" : \"" << this->
input_type_m <<
"\",\n";
464 ss <<
" \"density_component\": {\n";
466 ss <<
" \"value\":[";
467 if (this->lpdf_vec.
size() == 0) {
470 for (
size_t i = 0; i < this->lpdf_vec.
size() - 1; i++) {
478 ss <<
" \"expected_values\":[";
479 if (this->expected_values.
size() == 0) {
482 for (
size_t i = 0; i < this->expected_values.
size() - 1; i++) {
487 this->expected_values[this->expected_values.
size() - 1]
491 ss <<
" \"log_sd_values\":[";
492 if (this->log_sd.
size() == 0) {
495 for (R_xlen_t i = 0; i < static_cast<R_xlen_t>(this->log_sd.
size()) - 1;
500 this->log_sd[this->log_sd.
size() - 1].final_value_m)
503 ss <<
" \"observed_values\":[";
504 if (this->observed_values.
size() == 0) {
507 for (
size_t i = 0; i < this->observed_values.
size() - 1; i++) {
508 ss << this->observed_values[i].final_value_m <<
", ";
510 ss << this->observed_values[this->observed_values.
size() - 1]
520 template <
typename Type>
521 bool add_to_fims_tmb_internal() {
522 std::shared_ptr<fims_info::Information<Type>> info =
525 std::shared_ptr<fims_distributions::NormalLPDF<Type>> distribution =
526 std::make_shared<fims_distributions::NormalLPDF<Type>>();
531 std::stringstream ss;
533 distribution->key.resize(this->
key_m->size());
534 for (
size_t i = 0; i < this->
key_m->size(); i++) {
535 distribution->key[i] = this->
key_m->at(i);
537 distribution->id = this->
id_m;
538 distribution->observed_values.resize(this->observed_values.
size());
539 for (
size_t i = 0; i < this->observed_values.
size(); i++) {
540 distribution->observed_values[i] =
541 this->observed_values[i].initial_value_m;
544 distribution->expected_values.
resize(this->expected_values.
size());
545 for (
size_t i = 0; i < this->expected_values.
size(); i++) {
546 distribution->expected_values[i] =
547 this->expected_values[i].initial_value_m;
549 distribution->log_sd.
resize(this->log_sd.
size());
550 for (
size_t i = 0; i < this->log_sd.
size(); i++) {
551 distribution->log_sd[i] = this->log_sd[i].initial_value_m;
552 if (this->log_sd[i].estimation_type_m.
get() ==
"fixed_effects") {
554 ss <<
"dnorm." << this->
id_m <<
".log_sd." << this->log_sd[i].
id_m;
555 info->RegisterParameterName(ss.str());
556 info->RegisterParameter(distribution->log_sd[i]);
558 if (this->log_sd[i].estimation_type_m.
get() ==
"random_effects") {
559 FIMS_ERROR_LOG(
"standard deviations cannot be set to random effects");
562 info->variable_map[this->log_sd.
id_m] = &(distribution)->
log_sd;
565 distribution->expected_mean.resize(this->expected_mean.
size());
566 for (
size_t i = 0; i < this->expected_mean.
size(); i++) {
567 distribution->expected_mean[i] = this->expected_mean[i].initial_value_m;
568 if (this->expected_mean[i].estimation_type_m.
get() ==
"fixed_effects") {
570 ss <<
"dnorm." << this->
id_m <<
".expected_mean."
571 << this->expected_mean[i].
id_m;
572 info->RegisterParameterName(ss.str());
573 info->RegisterParameter(distribution->expected_mean[i]);
575 if (this->expected_mean[i].estimation_type_m.
get() ==
"random_effects") {
579 info->variable_map[this->expected_mean.
id_m] =
582 info->density_components[distribution->id] = distribution;
592 this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
593 this->add_to_fims_tmb_internal<TMBAD_FIMS_TYPE>();
635 std::make_shared<DlnormDistributionsInterface>(*
this);
681 Rcpp::IntegerVector ids) {
683 this->
key_m->resize(ids.size());
684 for (R_xlen_t i = 0; i < ids.size(); i++) {
685 this->
key_m->at(i) = ids[i];
702 for (
size_t i = 0; i < this->observed_values.
size(); i++) {
705 for (
size_t i = 0; i < this->expected_values.
size(); i++) {
708 for (
size_t i = 0; i < this->log_sd.
size(); i++) {
709 dlnorm.
log_sd[i] = this->log_sd[i].initial_value_m;
722 " has been finalized already.");
727 std::shared_ptr<fims_info::Information<double>> info =
737 " not found in Information.");
740 std::shared_ptr<fims_distributions::LogNormalLPDF<double>> dlnorm =
741 std::dynamic_pointer_cast<fims_distributions::LogNormalLPDF<double>>(
746 size_t n_x = dlnorm->get_n_x();
748 if (this->log_sd.
size() != n_x) {
750 if (this->log_sd.
size() == 1) {
751 auto tmp = this->log_sd[0];
753 for (
size_t i = 0; i < n_x; ++i) {
754 this->log_sd[i] = tmp;
759 "log_sd size does not match number of observations and is not "
764 for (
size_t i = 0; i < n_x; i++) {
765 if (this->log_sd[i].estimation_type_m.
get() ==
"constant") {
766 this->log_sd[i].final_value_m = this->log_sd[i].initial_value_m;
768 this->log_sd[i].final_value_m = dlnorm->log_sd.get_force_scalar(i);
773 if (this->expected_values.
size() == 1) {
774 this->expected_values.
resize(n_x);
776 if (this->observed_values.
size() == 1) {
777 this->observed_values.
resize(n_x);
779 for (
size_t i = 0; i < this->lpdf_vec.
size(); i++) {
780 this->lpdf_vec[i] = dlnorm->lpdf_vec[i];
781 this->expected_values[i].final_value_m = dlnorm->get_expected(i);
782 this->observed_values[i].final_value_m = dlnorm->get_observed(i);
795 std::stringstream ss;
798 ss <<
" \"module_name\": \"density\",\n";
799 ss <<
" \"module_id\": " << this->
id_m <<
",\n";
800 ss <<
" \"module_type\": \"log_normal\",\n";
803 ss <<
" \"input_type\" : \"" << this->
input_type_m <<
"\",\n";
806 ss <<
" \"density_component\": {\n";
808 ss <<
" \"value\":[";
809 if (this->lpdf_vec.
size() == 0) {
812 for (
size_t i = 0; i < this->lpdf_vec.
size() - 1; i++) {
819 ss <<
" \"expected_values\":[";
820 if (this->expected_values.
size() == 0) {
823 for (
size_t i = 0; i < this->expected_values.
size() - 1; i++) {
828 this->expected_values[this->expected_values.
size() - 1]
833 ss <<
" \"log_sd_values\":[";
834 if (this->log_sd.
size() == 0) {
837 for (R_xlen_t i = 0; i < static_cast<R_xlen_t>(this->log_sd.
size()) - 1;
842 this->log_sd[this->log_sd.
size() - 1].final_value_m)
845 ss <<
" \"observed_values\":[";
846 if (this->observed_values.
size() == 0) {
849 for (
size_t i = 0; i < this->observed_values.
size() - 1; i++) {
850 ss << this->observed_values[i].final_value_m <<
", ";
852 ss << this->observed_values[this->observed_values.
size() - 1]
862 template <
typename Type>
863 bool add_to_fims_tmb_internal() {
864 std::shared_ptr<fims_info::Information<Type>> info =
867 std::shared_ptr<fims_distributions::LogNormalLPDF<Type>> distribution =
868 std::make_shared<fims_distributions::LogNormalLPDF<Type>>();
871 distribution->id = this->
id_m;
872 std::stringstream ss;
875 distribution->key.resize(this->
key_m->size());
876 for (
size_t i = 0; i < this->
key_m->size(); i++) {
877 distribution->key[i] = this->
key_m->at(i);
879 distribution->observed_values.resize(this->observed_values.
size());
880 for (
size_t i = 0; i < this->observed_values.
size(); i++) {
881 distribution->observed_values[i] =
882 this->observed_values[i].initial_value_m;
885 distribution->expected_values.
resize(this->expected_values.
size());
886 for (
size_t i = 0; i < this->expected_values.
size(); i++) {
887 distribution->expected_values[i] =
888 this->expected_values[i].initial_value_m;
890 distribution->log_sd.
resize(this->log_sd.
size());
891 for (
size_t i = 0; i < this->log_sd.
size(); i++) {
892 distribution->log_sd[i] = this->log_sd[i].initial_value_m;
893 if (this->log_sd[i].estimation_type_m.
get() ==
"fixed_effects") {
895 ss <<
"dlnorm." << this->
id_m <<
".log_sd." << this->log_sd[i].
id_m;
896 info->RegisterParameterName(ss.str());
897 info->RegisterParameter(distribution->log_sd[i]);
899 if (this->log_sd[i].estimation_type_m.
get() ==
"random_effects") {
900 FIMS_ERROR_LOG(
"standard deviations cannot be set to random effects");
903 info->variable_map[this->log_sd.
id_m] = &(distribution)->
log_sd;
905 info->density_components[distribution->id] = distribution;
915 this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
916 this->add_to_fims_tmb_internal<TMBAD_FIMS_TYPE>();
962 std::make_shared<DmultinomDistributionsInterface>(*
this);
1008 Rcpp::IntegerVector ids) {
1010 this->
key_m->resize(ids.size());
1011 for (R_xlen_t i = 0; i < ids.size(); i++) {
1012 this->
key_m->at(i) = ids[i];
1035 dmultinom.
observed_values[i] = this->observed_values[i].initial_value_m;
1038 dmultinom.
expected_values[i] = this->expected_values[i].initial_value_m;
1041 dmultinom.
dims[0] = this->dims[0];
1042 dmultinom.
dims[1] = this->dims[1];
1050 fims::to_string(this->
id_m) +
1051 " has been finalized already.");
1056 std::shared_ptr<fims_info::Information<double>> info =
1066 " not found in Information.");
1069 std::shared_ptr<fims_distributions::MultinomialLPMF<double>> dmultinom =
1070 std::dynamic_pointer_cast<
1075 size_t n_x = dmultinom->lpdf_vec.size();
1076 this->lpdf_vec = Rcpp::NumericVector(n_x);
1077 if (this->expected_values.
size() != n_x) {
1078 this->expected_values.
resize(n_x);
1080 if (this->observed_values.
size() != n_x) {
1081 this->observed_values.
resize(n_x);
1083 for (
size_t i = 0; i < this->lpdf_vec.
size(); i++) {
1084 this->lpdf_vec[i] = dmultinom->lpdf_vec[i];
1085 this->expected_values[i].final_value_m = dmultinom->get_expected(i);
1086 if (dmultinom->input_type !=
"data") {
1087 this->observed_values[i].final_value_m = dmultinom->get_observed(i);
1090 if (dmultinom->input_type ==
"data") {
1092 dims[0] = dmultinom->dims[0];
1093 dims[1] = dmultinom->dims[1];
1094 for (
size_t i = 0; i <
dims[0]; i++) {
1095 for (
size_t j = 0; j <
dims[1]; j++) {
1096 size_t idx = (i *
dims[1]) + j;
1097 this->observed_values[idx].final_value_m = dmultinom->get_observed(
1098 static_cast<size_t>(i),
static_cast<size_t>(j));
1113 std::stringstream ss;
1116 ss <<
" \"module_name\": \"density\",\n";
1117 ss <<
" \"module_id\": " << this->
id_m <<
",\n";
1118 ss <<
" \"module_type\": \"multinomial\",\n";
1121 ss <<
" \"input_type\" : \"" << this->
input_type_m <<
"\",\n";
1122 ss <<
" \"density_component\": {\n";
1124 ss <<
" \"value\":[";
1125 if (this->lpdf_vec.
size() == 0) {
1128 for (
size_t i = 0; i < this->lpdf_vec.
size() - 1; i++) {
1136 ss <<
" \"expected_values\":[";
1137 if (this->expected_values.
size() == 0) {
1140 for (
size_t i = 0; i < this->expected_values.
size() - 1; i++) {
1145 this->expected_values[this->expected_values.
size() - 1]
1151 ss <<
" \"observed_values\":[";
1152 if (this->observed_values.
size() == 0) {
1155 for (
size_t i = 0; i < this->observed_values.
size() - 1; i++) {
1156 ss << this->observed_values[i].final_value_m <<
", ";
1158 ss << this->observed_values[this->observed_values.
size() - 1]
1168 template <
typename Type>
1169 bool add_to_fims_tmb_internal() {
1170 std::shared_ptr<fims_info::Information<Type>> info =
1173 std::shared_ptr<fims_distributions::MultinomialLPMF<Type>> distribution =
1174 std::make_shared<fims_distributions::MultinomialLPMF<Type>>();
1176 distribution->id = this->
id_m;
1179 distribution->key.resize(this->
key_m->size());
1180 for (
size_t i = 0; i < this->
key_m->size(); i++) {
1181 distribution->key[i] = this->
key_m->at(i);
1183 distribution->observed_values.resize(this->observed_values.
size());
1184 for (
size_t i = 0; i < this->observed_values.
size(); i++) {
1185 distribution->observed_values[i] =
1186 this->observed_values[i].initial_value_m;
1189 distribution->expected_values.
resize(this->expected_values.
size());
1190 for (
size_t i = 0; i < this->expected_values.
size(); i++) {
1191 distribution->expected_values[i] =
1192 this->expected_values[i].initial_value_m;
1195 info->density_components[distribution->id] = distribution;
1200 this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
1201 this->add_to_fims_tmb_internal<TMBAD_FIMS_TYPE>();
Rcpp interface that serves as the parent class for Rcpp distribution interfaces. This type should be ...
Definition rcpp_distribution.hpp:24
virtual bool set_observed_data(int observed_data_id)
Set the unique ID for the observed data object.
Definition rcpp_distribution.hpp:159
double lpdf_value
The log probability density function value.
Definition rcpp_distribution.hpp:81
virtual ~DistributionsInterfaceBase()
The destructor.
Definition rcpp_distribution.hpp:108
virtual double evaluate()=0
A method for each child distribution interface object to inherit so each distribution can have an eva...
std::string parameters_to_json(const std::vector< std::pair< std::string, VariableVector * > > ¶meters)
Writes the parameters of a distribution as a JSON "parameters" member, in the same shape the modules ...
Definition rcpp_distribution.hpp:182
std::string linked_ids_to_json()
Writes the ids of the vectors this distribution is linked to as a JSON "linked_ids" member.
Definition rcpp_distribution.hpp:225
std::shared_ptr< std::vector< uint32_t > > key_m
The unique ID for the variable map that points to a fims::Vector.
Definition rcpp_distribution.hpp:37
DistributionsInterfaceBase(const DistributionsInterfaceBase &other)
Construct a new Distributions Interface Base object.
Definition rcpp_distribution.hpp:98
uint32_t id_m
The local ID of the DistributionsInterfaceBase object.
Definition rcpp_distribution.hpp:33
virtual uint32_t get_id()=0
Get the ID for the child distribution interface objects to inherit.
SharedString use_mean_m
Control flag indicating whether to use the expected mean in the distribution calculations.
Definition rcpp_distribution.hpp:65
SharedInt interface_observed_data_id_m
The ID of the observed data object, which is set to -999.
Definition rcpp_distribution.hpp:76
virtual bool set_distribution_mean(double input_value)
Set the expected mean value for the distribution.
Definition rcpp_distribution.hpp:151
virtual bool set_distribution_links(std::string input_type, Rcpp::IntegerVector ids)
Sets pointers for data observations, random effects, or priors.
Definition rcpp_distribution.hpp:123
static uint32_t id_g
The static ID of the DistributionsInterfaceBase object.
Definition rcpp_distribution.hpp:29
static std::map< uint32_t, std::shared_ptr< DistributionsInterfaceBase > > live_objects
The map associating the ID of the DistributionsInterfaceBase to the DistributionsInterfaceBase object...
Definition rcpp_distribution.hpp:72
SharedString input_type_m
The type of density input. The options are prior, re, or data.
Definition rcpp_distribution.hpp:41
DistributionsInterfaceBase()
The constructor.
Definition rcpp_distribution.hpp:85
The Rcpp interface for Dlnorm to instantiate from R: dlnorm_ <- methods::new(DlnormDistribution).
Definition rcpp_distribution.hpp:605
virtual bool set_distribution_links(std::string input_type, Rcpp::IntegerVector ids)
Sets pointers for data observations, random effects, or priors.
Definition rcpp_distribution.hpp:680
DlnormDistributionsInterface(const DlnormDistributionsInterface &other)
Construct a new Dlnorm Distributions Interface object.
Definition rcpp_distribution.hpp:645
DlnormDistributionsInterface()
The constructor.
Definition rcpp_distribution.hpp:633
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_distribution.hpp:794
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_distribution.hpp:661
VariableVector log_sd
The uncertainty, which would be the natural logarithm of the standard deviation (sd) of log(x) for th...
Definition rcpp_distribution.hpp:623
virtual double evaluate()
Evaluate lognormal probability density function (pdf). The natural log of the pdf is returned.
Definition rcpp_distribution.hpp:696
virtual bool set_observed_data(int observed_data_id)
Set the unique ID for the observed data object.
Definition rcpp_distribution.hpp:667
virtual void finalize()
Extracts the derived quantities from Information to the Rcpp object.
Definition rcpp_distribution.hpp:718
VariableVector expected_values
The expected values, which would be the mean of log(x) for this distribution.
Definition rcpp_distribution.hpp:615
virtual ~DlnormDistributionsInterface()
The destructor.
Definition rcpp_distribution.hpp:655
VariableVector observed_values
Observed data.
Definition rcpp_distribution.hpp:610
RealVector lpdf_vec
Vector that records the individual log probability function for each observation.
Definition rcpp_distribution.hpp:628
The Rcpp interface for Dmultinom to instantiate from R: dmultinom_ <- methods::new(DmultinomDistribut...
Definition rcpp_distribution.hpp:928
virtual bool set_distribution_links(std::string input_type, Rcpp::IntegerVector ids)
Sets pointers for data observations, random effects, or priors.
Definition rcpp_distribution.hpp:1007
SharedString notes
TODO: document this.
Definition rcpp_distribution.hpp:955
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_distribution.hpp:988
void finalize()
Extracts derived quantities back to the Rcpp interface object from the Information object.
Definition rcpp_distribution.hpp:1046
virtual double evaluate()
Definition rcpp_distribution.hpp:1029
void set_note(std::string note)
Set the note object.
Definition rcpp_distribution.hpp:1022
virtual bool set_observed_data(int observed_data_id)
Set the unique ID for the observed data object.
Definition rcpp_distribution.hpp:994
VariableVector expected_values
The expected values, which should be a vector of length K where each value specifies the probability ...
Definition rcpp_distribution.hpp:939
RealVector dims
The dimensions of the number of rows and columns of the multivariate dataset.
Definition rcpp_distribution.hpp:944
DmultinomDistributionsInterface()
The constructor.
Definition rcpp_distribution.hpp:960
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_distribution.hpp:1112
RealVector lpdf_vec
Vector that records the individual log probability function for each observation.
Definition rcpp_distribution.hpp:949
DmultinomDistributionsInterface(const DmultinomDistributionsInterface &other)
Construct a new Dmultinom Distributions Interface object.
Definition rcpp_distribution.hpp:972
VariableVector observed_values
Observed data, which should be a vector of length K of integers.
Definition rcpp_distribution.hpp:933
virtual ~DmultinomDistributionsInterface()
The destructor.
Definition rcpp_distribution.hpp:983
The Rcpp interface for Dnorm to instantiate from R: dnorm_ <- methods::new(DnormDistribution).
Definition rcpp_distribution.hpp:240
DnormDistributionsInterface(const DnormDistributionsInterface &other)
Construct a new Dnorm Distributions Interface object.
Definition rcpp_distribution.hpp:282
DnormDistributionsInterface()
The constructor.
Definition rcpp_distribution.hpp:270
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_distribution.hpp:452
virtual ~DnormDistributionsInterface()
The destructor.
Definition rcpp_distribution.hpp:293
RealVector lpdf_vec
Vector that records the individual log probability function for each observation.
Definition rcpp_distribution.hpp:265
virtual double evaluate()
Evaluate normal probability density function (pdf). The natural log of the pdf is returned.
Definition rcpp_distribution.hpp:339
VariableVector observed_values
Observed data.
Definition rcpp_distribution.hpp:245
VariableVector expected_values
The expected values, which would be the mean of x for this distribution.
Definition rcpp_distribution.hpp:250
virtual void finalize()
Extracts the derived quantities from Information to the Rcpp object.
Definition rcpp_distribution.hpp:365
VariableVector log_sd
The uncertainty, which would be the standard deviation of x for the normal distribution.
Definition rcpp_distribution.hpp:260
virtual bool set_observed_data(int observed_data_id)
Set the unique ID for the observed data object.
Definition rcpp_distribution.hpp:305
virtual bool set_distribution_mean(double input_value)
Set the expected mean value for the distribution.
Definition rcpp_distribution.hpp:313
virtual bool set_distribution_links(std::string input_type, Rcpp::IntegerVector ids)
Sets pointers for data observations, random effects, or priors.
Definition rcpp_distribution.hpp:323
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_distribution.hpp:299
VariableVector expected_mean
The expected mean, which would be the mean of x for this distribution.
Definition rcpp_distribution.hpp:255
Base class for all interface objects.
Definition rcpp_interface_base.hpp:655
bool finalized
Is the object already finalized? The default is false.
Definition rcpp_interface_base.hpp:660
std::string value_to_string(double value)
Report the variable value as a string.
Definition rcpp_interface_base.hpp:696
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:665
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:670
An Rcpp interface class that defines the RealVector class.
Definition rcpp_interface_base.hpp:431
size_t size()
Returns the size of a RealVector.
Definition rcpp_interface_base.hpp:602
void resize(size_t size)
Resizes a RealVector to the desired length.
Definition rcpp_interface_base.hpp:609
A class that provides shared ownership of an integer value.
Definition rcpp_shared_primitive.hpp:29
void set(int val)
Change the value of the integer.
Definition rcpp_shared_primitive.hpp:134
A class that provides shared ownership of a string.
Definition rcpp_shared_primitive.hpp:1513
std::string get() const
Retrieves the string value managed by the object.
Definition rcpp_shared_primitive.hpp:1617
void set(std::string val)
Sets the string value of the object.
Definition rcpp_shared_primitive.hpp:1626
An Rcpp interface class that defines the VariableVector class.
Definition rcpp_interface_base.hpp:143
Variable & get(size_t pos)
An internal accessor for calling a position of a VariableVector from R.
Definition rcpp_interface_base.hpp:266
uint32_t id_m
The local ID of the Variable object.
Definition rcpp_interface_base.hpp:156
void set(size_t pos, const Variable &p)
An internal setter for setting a position of a VariableVector from R.
Definition rcpp_interface_base.hpp:282
void resize(size_t size)
Resizes a VariableVector to the desired length.
Definition rcpp_interface_base.hpp:294
size_t size()
Returns the size of a VariableVector.
Definition rcpp_interface_base.hpp:287
void resize(size_t s)
Changes the number of elements stored.
Definition fims_vector.hpp:401
#define FIMS_WARNING_LOG(MESSAGE)
Definition def.hpp:648
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:664
The Rcpp interface to declare objects that are used ubiquitously throughout the Rcpp interface,...
double sanitize_val(double x)
Sanitize a double value by replacing NaN or Inf with -999.0.
Definition rcpp_interface_base.hpp:112
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 > observed_values
Input value of distribution function for priors or random effects.
Definition density_components_base.hpp:61
Type lpdf
Total log probability density contribution of the distribution.
Definition density_components_base.hpp:180
fims::Vector< Type > expected_values
Expected value vector for prior-based pathways.
Definition density_components_base.hpp:44
fims::Vector< Type > expected_mean
The expected mean of the distribution; overrides expected values.
Definition density_components_base.hpp:66
Implements the LogNormalLPDF distribution functor used by FIMS to evaluate observation-level and tota...
Definition lognormal_lpdf.hpp:34
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:41
virtual const Type evaluate()
Evaluates the lognormal log probability density function.
Definition lognormal_lpdf.hpp:62
Implements the MultinomialLPMF distribution functor used by FIMS to evaluate the observation-level an...
Definition multinomial_lpmf.hpp:36
virtual const Type evaluate()
Evaluates the multinomial log probability mass function.
Definition multinomial_lpmf.hpp:62
fims::Vector< size_t > dims
Dimensions of the number of rows and columns of the multivariate dataset.
Definition multinomial_lpmf.hpp:41
Implements the NormalLPDF distribution functor used by FIMS to evaluate observation-level and total l...
Definition normal_lpdf.hpp:32
fims::Vector< Type > log_sd
The natural log of the standard deviation of the distribution. The argument can be a vector or scalar...
Definition normal_lpdf.hpp:39
virtual const Type evaluate()
Evaluates the normal log probability density function.
Definition normal_lpdf.hpp:59