Author

library(forecast)
library(pracma)
library(RTransferEntropy)
library(lmtest)

Immigration, Refugees and Citizenship Canada (IRCC), Permanent Residents – Monthly IRCC Updates

Canada - Admissions of Permanent Residents by Province/Territory, Census Division and Census Subdivision of the Intended Destination (2018 ranking), January 2015 - May 2019

Seasonal Decomposition

IRCC_admissions <- read.csv("IRCC_admissions.csv")
Toronto.ts <- ts(IRCC_admissions$Toronto, frequency = 12, start = 2015)

Toronto.ts.components <- decompose(Toronto.ts)

autoplot(Toronto.ts.components)

ON.ts <- ts(IRCC_admissions$ON, frequency = 12, start = 2015)

ON.ts.components <- decompose(ON.ts)

autoplot(ON.ts.components)

Vancouver.ts <- ts(IRCC_admissions$Vancouver, frequency = 12, start = 2015)

Vancouver.ts.components <- decompose(Vancouver.ts)

autoplot(Vancouver.ts.components)

BC.ts <- ts(IRCC_admissions$BC, frequency = 12, start = 2015)

BC.ts.components <- decompose(BC.ts)

autoplot(BC.ts.components)

Cross-Correlation

E. E. Holmes, M. D. Scheuerell, and E. J. Ward, Applied Time Series Analysis for Fisheries and Environmental Sciences. Section 4.4: Correlation within and among time series

length(Toronto.ts)
[1] 53
ccf(Toronto.ts, Vancouver.ts, main = NA, lag = 52, ylab="Cross-correlation")

ccf(Toronto.ts, ON.ts, main = NA, lag = 52, ylab="Cross-correlation")

ccf(Vancouver.ts, BC.ts, main = NA, lag = 52, ylab="Cross-correlation")

ccf(ON.ts, BC.ts, main = NA, lag = 52, ylab="Cross-correlation")

Sample Entropy

pracma, Approximate And Sample Entropy

Sample Entropy with Rcpp

sample_entropy(Toronto.ts)
[1] 2.564949
sample_entropy(ON.ts)
[1] 1.871802
sample_entropy(Vancouver.ts)
[1] 1.824549
sample_entropy(BC.ts)
[1] 3.135494
approx_entropy(Toronto.ts)
[1] 0.4996574
approx_entropy(ON.ts)
[1] 0.4241658
approx_entropy(Vancouver.ts)
[1] 0.4778336
approx_entropy(BC.ts)
[1] 0.4569236

Simon Behrendt, Thomas Dimpfl, Franziska J. Peter, and David J. Zimmermann, RTransferEntropy

calc_te(Toronto.ts, Vancouver.ts)
[1] 0.05672144
calc_te(Toronto.ts, ON.ts)
[1] 0.01701271
calc_te(ON.ts, BC.ts)
[1] 0.02579484

Granger Causality

lmtest, Test For Granger Causality

grangertest(Toronto.ts, ON.ts)
Granger causality test

Model 1: ON.ts ~ Lags(ON.ts, 1:1) + Lags(Toronto.ts, 1:1)
Model 2: ON.ts ~ Lags(ON.ts, 1:1)
  Res.Df Df      F Pr(>F)
1     49                 
2     50 -1 1.4876 0.2284
grangertest(Vancouver.ts, BC.ts)
Granger causality test

Model 1: BC.ts ~ Lags(BC.ts, 1:1) + Lags(Vancouver.ts, 1:1)
Model 2: BC.ts ~ Lags(BC.ts, 1:1)
  Res.Df Df      F Pr(>F)
1     49                 
2     50 -1 1.9343 0.1706
grangertest(Toronto.ts, Vancouver.ts)
Granger causality test

Model 1: Vancouver.ts ~ Lags(Vancouver.ts, 1:1) + Lags(Toronto.ts, 1:1)
Model 2: Vancouver.ts ~ Lags(Vancouver.ts, 1:1)
  Res.Df Df      F Pr(>F)
1     49                 
2     50 -1 1.7999 0.1859
grangertest(ON.ts, BC.ts)
Granger causality test

Model 1: BC.ts ~ Lags(BC.ts, 1:1) + Lags(ON.ts, 1:1)
Model 2: BC.ts ~ Lags(BC.ts, 1:1)
  Res.Df Df      F  Pr(>F)  
1     49                    
2     50 -1 3.5083 0.06703 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
LS0tDQp0aXRsZTogIklSQ0MgUGVybWFuZW50IFJlc2lkZW50IEFkbWlzc2lvbnMgTW9udGhseSBUaW1lc2VyaWVzLCBKYW51YXJ5IDIwMTUgdG8gTWF5IDIwMTkiDQpvdXRwdXQ6IA0KICBodG1sX25vdGVib29rOiANCiAgICB0b2M6IHllcw0KLS0tDQoNCiMgQXV0aG9yDQoNCiogSm9yZGFuIEJlbGwNCiogSnVseSAyNCwgMjAx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