dtgin {ginormal} | R Documentation |
Density for the generalized inverse normal distribution truncated to the positive or negative reals
dtgin(
z,
alpha,
mu,
tau,
sign = TRUE,
log = TRUE,
quasi = FALSE,
method = "Fortran"
)
z |
quantile. |
alpha |
degrees-of-freedom parameter. |
mu |
similar to location parameter, controls asymmetry of the distribution. |
tau |
similar to scale parameter, controls spread of the distribution. |
sign |
logical. |
log |
logical; should the log of the density be returned? Defaults to TRUE. |
quasi |
logical; should the quasi-density value be returned? Defaults to FALSE. |
method |
string with the method used to compute the parabolic cylinder function
in the normalization constant. |
Currently, only scalars are supported for the quantile and parameter values.
Density is supported on the positive reals (z
> 0) when sign = TRUE
and to
negative reals (z
< 0) when sign = FALSE
. mu
can take any value
in (-\infty, \infty)
. Density is only defined for parameter values
alpha
> 1 or tau
> 0, so it is set to 0 outside of these values.
The quasi-density or kernel is the density without the normalization constant,
use quasi = TRUE
for this behavior.
Numeric scalar with density.
# Computing (log) truncated densities
dtgin(z = 1, alpha = 3, mu = 1, tau = 1, sign = TRUE, log = TRUE, quasi = FALSE)
dtgin(z = -1, alpha = 3, mu = -1, tau = 1, sign = FALSE, log = TRUE, quasi = FALSE)
# Generalized inverse normal density with alpha = 5, mu = 0, tau = 1
n_values <- 200
z_vals <- seq(-5, 5, length.out = n_values)
# Truncated to positive reals (z > 0)
fz_p <- sapply(z_vals[z_vals > 0], function(z) dtgin(z, 5, 0, 1, TRUE, FALSE))
fz_p <- c(rep(0, n_values - sum(z_vals > 0)), fz_p)
plot(z_vals, fz_p, type = "l", xlab = 'Values', ylab = 'Density')
# Truncated to positive reals (z < 0)
fz_n <- sapply(z_vals[z_vals < 0], function(z) dtgin(z, 5, 0, 1, FALSE, FALSE))
fz_n <- c(fz_n, rep(0, n_values - sum(z_vals < 0)))
plot(z_vals, fz_n, type = "l", xlab = 'Values', ylab = 'Density')
# Both truncated densities together
plot(z_vals, fz_p, type = "l", xlab = 'Values', ylab = 'Density')
lines(z_vals, fz_n, col = 'blue', lty = 2)
legend('topright', legend = c('z > 0', 'z < 0'),
col = c('black', 'blue'), lty = 1:2)