theta-utils | R Documentation |
\times
F distributionsThese functions work with \boldsymbol \theta = (\boldsymbol \beta, \gamma, \delta, \alpha)
,
which fully parametrizes Lambert W\times
F distributions.
See Details for more background information on some functions.
check_theta
checks if \theta = (\alpha, \boldsymbol \beta, \gamma, \delta)
describes a well-defined Lambert W distribution.
complete_theta
completes missing values in a parameters list so users
don't have to specify everything in detail. If not supplied, then
alpha = 1
, gamma = 0
, and delta = 0
will be set by default.
flatten_theta
and unflatten_theta
convert between the list
theta
and its vector-style flattened type. The flattened version is required
for several optimization routines, since they optimize over multivariate vectors – not lists.
get_initial_theta
provides initial estimates for \alpha
,
\boldsymbol \beta
, \gamma
, and \delta
, which are then
used in maximum likelihood (ML) estimation (MLE_LambertW
).
get_theta_bounds
returns lower and upper bounds for \theta
(necessary for optimization such as MLE_LambertW
).
theta2tau
converts \theta
to the transformation vector
\tau = (\mu_x, \sigma_x, \gamma, \delta, \alpha)
.
theta2unbounded
transforms \theta
from the bounded space to an
unrestricted space (by \log
-transformation on
\sigma_x
, \delta
, and \alpha
; note that this restricts
\gamma \geq 0
, \delta \geq 0
, and \alpha \geq 0
.).
check_theta(theta, distname)
complete_theta(theta = list(), LambertW.input = NULL)
flatten_theta(theta)
get_initial_theta(
y,
distname,
type = c("h", "hh", "s"),
theta.fixed = list(alpha = 1),
method = c("Taylor", "IGMM"),
use.mean.variance = TRUE
)
get_theta_bounds(
distname,
beta,
type = c("s", "h", "hh"),
not.negative = FALSE
)
theta2tau(theta = list(beta = c(0, 1)), distname, use.mean.variance = TRUE)
theta2unbounded(theta, distname, type = c("h", "hh", "s"), inverse = FALSE)
unflatten_theta(theta.flattened, distname, type)
theta |
list; a (possibly incomplete) list of parameters |
distname |
character; name of input distribution; see
|
LambertW.input |
optional; if |
y |
a numeric vector of real values (the observed data). |
type |
type of Lambert W |
theta.fixed |
list; fixed parameters for the optimization; default:
|
method |
character; should a fast |
use.mean.variance |
logical; if |
beta |
numeric vector (deprecated); parameter |
not.negative |
logical; if |
inverse |
logical; if |
theta.flattened |
named vector; flattened version of list |
get_initial_theta
obtains a quick initial estimate of \theta
by
first finding the (approximate) input \widehat{\boldsymbol
x}_{\widehat{\theta}}
by IGMM
, and then estimating
\boldsymbol \beta
for this input data \widehat{\boldsymbol
x}_{\widehat{\theta}} \sim F_X(x \mid \boldsymbol \beta)
(see
estimate_beta
).
Converting theta
to an unbounded space is especially useful
for optimization routines (like nlm
), which can be
performed over an unconstrained space. The obtained optimum can be
converted back to the original space using the inverse transformation
(set inverse = TRUE
transforms it via \exp
) – this
guarantees that the estimate satisfies non-negativity constraints (if
required). The main advantage is that this avoids using optimization
routines with boundary constraints – since they are much slower compared
to unconstrained optimization.
check_theta
throws an error if list theta
does not
define a proper Lambert W \times
F distribution;
does nothing otherwise.
complete_theta
returns a list containing:
alpha |
heavy tail exponent(s), |
beta |
named vector |
gamma |
skewness parameter, |
delta |
heavy-tail parameter(s). |
get_initial_theta
returns a list containing:
alpha |
heavy tail exponent; default: |
beta |
named vector |
gamma |
skewness parameter; if |
delta |
heavy-tail parameter;
estimated from |
get_theta_bounds
returns a list containing two vectors:
lower |
flattened vector of lower bounds for valid |
upper |
flattened vector of upper bounds for valid |
check_beta
estimate_beta
, get_initial_tau
beta2tau
## Not run:
check_theta(theta = list(beta = c(1, 1, -1)), distname = "t")
## End(Not run)
check_theta(theta = list(beta = c(1, 1)), distname = "normal") # ok
params <- list(beta = c(2, 1), delta = 0.3) # alpha and gamma are missing
complete_theta(params) # added default values
params <- list(beta = c(2, 1), delta = 0.3, alpha = c(1, 2))
params <- complete_theta(params)
check_theta(params, distname = 'normal')
###
x <- rnorm(1000)
get_initial_theta(x, distname = "normal", type = "h")
get_initial_theta(x, distname = "normal", type = "s")
# starting values for the skewed version of an exponential
y <- rLambertW(n = 1000, distname = "exp", theta=list(beta = 2, gamma = 0.1))
get_initial_theta(y, distname = "exp", type = "s")
# starting values for the heavy-tailed version of a Normal = Tukey's h
y <- rLambertW(n = 1000, distname="normal", theta=list(beta = c(2, 1), delta = 0.2))
get_initial_theta(y, distname = "normal", type = "h")#'
###
get_theta_bounds(type = "hh", distname = "normal", beta = c(0, 1))
###
theta.restr <- theta2unbounded(list(beta = c(-1, 0.1),
delta = c(0.2, 0.2)),
distname = "normal")
theta.restr
# returns again the beta and delta from above
theta2unbounded(theta.restr, inverse = TRUE, distname = "normal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.