depfit {tsxtreme} | R Documentation |
Dependence model fit
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
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. |
lapl |
logical; is |
method.mar |
a character string defining the method used to estimate the marginal GPD; either |
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 \alpha_j
and \beta_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 \alpha=\beta=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 |
len |
length of the returned traces. |
See Also
Examples
## 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")