50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


BayesLN (version 0.2.10)

LN_Quant: Bayesian estimate of the log-normal quantiles

Description

This function produces an estimate for the log-normal distribution quantile of fixed level quant.

Usage

LN_Quant(
  x,
  quant,
  method = "weak_inf",
  x_transf = TRUE,
  guess_s2 = NULL,
  CI = TRUE,
  alpha_CI = 0.05,
  type_CI = "two-sided",
  method_CI = "exact",
  rel_tol_CI = 1e-05,
  nrep_CI = 1e+06
)

Value

The function returns the prior parameters and their posterior values, summary statistics of the log-scale parameters and the estimate of the specified quantile: the posterior mean and variance are provided by default. Moreover, the user can control the computation of posterior intervals.

Arguments

x

Vector of data used to estimate the quantile.

quant

Number between 0 and 1 that indicates the quantile of interest.

method

String that indicates the prior setting to adopt. Choosing "weak_inf" a weakly informative prior setting is adopted, whereas selecting "optimal" the hyperparameters are fixed trough a numerical optimization algorithm aimed at minimizing the frequentist MSE.

x_transf

Logical. If TRUE, the x vector is assumed already log-transformed.

guess_s2

Specification of a guess for the variance if available. If not, the sample estimate is used.

CI

Logical. With the default choice TRUE, the posterior credibility interval is computed.

alpha_CI

Level of alpha that determines the credibility (1-alpha_CI) of the posterior interval.

type_CI

String that indicates the type of interval to compute: "two-sided" (default), "UCL" (i.e. Upper Credible Limit) for upper one-sided intervals or "LCL" (i.e. Lower Credible Limit) for lower one-sided intervals.

method_CI

String that indicates if the limits should be computed through the logSMNG quantile function qlSMNG (option "exact", default), or by randomly generating a sample ("simulation") using the function rlSMNG.

rel_tol_CI

Level of relative tolerance required for the integrate procedure or for the infinite sum. Default set to 1e-5.

nrep_CI

Number of simulations in case of method="simulation".

Details

The function allows to carry out Bayesian inference for the unconditional quantiles of a sample that is assumed log-normally distributed.

A generalized inverse Gaussian prior is assumed for the variance in the log scale σ2, whereas a flat improper prior is assumed for the mean in the log scale ξ.

Two alternative hyperparamters setting are implemented (choice controlled by the argument method): a weakly informative proposal and an optimal one.

Examples

Run this code
library(BayesLN)
data("EPA09")
# The optimization algorithm might require time:
# LN_Quant(x = EPA09, x_transf = FALSE, quant = 0.95, method = "optimal", CI = FALSE)
LN_Quant(x = EPA09, x_transf = FALSE, quant = 0.95, method = "weak_inf",
        alpha_CI = 0.05, type_CI = "UCL", nrep_CI = 1e3) # increase nrep_CI

Run the code above in your browser using DataLab