|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_MATH_REGRESSION_FAMILY_H_
2 #define GENESIS_UTILS_MATH_REGRESSION_FAMILY_H_
85 std::function<double(
double mu )>
rectify;
127 return mu * (1.0 - mu);
132 double l = y * std::log(mu);
133 double r = (1.0 - y) * std::log(1.0 - mu);
136 l = ( std::isfinite(l) ? l : 0.0 );
137 r = ( std::isfinite(r) ? r : 0.0 );
141 family.
rectify = [](
double mu )
143 const double zero = 1.e-10;
144 const double one = 1.0 - 1.e-10;
148 }
else if( mu > one ) {
156 double l = y * std::log( y / mu );
157 double r = ( 1.0 - y ) * std::log(( 1.0 - y ) / ( 1.0 - mu ));
160 l = ( std::isfinite(l) ? l : 0.0 );
161 r = ( std::isfinite(r) ? r : 0.0 );
163 return 2.0 * ( l + r );
193 return y * std::log(mu) - mu;
195 family.
rectify = [](
double mu )
197 const double zero = 1.e-10;
208 return 2.0 * ( y * std::log( y / mu ) - ( y - mu ));
238 auto const x = y - mu;
241 family.
rectify = [](
double mu )
247 double const d = y - mu;
277 auto const x = y / mu;
279 return std::log(x) - x;
281 family.
rectify = [](
double mu )
287 double const f = y / mu;
289 return 2.0 * ( f - std::log( f ) - 1.0 );
301 #endif // include guard
GlmLink::Link canonical_link_id
Internal ID of the GlmLink, used to check if the link is the canonical one for a given distribution f...
bool is_defined(GlmFamily const &family)
Check whether all necessary values and functors of a GlmFamily are set.
GlmLink glm_link_identity()
Identity link functions.
bool is_canonical_link(GlmFamily const &family, GlmLink const &link)
Family
List of common GLM Families.
GlmFamily glm_family_poisson()
Poisson family functions.
std::function< GlmLink()> canonical_link
Get the canonical link function.
GlmLink glm_link_logit()
Logit link functions.
GlmLink glm_link_inverse()
Inverse link functions.
Link
List of common GLM Link functions.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
GlmFamily glm_family_gaussian()
Gaussian/normal family functions.
std::function< double(double mu)> rectify
Rectify to a valid value, for the fitted mean, to avoid extreme predictions.
Link id
Internal ID, used to check if the link is the canonical one for a distribution family.
GlmFamily glm_family_binomial()
Binomial family functions.
std::function< double(double y, double mu)> log_likelihood
Log-Likelihood contribution of a value. To be multiplied by prior weight.
std::function< double(double mu)> variance
Variance function for the distribution family.
GlmLink glm_link_log()
Log link functions.
GlmFamily glm_family_gamma()
Gamma family functions.
Family id
Internal ID of the GlmFamily, used to check for specific families where needed.
std::function< double(double y, double mu)> unit_deviance
Unit deviance for the distribution family.