Description Details Author(s) References Examples
The R package carfima provides a toolbox to fit a continuous-time fractionally integrated ARMA process (CARFIMA) on univariate and irregularly spaced time series data via both frequentist and Bayesian machinery. A general-order CARFIMA(p, H, q) model for p>q is specified in Tsai and Chan (2005). It involves p+q+2 unknown model parameters, i.e., p AR parameters, q MA parameters, Hurst parameter H, and process uncertainty (standard deviation) σ; see also carfima
. Also, the model can account for heteroscedastic measurement errors, if the information about measurement error standard deviations is known. The package produces their maximum likelihood estimates and asymptotic uncertainties using a global optimizer called the differential evolution algorithm. It also produces posterior samples of the model parameters via Metropolis-Hastings within a Gibbs sampler equipped with adaptive Markov chain Monte Carlo. These fitting procedures, however, may produce numerical errors if p>2. The toolbox also contains a function to simulate discrete time series data from CARFIMA(p, H, q) process given the model parameters and observation times.
Package: | carfima |
Type: | Package |
Version: | 2.0.2 |
Date: | 2020-03-20 |
License: | GPL-2 |
Main functions: | carfima , carfima.loglik , carfima.sim |
Hyungsuk Tak, Henghsiu Tsai, and Kisung You
Maintainer: Hyungsuk Tak <hyungsuk.tak@gmail.com>
H. Tsai and K.S. Chan (2005) "Maximum Likelihood Estimation of Linear Continuous Time Long Memory Processes with Discrete Time Data," Journal of the Royal Statistical Society (Series B), 67 (5), 703-716. DOI: 10.1111/j.1467-9868.2005.00522.x
H. Tsai and K.S. Chan (2000) "A Note on the Covariance Structure of a Continuous-time ARMA Process," Statistica Sinica, 10, 989-998.
Link: http://www3.stat.sinica.edu.tw/statistica/j10n3/j10n317/j10n317.htm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ##### Irregularly spaced observation time generation.
length.time <- 30
time.temp <- rexp(length.time, rate = 2)
time <- rep(NA, length.time + 1)
time[1] <- 0
for (i in 2 : (length.time + 1)) {
time[i] <- time[i - 1] + time.temp[i - 1]
}
time <- time[-1]
##### Data genration for CARFIMA(1, H, 0) based on the observation times.
parameter <- c(-0.4, 0.8, 0.2)
# AR parameter alpha = -0.4
# Hurst parameter = 0.8
# Process uncertainty (standard deviation) sigma = 0.2
me.sd <- rep(0.05, length.time)
# Known measurement error standard deviations 0.05 for all observations
# If not known, remove the argument "measure.error = me.sd" in the following codes,
# so that the default values (zero) are automatically assigned.
y <- carfima.sim(parameter = parameter, time = time,
measure.error = me.sd, ar.p = 1, ma.q = 0)
##### Fitting the CARFIMA(1, H, 0) model on the simulated data for MLEs.
res <- carfima(Y = y, time = time, measure.error = me.sd,
method = "mle", ar.p = 1, ma.q = 0)
# It takes a long time due to the differential evolution algorithm (global optimizer).
# res$mle; res$se; res$AIC; res$fitted.values
##### Fitting the CARFIMA(1, H, 0) model on the simulated data for Bayesian inference.
res <- carfima(Y = y, time = time, measure.error = me.sd,
method = "bayes", ar.p = 1, ma.q = 0,
bayes.param.ini = parameter,
bayes.param.scale = c(rep(0.2, length(parameter))),
bayes.n.warm = 100, bayes.n.sample = 1000)
# It takes a long time because the likelihood evaluation is computationally heavy.
# The last number of bayes.param.scale is to update sigma2 (not sigma) on a log scale.
# hist(res$param[, 1]); res$accept; res$AIC; res$fitted.values
##### Computing the log likelihood of the CARFIMA(1, H, 0) model given the parameters.
loglik <- carfima.loglik(Y = y, time = time, ar.p = 1, ma.q = 0,
measure.error = me.sd,
parameter = parameter, fitted = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.