Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ha0ye/rEDM
Applications of Empirical Dynamic Modeling from Time Series
https://github.com/ha0ye/rEDM
Last synced: 3 months ago
JSON representation
Applications of Empirical Dynamic Modeling from Time Series
- Host: GitHub
- URL: https://github.com/ha0ye/rEDM
- Owner: ha0ye
- License: other
- Archived: true
- Created: 2018-11-15T00:18:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-18T13:36:06.000Z (over 3 years ago)
- Last Synced: 2024-05-21T02:12:34.486Z (6 months ago)
- Language: R
- Homepage: https://ha0ye.github.io/rEDM
- Size: 36.3 MB
- Stars: 49
- Watchers: 7
- Forks: 16
- Open Issues: 8
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
)
```## *This version of rEDM is no longer being maintained (as of October 2019) - please see https://github.com/SugiharaLab/rEDM/ for the latest version of the package*
# rEDM
[![Build
Status](https://travis-ci.org/ha0ye/rEDM.svg?branch=master)](https://travis-ci.org/ha0ye/rEDM)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.596502.svg)](https://doi.org/10.5281/zenodo.596502)
[![codecov](https://codecov.io/gh/ha0ye/rEDM/branch/master/graph/badge.svg)](https://codecov.io/gh/ha0ye/rEDM)
[![downloads](https://cranlogs.r-pkg.org/badges/grand-total/rEDM)](https://cran.rstudio.com/web/packages/rEDM/index.html)## Binder Demo
Try out the package without installation (after loading, try clicking on `README.Rmd` in the `Files` tab).[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/ha0ye/rEDM/master?urlpath=rstudio)
## Overview
The `rEDM` package is a collection of methods for Empirical Dynamic Modeling (EDM). EDM is based on the mathematical theory of recontructing attractor manifolds from time series data, with applications to forecasting, causal inference, and more. It is based on research software previously developed for the Sugihara Lab (University of California San Diego, Scripps Institution of Oceanography).
## Installation
You can install rEDM from CRAN with:
```{r cran-installation, eval = FALSE}
install.packages("rEDM")
```OR from github with:
```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_github("ha0ye/rEDM")
```If you are on Windows, you may need to install [Rtools](https://cran.r-project.org/bin/windows/Rtools/) first, so that you have access to a C++ compiler.
## Example
```{r, include = FALSE}
knitr::opts_chunk$set(fig.width = 6, fig.height = 4)
par(mar = c(4, 4, 1, 1), mgp = c(2.5, 1, 0), oma = c(0, 0, 0, 0))
```We begin by looking at annual time series of sunspots:
```{r sunspots}
dat <- data.frame(yr = as.numeric(time(sunspot.year)),
sunspot_count = as.numeric(sunspot.year))plot(dat$yr, dat$sunspot_count, type = "l",
xlab = "year", ylab = "sunspots")
```First, we use simplex to determine the optimal embedding dimension, E:
```{r determining E, warning = FALSE}
library(rEDM) # load the packagen <- NROW(dat)
lib <- c(1, floor(2/3 * n)) # indices for the first 2/3 of the time series
pred <- c(floor(2/3 * n) + 1, n) # indices for the final 1/3 of the time seriesoutput <- simplex(dat, # input data (for data.frames, uses 2nd column)
lib = lib, pred = lib, # which portions of the data to train and predict
E = 1:10) # embedding dimensions to trysummary(output[, 1:9])
```It looks like `E = 3` or `4` is optimal. Since we generally want a simpler model, if possible, let's go with `E = 3` to forecast the remaining 1/3 of the data.
```{r}
output <- simplex(dat,
lib = lib, pred = pred, # predict on last 1/3
E = 3,
stats_only = FALSE) # return predictions, toopredictions <- na.omit(output$model_output[[1]])
plot(dat$yr, dat$sunspot_count, type = "l",
xlab = "year", ylab = "sunspots")
lines(predictions$time, predictions$pred, col = "blue", lty = 2)
polygon(c(predictions$time, rev(predictions$time)),
c(predictions$pred - sqrt(predictions$pred_var),
rev(predictions$pred + sqrt(predictions$pred_var))),
col = rgb(0, 0, 1, 0.5), border = NA)
```## Further Examples
Please see the package vignettes for more details:
```{r, eval = FALSE}
browseVignettes("rEDM")
```