package-carfima: Continuous-Time Fractionally Integrated ARMA Process for...

Description Details References Examples

Description

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 frequentist or Bayesian machinery. A general-order CARFIMA(p, H, q) model for p>q is specified in Tsai and Chan (2005) and 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. The package produces their maximum likelihood estimates and asymptotic uncertainties using a global optimizer called the differential evolution algorithm. It also produces their posterior distributions via Metropolis within a Gibbs sampler equipped with adaptive Markov chain Monte Carlo for posterior sampling. 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.

Details

Package: carfima
Type: Package
Version: 2.0.0
License: GPL-2
Main functions: carfima, carfima.loglik, carfima.sim

References

\insertRef

tsai_note_2000carfima

\insertRef

tsai_maximum_2005carfima

Examples

 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
##### Irregularly spaced observation time generation.

length.time <- 10
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.75, 0.2) 
 # AR parameter alpha = -0.4
 # Hurst parameter = 0.75
 # process uncertainty (standard deviation) sigma = 0.2
 y <- carfima.sim(parameter = parameter, time = time, 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, 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, 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,
                          parameter = parameter, fitted = FALSE)

kisungyou/carfima documentation built on May 13, 2019, 5:24 p.m.