R-CMD-check CRAN status Codecov test coverage

Functions to analyse time series consisting of low counts are provided. The focus in the current version is on practical models that can capture first and higher-order dependence based on the work of Joe (1996). Both equidispersed and overdispersed marginal distributions of data can be modelled. Regression effects can be included. Fast and efficient procedures for likelihood based inference and probabilistic forecasting are provided as well as useful tools for model validation and diagnostics.

alt text


The package allows simulation of convolution-closed count time series models with the cocoSim function. Model fitting is performed with the cocoReg routine. By passing a cocoReg-type object, cocoForecast computes the one-step ahead forecasting distribution. cocoBoot, cocoPit, cocoScore, and cocoResid provide routines for model assessment. The main usage of the package is illustrated within the cocoReg function chapter. For more details and examples of the functions see the respective sections within this vignette.

By default, our functions make use of an RCPP implementation. However, users with a running Julia installation can choose to call Julia in the background to run their functions by specifying it in the R function input. This option is particularly useful for the regression (), where a complex likelihood function must be numerically evaluated to obtain parameter estimates. By leveraging Julia’s automatic differentiation capabilities, our functions can take advantage of numerical gradients, leading to increased numerical stability and faster convergence.

Despite these advantages, we found that both the Julia and RCPP implementations produced qualitatively similar results in all our tests. As a result, we have decided to use the RCPP implementation as the default option to make our package accessible to non-Julia users.


alt text


You can install the latest stable version of coconots from CRAN with:


Example using RCPP implementation

Coconots runs on an RCPP and a Julia implementation. RCPP is the default. The regression results can be summarized using the summary function.

length <- 500

pars <- c(1, 0.4)
data <- cocoSim(order = 1, type = "Poisson", par = pars,
                length = length)
coco <- cocoReg(order = 1, type = "Poisson", data = data)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#> zoo
#> Coefficients:
#>          Estimate   Std. Error         t
#> lambda     0.9427       0.0678   13.9055
#> alpha      0.4530       0.0346   13.0806
#> Type: Poisson 
#> Order: 1 
#> Log-likelihood: -749.4656

Example using Julia implementation

In order to use the Julia functions, you need a running version of Julia installed. You need to install the relevant Julia packages once.

#> Starting Julia ...

If installed, the Julia implementation can be addressed by setting the julia argument to true. In this case we need to set the seed within the simulation function in order to pass it to Julia.

length <- 500

pars <- c(1, 0.4)
data <- cocoSim(order = 1, type = "Poisson", par = pars, length = length,
                julia = TRUE, julia_seed = 123)
coco <- cocoReg(order = 1, type = "Poisson", data = data, julia = TRUE)

Model assessment

We provide different tools for model assessment. One can even use the RCPP implementation for the regression and do model assessment with the Julia implementation. If this is desired, one needs to specify in the output of the regression that it should be Julia compatible. Note that this is not necessary if the Julia option in the regression is true.

length <- 500

pars <- c(1, 0.4)
data <- cocoSim(order = 1, type = "Poisson", par = pars, length = length)
coco <- cocoReg(order = 1, type = "Poisson", data = data,
(scores <- cocoScore(coco, julia = TRUE))
#> $log.score
#> [1] 1.501935
#> $quad.score
#> [1] -0.2532058
#> $rps.score
#> [1] 0.619761
pit <- cocoPit(coco, julia = TRUE)

boot <- cocoBoot(coco, julia = TRUE)

forecast <- cocoForecast(coco, julia = TRUE)