fdsa: Finite difference stochastic approximation inference

View source: R/fdsa.R

fdsaR Documentation

Finite difference stochastic approximation inference

Description

Finite difference stochastic approximation (FDSA) inference for the g-and-k or g-and-h distribution

Usage

fdsa(
  x,
  N,
  model = c("gk", "generalised_gh", "tukey_gh", "gh"),
  logB = FALSE,
  theta0,
  batch_size = 100,
  alpha = 1,
  gamma = 0.49,
  a0 = 1,
  c0 = NULL,
  A = 100,
  theta_min = c(-Inf, ifelse(logB, -Inf, 1e-05), -Inf, 1e-05),
  theta_max = c(Inf, Inf, Inf, Inf),
  silent = FALSE,
  plotEvery = 100
)

Arguments

x

Vector of observations.

N

number of iterations to perform.

model

Which model to check: "gk", "generalised_gh" or "tukey_gh". For backwards compatibility, "gh" acts the same as "generalised_gh".

logB

When true, the second parameter is log(B) rather than B.

theta0

Vector of initial value for 4 parameters.

batch_size

Mini-batch size.

alpha

Gain decay for step size.

gamma

Gain decay for finite difference.

a0

Multiplicative step size tuning parameter (or vector of 4 values).

c0

Multiplicative finite difference step tuning parameter (or vector of 4 values).

A

Additive step size tuning parameter.

theta_min

Vector of minimum values for each parameter. Note: for model=="tukey_gh" it's usually advisable to rule out h=0 as this case sometimes causes optimisation problems.

theta_max

Vector of maximum values for each parameter.

silent

When FALSE (the default) a progress bar and intermediate results plots are shown.

plotEvery

How often to plot the results if silent==FALSE.

Details

fdsa performs maximum likelihood inference for iid data from a g-and-k or g-and-h distribution, using simulataneous perturbation stochastic approximation. This should be faster than directly maximising the likelihood.

Value

Matrix whose rows are FDSA states: the initial state theta0 and N subsequent states. The final row is the MLE estimate.

References

D. Prangle gk: An R package for the g-and-k and generalised g-and-h distributions, 2017.

Examples

set.seed(1)
x = rgk(10, A=3, B=1, g=2, k=0.5) ##An unusually small dataset for fast execution of this example
out = fdsa(x, N=100, theta0=c(mean(x),sd(x),0,1E-5), theta_min=c(-5,1E-5,-5,1E-5),
    theta_max=c(5,5,5,5))

gk documentation built on Aug. 10, 2023, 5:06 p.m.

Related to fdsa in gk...