depfit: Dependence model fit

Description Usage Arguments Details Value See Also Examples

View source: R/htfit.R

Description

Bayesian semiparametrics are used to fit the Heffernan–Tawn model to time series. Options are available to impose a structure in time on the model.

Usage

1
2
3
4
depfit(ts, u.mar = 0, u.dep=u.mar,
    lapl = FALSE, method.mar=c("mle","mom","pwm"),  nlag = 1,
    par = bayesparams(),
    submodel = c("fom", "none", "ugm"))

Arguments

ts

numeric vector; time series to be fitted.

u.mar

marginal threshold; used when transforming the time series to Laplace scale.

u.dep

dependence threshold; level above which the dependence is modelled. u.dep can be lower than u.mar.

lapl

logical; is ts on the Laplace scale already? The default (FALSE) assumes unknown marginal distribution.

method.mar

a character string defining the method used to estimate the marginal GPD; either "mle" for maximum likelihood or "mom" for method of moments or "pwm" for probability weighted moments. Defaults to "mle".

nlag

integer; number of lags to be considered when modelling the dependence in time.

par

an object of class 'bayesparams'.

submodel

a character string; "fom" for first order Markov, "none" for no particular time structure, or "ugm" for univariate Gaussian mixture (see details).

Details

submodel can be "fom" to impose a first order Markov structure on the model parameters α_j and β_j (see thetafit for more details); it can take the value "none" to impose no particular structure in time; it can also be "ugm" which can be applied to density estimation, as it corresponds to setting α=β=0 (see examples).

Value

An object of class 'bayesfit' with elements:

a

posterior trace of α.

b

posterior trace of β.

sd

posterior trace of the components' standard deviations.

mean

posterior trace of the components' means.

w

posterior trace of the components' assigned weights.

prec

posterior trace of the precision parameter.

noo

posterior trace of the number of observations per component.

noc

posterior trace of the number of components containing at least one observation.

prop.sd

trace of proposal standard deviations in the 5+3 regions of the adaption scheme for α and β.

len

length of the returned traces.

See Also

thetafit, chifit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## generate data from an AR(1)
## with Gaussian marginal distribution
n   <- 10000
dep <- 0.5
ar    <- numeric(n)
ar[1] <- rnorm(1)
for(i in 2:n)
  ar[i] <- rnorm(1, mean=dep*ar[i-1], sd=1-dep^2)
  
## rescale the margin
ar <- qlapl(pnorm(ar))

## fit the data
params <- bayesparams()
params$maxit <- 100# bigger numbers would be
params$burn  <- 10 # more sensible...
params$thin  <- 4
fit <- depfit(ts=ar, u.mar=0.95, u.dep=0.98, par=params)

########
## density estimation with submodel=="ugm"
data <- MASS::galaxies/1e3
dens <- depfit(ts=data, par=params, submodel="ugm")

tsxtreme documentation built on May 30, 2017, 3:32 a.m.