Dist | R Documentation |
Contains the probability density/mass function, and the link and inverse link functions for a probability distribution.
new()
Create a Dist object
Dist$new( name, pdf, rng, cdf = NULL, link, invlink, npar, parnames, parapprox = NULL, fixed = NULL, name_long = name, par_alt = NULL )
name
Name of distribution
pdf
Probability density/mass function of the distribution
(e.g. dnorm
for normal distribution).
rng
Random generator function of the distribution (e.g.
rnorm
for normal distribution).
cdf
Cumulative distribution function of the distribution
(e.g., pnorm
for normal distribution). This is used to compute
pseudo-residuals.
link
Named list of link functions for distribution parameters
invlink
Named list of inverse link functions for distribution parameters
npar
Number of parameters of the distribution
parnames
Character vector with name of each parameter
parapprox
Function that takes a sample and produces approximate values for the unknown parameters
fixed
Vector with element for each parameter which is TRUE if parameter is fixed
name_long
Long version of the name of the distribution, possibly more user-readable than name.
par_alt
Function that takes a vector of the distribution parameters as input and returns them in a different format. Only relevant for some distributions (e.g., MVN, where the SDs and correlations can be reformatted into a covariance matrix)
A new Dist object
name()
Return name of Dist object
Dist$name()
pdf()
Return pdf of Dist object
Dist$pdf()
cdf()
Return cdf of Dist object
Dist$cdf()
rng()
Return random generator function of Dist object
Dist$rng()
link()
Return link function of Dist object
Dist$link()
invlink()
Return inverse link function of Dist object
Dist$invlink()
npar()
Return number of parameters of Dist object
Dist$npar()
parnames()
Return names of parameters
Dist$parnames()
parapprox()
Return function that approximates parameters
Dist$parapprox()
fixed()
Return which parameters are fixed
Dist$fixed()
code()
Return code of Dist object
Dist$code()
name_long()
Human-readable name of Dist object
Dist$name_long()
set_npar()
Set number of parameters this distribution has
Dist$set_npar(new_npar)
new_npar
Number of parameters
set_parnames()
Set parameter names
Dist$set_parnames(new_parnames)
new_parnames
Parameter names
set_code()
Set distribution code
Dist$set_code(new_code)
new_code
Distribution code
pdf_apply()
Evaluate probability density/mass function
This method is used in the Dist$obs_probs() method. It is a wrapper around Dist$pdf(), which prepares the parameters and passes them to the function.
Dist$pdf_apply(x, par, log = FALSE)
x
Value at which the function should be evaluated
par
Vector of parameters. The entries should be named if they are not in the same order as expected by the R function. (E.g. shape/scale rather than shape/rate for gamma distribution.)
log
Logical. If TRUE, the log-density is returned. Default: FALSE.
Probability density/mass function evaluated at x for parameters par
rng_apply()
Random number generator
This method is a wrapper around Dist$rng(), which prepares the parameters and passes them to the function.
Dist$rng_apply(n, par)
n
Number of realisations to generate
par
Vector of parameters. The entries should be named if they are not in the same order as expected by the R function. (E.g. shape/scale rather than shape/rate for gamma distribution.)
Vector of n
realisations of this distribution
par_alt()
Alternative parameter formatting
Dist$par_alt(par)
par
Vector of distribution parameters
Formatted parameters
n2w()
Natural to working parameter transformation
This method transforms parameters from the natural scale (i.e., their domain of definition) to the "working" or "linear predictor" scale (i.e., the real line). It is a wrapper for Dist$link().
Dist$n2w(par)
par
List of parameters
Vector of parameters on the working scale
w2n()
Working to natural parameter transformation
This method transforms parameters from the "working" or "linear predictor" scale (i.e., the real line) to the natural scale (i.e., their domain of definition). It is a wrapper for Dist$invlink().
Dist$w2n(wpar, as_matrix = FALSE)
wpar
Vector of working parameters
as_matrix
Logical. If TRUE, the natural parameters are returned as a matrix with one row for each state and one column for each parameter. If FALSE, the natural parameters are returned as a list (default).
List or matrix of parameters on natural scale
clone()
The objects of this class are cloneable with this method.
Dist$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.