# Bitcoin Analysis In tscopula: Time Series Copula Models

knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(tscopula) tsoptions <- list(hessian = TRUE, method = "Nelder-Mead", avoidzero= FALSE)  ## The Bitcoin Log-Return Data We first load the data and calculate log-returns. data(bitcoin) X <- (diff(log(bitcoin))[-1]) * 100 # log-returns (as percentages) length(X) plot(X, type = "h")  ## Copula Processes ### ARMA Copulas We start with the fulcrum profile-likelihood plot which indicates that a value$\delta = 0.45$is about right. U <- strank(X) copmod_Gauss <- armacopula(pars = list(ar = 0.95, ma = -0.85)) pts <- seq(from=0.01, to=0.99, length=51) + 0.005 profilefulcrum(U, copmod_Gauss, locations = pts) abline(v = 0.45)  Our baseline model is a model with ARMA(1,1) copula and v-transform with fulcrum at$\delta=0.45\$.

mod_Gauss <- vtscopula(copmod_Gauss, Vlinear(0.45))
fit_Gauss <- fit(mod_Gauss, U, tsoptions = tsoptions)
fit_Gauss


### D-Vine Copula (second kind)

In this next section we try a d-vine copula model of the second kind with a finite value for maxlag and a linear v-transform. We continue to use the Frank copula. The resulting model is superior to the ARMA copula model and has the same number of parameters. Note that an infinite value for maxlag makes next to no difference in the fit.

copmod_Frank <- dvinecopula2(family = "frank",
pars = list(ar = 0.95, ma = -0.85),
maxlag = 30)
mod_Frank <- vtscopula(copmod_Frank, Vlinear(0.45))
fit_Frank <- fit(mod_Frank, U, tsoptions = tsoptions)

AIC(fit_Gauss, fit_Frank)


We provide plots for the model with Frank copula to show aspects of the fit.

plot(fit_Frank, plottype = "residual")
plot(fit_Frank, plottype = "kendall")


## Marginal Models

We fit 6 marginal distributions (3 symmetric and 3 skewed) of which the double Weibull gives the lowest AIC value.

marg_st <- fit(margin("st"), X)
marg_sst <- fit(margin("sst"), X)
marg_lp <- fit(margin("laplace",
pars = c(mu = 0.2, scale = 2.7)), X)
marg_slp <- fit(margin("slaplace",
pars = c(mu = 0.2, scale = 2.7, gamma = 0.9)), X)
marg_dw <- fit(margin("doubleweibull",
pars = c(mu = 0.2, shape = 0.8, scale = 2.7)), X)
marg_sdw <- fit(margin("sdoubleweibull",
pars = c(mu = 0.2, shape = 0.8, scale = 2.7, gamma = 0.9)), X)
AIC(marg_st, marg_sst, marg_slp, marg_lp, marg_dw, marg_sdw)


## Full Models

### D-Vine Copula

We fit a full model combining the double Weibull margin with the VT-d-vine model of the second kind.

fullmod <- tscm(fit_Frank, margin = marg_dw)
fullmod <- fit(fullmod, as.numeric(X),
method = "full", tsoptions = tsoptions)
fullmod
AIC(marg_dw, fullmod)


We show all the possible plots for the full model.

plot(fullmod, plottype = "residual")
plot(fullmod, plottype = "kendall")
plot(fullmod, plottype = "margin")
plot(fullmod, plottype = "vtransform")
plot(fullmod, plottype = "volprofile")
plot(fullmod, plottype = "volproxy")

plot(fullmod, plottype = "glag")


## Try the tscopula package in your browser

Any scripts or data that you put into this service are public.

tscopula documentation built on May 7, 2022, 5:06 p.m.