fit_sqn: Fitting the sqn functions

View source: R/sqn.R

fit_sqnR Documentation

Fitting the sqn functions

Description

Functions for fitting and sampling from sqn distribution

Usage

fit_sqn(p, q, tol = .Machine$double.eps^2)

approx_sqn(
  q,
  p = NULL,
  thin = FALSE,
  n_grid = 1000,
  s_grid = 2L,
  tol = .Machine$double.eps^2
)

is_sqn_valid(a, n_grid = 50L, s_grid = 2L)

Arguments

p

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

q

vector of quantile values (data)

tol

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

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.

a

vector of a-coefficient parameters of sqn distribution

Details

fit_sqn is for fitting the sqn function to the set of QP values. Number of sqn terms will match the number of QP pairs. approx_sqn is for approximating sqn function to the set of data. is_sqn_valid is a function for checking if the sqn is valid

Examples

p <- c(0.1, 0.5, 0.6, 0.9)
q <- c(4, 9, 10, 13)
a <- fit_sqn(p,q)
x <- rsqn(100, a)
approx_sqn(x)
a <- c(9,  1.8, -1.13, 9)
is_sqn_valid(a)

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