arima2

Software for maximum likelihood estimation of ARIMA models

https://github.com/jeswheel/arima2

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.5%) to scientific vocabulary

Keywords

arima arma maximum-likelihood-estimation r-package time-series time-series-analysis
Last synced: 6 months ago · JSON representation

Repository

Software for maximum likelihood estimation of ARIMA models

Basic Info
  • Host: GitHub
  • Owner: jeswheel
  • License: gpl-3.0
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 696 KB
Statistics
  • Stars: 6
  • Watchers: 1
  • Forks: 0
  • Open Issues: 2
  • Releases: 2
Topics
arima arma maximum-likelihood-estimation r-package time-series time-series-analysis
Created over 3 years ago · Last pushed 8 months ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r setOptions, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# arima2


[![R-CMD-check](https://github.com/jeswheel/arima2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jeswheel/arima2/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/arima2)](https://CRAN.R-project.org/package=arima2)


The goal of `arima2` is to provide a set of tools to aid in the analysis of time series data in `R`. 
One such function is `arima2::arima`, which provides an interface to estimating Auto Regressive Integrated Moving Average (ARIMA) models using a random-restart algorithm. 
This function improves on the functionality of the `stats::arima` method, as it has the potential to increase the likelihood of the final output model.
By design, the function cannot result in models with lower likelihoods than that of the `stats::arima` function. 
The potential for increased model likelihoods is obtained at the cost of computational efficiency. 
The function is approximately $n$ times slower than the `stats::arima` function, where $n$ is the number of random restarts.
The benefit of trying multiple restarts becomes smaller as the number of available observations increases. 
Because the estimation of ARIMA models takes only a fraction of a second on relatively small data sets (less than a thousand observations), we are of the opinion that potential to increase model likelihoods is well worth this computational cost.
The `arima` function implementation relies heavily on the source code of the `stats::arima` function. 

## Installation

``` r
# Install from CRAN
install.packages("arima2")
```

You can install the development version of `arima2` from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("jeswheel/arima2")
```

## Example

This is a basic example which shows you how to solve a common problem:

```{r example}
library(arima2)

set.seed(851348)

coefs <- c("ar1" = -0.3, "ar2" = -0.3, 'ma1' = -0.2, 'ma2' = 0.1)
intercept <- 20

# Generate data from ARMA model
x <- intercept + arima.sim(
  n = 100,
  model = list(ar = coefs[grepl("^ar[[:digit:]]+", names(coefs))],
               ma = coefs[grepl("^ma[[:digit:]]+", names(coefs))])
)

arma <- stats::arima(x, order = c(2, 0, 2), SSinit = "Rossignol2011")
arma2 <- arima2::arima(x, order = c(2, 0, 2), SSinit = "Rossignol2011")
```

In the example above, the resulting log-likelihood of the `stats::arima` function is `r round(arma$loglik, 2)`, and the log-likelihood of the `arima` function is `r round(arma2$loglik, 2)`.
For this particular model and dataset, the random restart algorithm implemented in `arima2` improved the model likelihood by `r round(arma2$loglik - arma$loglik, 2)` log-likelihood units. 

Our package creates a new `S3` object that we call `Arima2`, which extends the `Arima` class of the `stats` package. 
Once the model has been fit, our package includes some features that help diagnose the fitted model using this new child class.
For example, `ARMApolyroots` function will return the AR or MA polynomial roots of the fitted model:

```{r getARMAroots}
ARMApolyroots(arma2, type = 'AR')
ARMApolyroots(arma2, type = 'MA')
```

We have also implemented a `plot.Arima2` function that uses the `ggplot2` package so that we can visualize a fitted model. 
To compare the roots of the model fit using multiple restarts to the model fit using `stats::arima`, I will modify the class of the `arma` object so that it can easily be plotted:

```{r PlotARMAresults}
class(arma) <- c("Arima2", class(arma))

plot(arma)
plot(arma2)
```

Finally, if a user would like help in determining an appropriate number of coefficients, we provide the `aicTable` function.
The package also includes an `aicTable` function, which prints the AIC values for all ARMA$(p, d, q)$, with $p \leq P$, $q \leq Q$, and $d = D$:

```{r getAICtable}
set.seed(443252)
tab_results <- aicTable(x, P = 4, Q = 4, D = 0) 

tab_results |> knitr::kable()

P <- which(tab_results == min(tab_results), arr.ind = TRUE)[1] - 1
Q <- which(tab_results == min(tab_results), arr.ind = TRUE)[2] - 1

print(paste0("p = ", P, "; q = ", Q))
```

For more details about this package, please see our arXiv paper: [arXiv:2310.01198](https://doi.org/10.48550/arXiv.2310.01198)

Owner

  • Name: Jesse Wheeler
  • Login: jeswheel
  • Kind: user

PhD student in Statistics, University of Michigan

GitHub Events

Total
  • Watch event: 2
  • Push event: 7
Last Year
  • Watch event: 2
  • Push event: 7

Packages

  • Total packages: 1
  • Total downloads:
    • cran 264 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: arima2

Likelihood Based Inference for ARIMA Modeling

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 264 Last month
Rankings
Dependent packages count: 27.9%
Dependent repos count: 36.8%
Average: 50.2%
Downloads: 86.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/render-rmarkdown.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-renv v2 composite
DESCRIPTION cran
  • ggplot2 * imports
  • methods * imports
  • testthat >= 3.0.0 suggests