knitr::opts_chunk$set(echo = TRUE)

Setup

ordinal_TSA installation

  1. clone from https://github.com/garlanjt/Ordinal_TSA
  2. in command line, navigate to the folder, and then:
pip install .
  1. test the code
python min_working_example.py

R code

Analysis

Generate data

set.seed(42)
nile <- as.numeric(Nile)
ss_m <- as.numeric(sunspot.month)
ss_y <- as.numeric(sunspot.year)
test <- c(1, 1, 0, 0, 1, 1, rnorm(100))

Compute WPE

Josh's cython implementation:

import ordinal_TSA
import numpy as np

ts = np.vstack(np.asarray(r.nile))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)

ts = np.vstack(np.asarray(r.ss_m))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)

ts = np.vstack(np.asarray(r.ss_y))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)

Frank's R implementation:

library(MATSSforecasting)

PE(nile, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
PE(ss_m, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
PE(ss_y, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)

Tie-handling

Check how ties should be handled for consistency

import ordinal_TSA
import numpy as np

ts = np.vstack(np.asarray(r.test))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)
library(MATSSforecasting)

PE(test, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
PE(test, weighted = TRUE, tie_method = "last", word_length = 3, tau = 1)
PE(test, weighted = TRUE, tie_method = "average", word_length = 3, tau = 1)
PE(test, weighted = TRUE, tie_method = "random", word_length = 3, tau = 1)
PE(test, weighted = TRUE, tie_method = "noise", word_length = 3, tau = 1, noise_amount = 5)


ha0ye/MATSS-forecasting documentation built on Nov. 28, 2020, 10:16 a.m.