|
TMB Documentation
v1.9.11
|
Probability distributions (discrete and continuous) for use in the likelihood function. More...
Files | |
| file | dnorm.hpp |
| Univariate normal density. | |
Functions | |
| template<class Type > | |
| Type | dbeta (Type x, Type shape1, Type shape2, int give_log) |
| Probability density function of the beta distribution. More... | |
| template<class Type > | |
| Type | dbinom (Type k, Type size, Type prob, int give_log=0) |
| Probability mass function of the binomial distribution. More... | |
| template<class Type > | |
| Type | dbinom_robust (Type k, Type size, Type logit_p, int give_log=0) |
| Density of binomial distribution parameterized via logit(prob) More... | |
| template<class T1 , class T2 , class T3 > | |
| T1 | dcompois (T1 x, T2 mode, T3 nu, int give_log=0) |
| Conway-Maxwell-Poisson. Calculate density. More... | |
| template<class T1 , class T2 , class T3 > | |
| T1 | dcompois2 (T1 x, T2 mean, T3 nu, int give_log=0) |
| Conway-Maxwell-Poisson. Calculate density parameterized via the mean. More... | |
| template<class Type > | |
| Type | df (Type x, Type df1, Type df2, int give_log) |
| Probability density function of the Fisher distribution. More... | |
| template<class Type > | |
| Type | dgamma (Type y, Type shape, Type scale, int give_log=0) |
| Density of X where X~gamma distributed. | |
| template<class Type > | |
| Type | dlgamma (Type y, Type shape, Type scale, int give_log=0) |
| Density of log(X) where X~gamma distributed. | |
| template<class Type > | |
| Type | dlogis (Type x, Type location, Type scale, int give_log) |
| Probability density function of the logistic distribution. More... | |
| template<class Type > | |
| Type | dmultinom (vector< Type > x, vector< Type > p, int give_log=0) |
| Probability mass function of the multinomial distribution. More... | |
| template<class Type > | |
| Type | dnbinom (const Type &x, const Type &size, const Type &prob, int give_log=0) |
| Negative binomial probability function.Parameterized through size and prob parameters, following R-convention. | |
| template<class Type > | |
| Type | dnbinom2 (const Type &x, const Type &mu, const Type &var, int give_log=0) |
| Negative binomial probability function.Alternative parameterization through mean and variance parameters. | |
| template<class Type > | |
| Type | dnbinom_robust (const Type &x, const Type &log_mu, const Type &log_var_minus_mu, int give_log=0) |
| Negative binomial probability function. More... | |
| template<class Type > | |
| Type | dnorm (Type x, Type mean, Type sd, int give_log=0) |
| Probability density function of the normal distribution. More... | |
| template<class Type > | |
| Type | dpois (const Type &x, const Type &lambda, int give_log=0) |
| Poisson probability function. | |
| template<class Type > | |
| Type | dsn (Type x, Type alpha, int give_log=0) |
| Probability density function of the skew-normal distribution. More... | |
| template<class Type > | |
| Type | dt (Type x, Type df, int give_log) |
| Probability density function of the Student t-distribution. More... | |
| template<class Type > | |
| Type | dtweedie (Type y, Type mu, Type phi, Type p, int give_log=0) |
| dtweedie function (same as dtweedie.series from R package 'tweedie'). More... | |
| template<class Type > | |
| Type | dzinbinom (const Type &x, const Type &size, const Type &p, const Type &zip, int give_log=0) |
| Zero-Inflated negative binomial probability function. More... | |
| template<class Type > | |
| Type | dzinbinom2 (const Type &x, const Type &mu, const Type &var, const Type &zip, int give_log=0) |
| Zero-Inflated negative binomial probability function. More... | |
| template<class Type > | |
| Type | dzipois (const Type &x, const Type &lambda, const Type &zip, int give_log=0) |
| Zero-Inflated Poisson probability function. More... | |
| template<class Type > | |
| Type | pbeta (Type q, Type shape1, Type shape2) |
| Distribution function of the beta distribution (following R argument convention). More... | |
| template<class Type > | |
| Type | pgamma (Type q, Type shape, Type scale=1.) |
| Distribution function of the gamma distribution (following R argument convention). | |
| template<class Type > | |
| Type | pnorm (Type q, Type mean=0., Type sd=1.) |
| Distribution function of the normal distribution (following R argument convention). | |
| template<class Type > | |
| Type | ppois (Type q, Type lambda) |
| Distribution function of the poisson distribution (following R argument convention). | |
| template<class Type > | |
| Type | qbeta (Type p, Type shape1, Type shape2) |
| Quantile function of the beta distribution (following R argument convention). More... | |
| template<class Type > | |
| Type | qgamma (Type q, Type shape, Type scale=1.) |
| Quantile function of the gamma distribution (following R argument convention). | |
| template<class Type > | |
| Type | qnorm (Type p, Type mean=0., Type sd=1.) |
| Quantile function of the normal distribution (following R argument convention). | |
Exponential distribution. | |
| template<class Type > | |
| Type | pexp (Type x, Type rate) |
| Cumulative distribution function of the exponential distribution. More... | |
| template<class Type > | |
| Type | dexp (Type x, Type rate, int give_log=0) |
| Probability density function of the exponential distribution. More... | |
| template<class Type > | |
| Type | qexp (Type p, Type rate) |
| Inverse cumulative distribution function of the exponential distribution. More... | |
Weibull distribution. | |
| template<class Type > | |
| Type | pweibull (Type x, Type shape, Type scale) |
| Cumulative distribution function of the Weibull distribution. More... | |
| template<class Type > | |
| Type | dweibull (Type x, Type shape, Type scale, int give_log=0) |
| Probability density function of the Weibull distribution. More... | |
| template<class Type > | |
| Type | qweibull (Type p, Type shape, Type scale) |
| Inverse cumulative distribution function of the Weibull distribution. More... | |
Sinh-asinh distribution. | |
| template<class Type > | |
| Type | dSHASHo (Type x, Type mu, Type sigma, Type nu, Type tau, int give_log=0) |
| Probability density function of the sinh-asinh distribution. More... | |
| template<class Type > | |
| Type | pSHASHo (Type q, Type mu, Type sigma, Type nu, Type tau, int give_log=0) |
| Cumulative distribution function of the sinh-asinh distribution. More... | |
| template<class Type > | |
| Type | qSHASHo (Type p, Type mu, Type sigma, Type nu, Type tau, int log_p=0) |
| Quantile function of the sinh-asinh distribution. More... | |
| template<class Type > | |
| Type | norm2SHASHo (Type x, Type mu, Type sigma, Type nu, Type tau, int log_p=0) |
| Transforms a normal variable into a sinh-asinh variable. More... | |
Probability distributions (discrete and continuous) for use in the likelihood function.
| Type dbeta | ( | Type | x, |
| Type | shape1, | ||
| Type | shape2, | ||
| int | give_log | ||
| ) |
Probability density function of the beta distribution.
| shape1 | First shape parameter. Must be strictly positive. |
| shape2 | Second shape parameter. Must be strictly positive. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 227 of file distributions_R.hpp.
| Type dbinom | ( | Type | k, |
| Type | size, | ||
| Type | prob, | ||
| int | give_log = 0 |
||
| ) |
Probability mass function of the binomial distribution.
| k | Number of successes. |
| size | Number of trials. |
| prob | Probability of success. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 183 of file distributions_R.hpp.
| Type dbinom_robust | ( | Type | k, |
| Type | size, | ||
| Type | logit_p, | ||
| int | give_log = 0 |
||
| ) |
Density of binomial distribution parameterized via logit(prob)
This version should be preferred when working on the logit scale as it is numerically stable for probabilities close to 0 or 1.
Definition at line 205 of file distributions_R.hpp.
| T1 dcompois | ( | T1 | x, |
| T2 | mode, | ||
| T3 | nu, | ||
| int | give_log = 0 |
||
| ) |
Conway-Maxwell-Poisson. Calculate density.
\[ P(X=x) \propto \frac{\lambda^x}{(x!)^\nu}\:,x=0,1,\ldots \]
Silently returns NaN if not within the valid parameter range:
\[ (0 \leq x) \land (0 < \lambda) \land (0 < \nu) \]
.
| x | Observation |
| mode | Approximate mode \( \lambda^\frac{1}{\nu} \) |
| nu | \( \nu \) |
Definition at line 627 of file distributions_R.hpp.
| T1 dcompois2 | ( | T1 | x, |
| T2 | mean, | ||
| T3 | nu, | ||
| int | give_log = 0 |
||
| ) |
Conway-Maxwell-Poisson. Calculate density parameterized via the mean.
Silently returns NaN if not within the valid parameter range:
\[ (0 \leq x) \land (0 < E[X]) \land (0 < \nu) \]
.
| x | Observation |
| mean | \( E[X] \) |
| nu | \( \nu \) |
Definition at line 647 of file distributions_R.hpp.
| Type dexp | ( | Type | x, |
| Type | rate, | ||
| int | give_log = 0 |
||
| ) |
Probability density function of the exponential distribution.
| rate | Rate parameter. Must be strictly positive. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 94 of file distributions_R.hpp.
| Type df | ( | Type | x, |
| Type | df1, | ||
| Type | df2, | ||
| int | give_log | ||
| ) |
Probability density function of the Fisher distribution.
| df1 | Degrees of freedom 1. |
| df2 | Degrees of freedom 2. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 246 of file distributions_R.hpp.
| Type dlogis | ( | Type | x, |
| Type | location, | ||
| Type | scale, | ||
| int | give_log | ||
| ) |
Probability density function of the logistic distribution.
| location | Location parameter. |
| scale | Scale parameter. Must be strictly positive. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 263 of file distributions_R.hpp.
Probability mass function of the multinomial distribution.
| x | Vector of length K of integers. |
| p | Vector of length K, specifying the probability for the K classes (note, unlike in R these must sum to 1). |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 312 of file distributions_R.hpp.
|
inline |
Negative binomial probability function.
More robust parameterization through \(log(\mu)\) and \(log(\sigma^2-\mu)\) parameters.
Definition at line 103 of file lgamma.hpp.
| Type dnorm | ( | Type | x, |
| Type | mean, | ||
| Type | sd, | ||
| int | give_log = 0 |
||
| ) |
Probability density function of the normal distribution.
| x | vector of observations |
| mean | mean of the normal distribution |
| sd | standard deviation of the normal distribution. must be strictly positive. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 17 of file dnorm.hpp.
Referenced by density::ARk_t< scalartype_ >::operator()().
| Type dSHASHo | ( | Type | x, |
| Type | mu, | ||
| Type | sigma, | ||
| Type | nu, | ||
| Type | tau, | ||
| int | give_log = 0 |
||
| ) |
Probability density function of the sinh-asinh distribution.
| mu | Location. |
| sigma | Scale. |
| nu | Skewness. |
| tau | Kurtosis. |
| give_log | true if one wants the log-probability, false otherwise. |
Notation adopted from R package "gamlss.dist".
Probability density given in (2) in Jones and Pewsey (2009) Biometrika (2009) 96 (4): 761-780.
It is not possible to call this function with nu a vector or tau a vector.
Definition at line 339 of file distributions_R.hpp.
| Type dsn | ( | Type | x, |
| Type | alpha, | ||
| int | give_log = 0 |
||
| ) |
Probability density function of the skew-normal distribution.
| alpha | Slant parameter. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 279 of file distributions_R.hpp.
| Type dt | ( | Type | x, |
| Type | df, | ||
| int | give_log | ||
| ) |
Probability density function of the Student t-distribution.
| df | Degree of freedom. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 295 of file distributions_R.hpp.
| Type dtweedie | ( | Type | y, |
| Type | mu, | ||
| Type | phi, | ||
| Type | p, | ||
| int | give_log = 0 |
||
| ) |
dtweedie function (same as dtweedie.series from R package 'tweedie').
Silently returns NaN if not within the valid parameter range:
\[ (0 \leq y) \land (0 < \mu) \land (0 < \phi) \land (1 < p) \land (p < 2) \]
.
This implementation can be used for both constant and variable y. However, note that the derivative wrt. y is hardcoded to return zero (!).
Definition at line 554 of file distributions_R.hpp.
| Type dweibull | ( | Type | x, |
| Type | shape, | ||
| Type | scale, | ||
| int | give_log = 0 |
||
| ) |
Probability density function of the Weibull distribution.
| shape | Shape parameter. Must be strictly positive. |
| scale | Scale parameter. Must be strictly positive. |
| give_log | true if one wants the log-probability, false otherwise. |
Definition at line 145 of file distributions_R.hpp.
|
inline |
Zero-Inflated negative binomial probability function.
Parameterized through size and prob parameters, following R-convention. No vectorized version is currently available.
| zip | is the probaility of having extra zeros |
Definition at line 175 of file lgamma.hpp.
|
inline |
Zero-Inflated negative binomial probability function.
Alternative parameterization through mean and variance parameters (conditional on not being an extra zero). No vectorized version is currently available.
| zip | is the probaility of having extra zeros |
Definition at line 192 of file lgamma.hpp.
|
inline |
Zero-Inflated Poisson probability function.
| zip | is the probaility of having extra zeros |
Definition at line 158 of file lgamma.hpp.
| Type norm2SHASHo | ( | Type | x, |
| Type | mu, | ||
| Type | sigma, | ||
| Type | nu, | ||
| Type | tau, | ||
| int | log_p = 0 |
||
| ) |
Transforms a normal variable into a sinh-asinh variable.
| mu | Location parameter of the result sinh-asinh distribution. |
| sigma | Scale parameter of the result sinh-asinh distribution. |
| nu | Skewness parameter of the result sinh-asinh distribution. |
| tau | Kurtosis parameter of the result sinh-asinh distribution. |
| log_p | true if p is log-probability, false otherwise. |
It is not possible to call this function with nu a vector or tau a vector.
Definition at line 417 of file distributions_R.hpp.
| Type pbeta | ( | Type | q, |
| Type | shape1, | ||
| Type | shape2 | ||
| ) |
Distribution function of the beta distribution (following R argument convention).
Definition at line 433 of file distributions_R.hpp.
| Type pexp | ( | Type | x, |
| Type | rate | ||
| ) |
Cumulative distribution function of the exponential distribution.
| rate | Rate parameter. Must be strictly positive. |
Definition at line 80 of file distributions_R.hpp.
| Type pSHASHo | ( | Type | q, |
| Type | mu, | ||
| Type | sigma, | ||
| Type | nu, | ||
| Type | tau, | ||
| int | give_log = 0 |
||
| ) |
Cumulative distribution function of the sinh-asinh distribution.
| mu | Location. |
| sigma | Scale. |
| nu | Skewness. |
| tau | Kurtosis. |
| give_log | true if one wants the log-probability, false otherwise. |
Notation adopted from R package "gamlss.dist".
It is not possible to call this function with nu a vector or tau a vector.
Definition at line 368 of file distributions_R.hpp.
| Type pweibull | ( | Type | x, |
| Type | shape, | ||
| Type | scale | ||
| ) |
Cumulative distribution function of the Weibull distribution.
| shape | Shape parameter. Must be strictly positive. |
| scale | Scale parameter. Must be strictly positive. |
Definition at line 130 of file distributions_R.hpp.
| Type qbeta | ( | Type | p, |
| Type | shape1, | ||
| Type | shape2 | ||
| ) |
Quantile function of the beta distribution (following R argument convention).
Definition at line 450 of file distributions_R.hpp.
| Type qexp | ( | Type | p, |
| Type | rate | ||
| ) |
Inverse cumulative distribution function of the exponential distribution.
| rate | Rate parameter. Must be strictly positive. |
Definition at line 110 of file distributions_R.hpp.
| Type qSHASHo | ( | Type | p, |
| Type | mu, | ||
| Type | sigma, | ||
| Type | nu, | ||
| Type | tau, | ||
| int | log_p = 0 |
||
| ) |
Quantile function of the sinh-asinh distribution.
| mu | Location. |
| sigma | Scale. |
| nu | Skewness. |
| tau | Kurtosis. |
| log_p | true if p is log-probability, false otherwise. |
Notation adopted from R package "gamlss.dist".
It is not possible to call this function with nu a vector or tau a vector.
Definition at line 396 of file distributions_R.hpp.
| Type qweibull | ( | Type | p, |
| Type | shape, | ||
| Type | scale | ||
| ) |
Inverse cumulative distribution function of the Weibull distribution.
| p | Probability ; must be between 0 and 1. |
| shape | Shape parameter. Must be strictly positive. |
| scale | Scale parameter. Must be strictly positive. |
Definition at line 163 of file distributions_R.hpp.