Rcpp interface that serves as the parent class for Rcpp distribution interfaces. This type should be inherited and not called from R directly.
More...
#include <rcpp_distribution.hpp>
|
|
| DistributionsInterfaceBase () |
| | The constructor.
|
| |
| | DistributionsInterfaceBase (const DistributionsInterfaceBase &other) |
| | Construct a new Distributions Interface Base object.
|
| |
|
virtual | ~DistributionsInterfaceBase () |
| | The destructor.
|
| |
| virtual uint32_t | get_id ()=0 |
| | Get the ID for the child distribution interface objects to inherit.
|
| |
| virtual bool | set_distribution_links (std::string input_type, Rcpp::IntegerVector ids) |
| | Sets pointers for data observations, random effects, or priors.
|
| |
| virtual bool | set_distribution_mean (double input_value) |
| | Set the expected mean value for the distribution.
|
| |
| virtual bool | set_observed_data (int observed_data_id) |
| | Set the unique ID for the observed data object.
|
| |
| virtual double | evaluate ()=0 |
| | A method for each child distribution interface object to inherit so each distribution can have an evaluate() function.
|
| |
| 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 use, so each element keeps its parameter id in the model output.
|
| |
| std::string | linked_ids_to_json () |
| | Writes the ids of the vectors this distribution is linked to as a JSON "linked_ids" member.
|
| |
| virtual bool | add_to_fims_tmb () |
| | A virtual method to inherit to add objects to the TMB model.
|
| |
| virtual void | finalize () |
| | Extracts derived quantities back to the Rcpp interface object from the Information object.
|
| |
| virtual std::string | to_json () |
| | Convert the data to json representation for the output.
|
| |
| std::string | value_to_string (double value) |
| | Report the variable value as a string.
|
| |
|
std::string | make_dimensions (uint32_t start, uint32_t end, uint32_t rep=1) |
| | Make a string of dimensions for the model.
|
| |
|
|
uint32_t | id_m |
| | The local ID of the DistributionsInterfaceBase object.
|
| |
|
std::shared_ptr< std::vector< uint32_t > > | key_m |
| | The unique ID for the variable map that points to a fims::Vector.
|
| |
|
SharedString | input_type_m |
| | The type of density input. The options are prior, re, or data.
|
| |
| SharedString | use_mean_m = fims::to_string("no") |
| | Control flag indicating whether to use the expected mean in the distribution calculations.
|
| |
|
SharedInt | interface_observed_data_id_m = -999 |
| | The ID of the observed data object, which is set to -999.
|
| |
|
double | lpdf_value = 0 |
| | The log probability density function value.
|
| |
|
bool | finalized = false |
| | Is the object already finalized? The default is false.
|
| |
Rcpp interface that serves as the parent class for Rcpp distribution interfaces. This type should be inherited and not called from R directly.
◆ DistributionsInterfaceBase()
Construct a new Distributions Interface Base object.
- Parameters
-
◆ evaluate()
| virtual double DistributionsInterfaceBase::evaluate |
( |
| ) |
|
|
pure virtual |
◆ get_id()
| virtual uint32_t DistributionsInterfaceBase::get_id |
( |
| ) |
|
|
pure virtual |
◆ linked_ids_to_json()
| std::string DistributionsInterfaceBase::linked_ids_to_json |
( |
| ) |
|
|
inline |
Writes the ids of the vectors this distribution is linked to as a JSON "linked_ids" member.
The first id is the vector the distribution applies to, e.g., recruitment deviations or a fleet's expected index, so its parameters can be reported under the module that owns that vector.
- Returns
- The JSON member followed by a comma and a newline.
◆ parameters_to_json()
| std::string DistributionsInterfaceBase::parameters_to_json |
( |
const std::vector< std::pair< std::string, VariableVector * > > & |
parameters | ) |
|
|
inline |
Writes the parameters of a distribution as a JSON "parameters" member, in the same shape the modules use, so each element keeps its parameter id in the model output.
Each distribution passes the parameter vectors it owns, e.g., {{"log_sd", &this->log_sd}}, so any process that uses the distribution reports its parameters, and a distribution with other parameters only needs to add them to its list. Empty vectors are skipped because the VariableVector stream operator does not handle a size of zero.
- Parameters
-
| parameters | Pairs of parameter names and pointers to the vectors. |
- Returns
- The JSON member followed by a comma and a newline, or an empty string when no vector has elements.
◆ set_distribution_links()
| virtual bool DistributionsInterfaceBase::set_distribution_links |
( |
std::string |
input_type, |
|
|
Rcpp::IntegerVector |
ids |
|
) |
| |
|
inlinevirtual |
◆ set_distribution_mean()
| virtual bool DistributionsInterfaceBase::set_distribution_mean |
( |
double |
input_value | ) |
|
|
inlinevirtual |
Set the expected mean value for the distribution.
This virtual function provides an interface for setting a fixed mean value for distribution objects. When overridden in derived classes, this method typically stores the provided mean value as a fixed effect parameter and marks the distribution to use the mean in its calculations.
The base class implementation returns false to indicate the operation is not supported. Derived classes that support mean specification should override this method to implement the actual functionality.
- Parameters
-
| input_value | The numeric value to set as the distribution's expected mean. This value will be treated as a fixed effect parameter (not estimated) in derived class implementations. |
- Returns
- bool Returns true if the mean was successfully set, false otherwise. The base class implementation always returns false to indicate the operation is not supported by default.
- See also
- DnormDistributionsInterface::set_distribution_mean for an example implementation that sets the mean as a fixed effect parameter.
Reimplemented in DnormDistributionsInterface.
◆ set_observed_data()
| virtual bool DistributionsInterfaceBase::set_observed_data |
( |
int |
observed_data_id | ) |
|
|
inlinevirtual |
◆ use_mean_m
Control flag indicating whether to use the expected mean in the distribution calculations.
This shared string member serves as a boolean flag (i.e., "yes" or "no") that determines whether the distribution should use the expected_mean vector or other expected values (e.g., from data or random effects) when computing the expected value in the likelihood calculations.
When set to "no" (default), the distribution uses expected values based on the input_type setting (data expected values for "data", random effects expected values for "random_effects", or standard expected values otherwise).
When set to "yes" (typically by calling set_distribution_mean()), the distribution overrides the default expected value source and uses the expected_mean vector instead. This is useful for setting a fixed mean value for the distribution that doesn't depend on other model components.
- See also
- set_distribution_mean() for the method that sets this flag to "yes".
-
DensityComponentBase::get_expected() in density_components_base.hpp for the implementation that checks this flag.
The documentation for this class was generated from the following files: