loglikLambertWutils  R Documentation 
Evaluates the loglikelihood for θ given observations y
.
loglik_LambertW
computes the loglikelihood of θ
for a Lambert W \times F distribution given observations y
.
loglik_input
computes the loglikelihood of various distributions for
the parameter \boldsymbol β given the data x
. This can be
used independently of the Lambert W x F framework to compute
the loglikelihood of parameters for common distributions.
loglik_penalty
computes the penalty for transforming the
data back to the input (see Goerg 2016). This penalty is independent of
the distribution specified by distname
, but only depends on
τ. If type = "s"
then the penalty term exists if the
distribution is nonnegative (see get_distname_family
) and
gamma >= 0
; otherwise, it returns NA
.
loglik_LambertW( theta, y, distname, type, return.negative = FALSE, flattened.theta.names = names(theta), use.mean.variance = TRUE ) loglik_input( beta, x, distname, dX = NULL, log.dX = function(x, beta) log(dX(x, beta)) ) loglik_penalty(tau, y, type = c("h", "hh", "s"), is.non.negative = FALSE)
theta 
list; a (possibly incomplete) list of parameters 
y 
a numeric vector of real values (the observed data). 
distname 
character; name of input distribution; see

type 
type of Lambert W \times F distribution: skewed 
return.negative 
logical; if 
flattened.theta.names 
vector of strings with names of flattened

use.mean.variance 
logical; if 
beta 
numeric vector (deprecated); parameter \boldsymbol β of
the input distribution. See 
x 
a numeric vector of real values (the input data). 
dX 
optional; density function of 
log.dX 
optional; a function that returns the logarithm of the density
function of 
tau 
named vector τ which defines the variable transformation.
Must have at least 
is.non.negative 
logical; by default it is set to 
For heavytail Lambert W\times F distributions (type = "h"
or
type = "hh"
) the loglikelihood decomposes into an input
loglikelihood plus a penalty term for transforming the data.
For skewed Lambert W \times F distributions this decomposition only
exists for nonnegative input RVs (e.g., "exp"
onential,
"gamma"
, "f"
, ...). If negative values are possible
("normal"
, "t"
, "unif"
, "cauchy"
, ...)
then loglik_input
and loglik_penalty
return NA
, but
the value of the output loglikelihood will still be returned correctly
as loglik.LambertW
.
See Goerg (2016) for details on the decomposition of the loglikelihood into a loglikelihood on the input parameters plus a penalty term for transforming the data.
loglik_input
and loglik_penalty
return a scalar;
loglik_LambertW
returns a list with 3 values:
loglik.input 
loglikelihood of 
loglik.penalty 
penalty for transforming the data, 
loglik.LambertW 
total loglikelihood of 
set.seed(1) yy < rLambertW(n = 1000, distname = "normal", theta = list(beta = c(0, 1), delta = 0.2)) loglik_penalty(tau = theta2tau(list(beta = c(1, 1), delta = c(0.2, 0.2)), distname = "normal"), y = yy, type = "hh") # For a type = 's' Lambert W x F distribution with location family input # such a decomposition doesn't exist; thus NA. loglik_penalty(tau = theta2tau(list(beta = c(1, 1), gamma = 0.03), distname = "normal"), is.non.negative = FALSE, y = yy, type = "s") # For scalefamily input it does exist loglik_penalty(tau = theta2tau(list(beta = 1, gamma = 0.01), distname = "exp"), is.non.negative = TRUE, y = yy, type = "s") # evaluating the Gaussian loglikelihood loglik_input(beta = c(0, 1), x = yy, distname = "normal") # builtin version # or pass your own log pdf function loglik_input(beta = c(0, 1), x = yy, distname = "user", log.dX = function(xx, beta = beta) { dnorm(xx, mean = beta[1], sd = beta[2], log = TRUE) }) ## Not run: # you must specify distname = 'user'; otherwise it does not work loglik_input(beta = c(0, 1), x = yy, distname = "mydist", log.dX = function(xx, beta = beta) { dnorm(xx, mean = beta[1], sd = beta[2], log = TRUE) }) ## End(Not run) ### loglik_LambertW returns all three values loglik_LambertW(theta = list(beta = c(1, 1), delta = c(0.09, 0.07)), y = yy, type = "hh", distname ="normal") # can also take a flattend vector; must provide names though for delta loglik_LambertW(theta = flatten_theta(list(beta = c(1, 1), delta = c(delta_l = 0.09, delta_r = 0.07))), y = yy, type = "hh", distname ="normal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.