fit_metalog: Fitting the metalog functions

View source: R/metalog.R

fit_metalogR Documentation

Fitting the metalog functions

Description

Functions for fitting and sampling from metalog distribution

Usage

fit_metalog(
  p,
  q,
  bl = -Inf,
  bu = Inf,
  log.p = FALSE,
  tol = .Machine$double.eps^2
)

approx_metalog(
  q,
  nterms = 3L,
  bl = -Inf,
  bu = Inf,
  p = NULL,
  thin = FALSE,
  n_grid = 1000,
  s_grid = 2L,
  tol = .Machine$double.eps^2
)

approx_max_metalog(
  q,
  p = NULL,
  bl = -Inf,
  bu = Inf,
  max_nterms = Inf,
  thin = FALSE,
  n_grid = 1000,
  s_grid = 2L,
  tol = 1e-07
)

is_metalog_valid(a, bl = -Inf, bu = Inf, n_grid = 50L, s_grid = 2L)

Arguments

p

the grid of probability values the quantiles q correspond to. This would be specified if metalog is fitted to the empirical CDF. Default is NULL.

q

vector of quantile values (data)

bl

real value of lower boundary (for bounded metalog). Default -Inf

bu

real value of upper boundary (for bounded metalog). Default Inf

log.p

are probabilities provided on log scale. Default FALSE

tol

tolerance for solve() and qr.solve(), default is .Machine$double.eps^2

nterms

integer number of terms for approximating metalog. Default is 3

thin

logical. Should original data be thinned. Default is FALSE.

n_grid

in case data thinning is performed, integer number of quantiles to extract from data, if data vector q is longer than this value

s_grid

in case data thinning is performed, probability grid shape parameter passed to qpd::make_pgrid(). Default is 10.

max_nterms

Maximum number of terms to be used for fitting

a

vector of a-coefficient parameters of metalog distribution

Details

fit_metalog is for fitting the metalog function to the set of QP values. Number of metalog terms will match the number of QP pairs. approx_metalog is for approximating metalog function to the set of data. is_metalog_valid is a function for checking if the metalog is valid

Examples

p <- c(0.1, 0.5, 0.9)
q <- c(4, 9, 12)
fit_metalog(p,q)
a <- c(9,  1.8, -1.13)
is_metalog_valid(a)

dmi3kno/qpd documentation built on Sept. 29, 2024, 6:39 p.m.