Public Health Ontario, Interactive Opioid Tool
Opioid-related morbidity and mortality in Ontario
library(data.table)
library(forecast) #autoplot
Ontario <- fread("Cases of opioid-related morbidity and mortality, Ontario, 2003 - 01 – 2018 - 09.csv")
Toronto_Public_Health <- fread("Cases of opioid-related morbidity and mortality, Toronto Public Health, 2003 - 01 – 2018 - 09.csv")
str(Toronto_Public_Health)
Classes ‘data.table’ and 'data.frame': 189 obs. of 8 variables:
$ Year - Month : chr "2003 - 01" "2003 - 02" "2003 - 03" "2003 - 04" ...
$ Population : int 2600854 2600228 2599602 2598977 2598351 2597725 2597099 2596801 2596503 2596205 ...
$ Rate of ED visits : num 1 0.5 0.8 0.8 1.1 0.8 1.1 0.9 1.2 1 ...
$ Count of ED visits : int 25 13 22 22 28 20 28 24 30 27 ...
$ Rate of Hospitalizations : num 0.6 0.3 0.5 0.6 0.6 0.5 0.5 0.7 0.4 0.6 ...
$ Count of Hospitalizations: int 15 9 12 15 15 14 12 18 11 16 ...
$ Rate of Deaths : chr "NA" "NA" "NA" "NA" ...
$ Count of Deaths : chr "NA" "NA" "NA" "NA" ...
- attr(*, ".internal.selfref")=<externalptr>
Toronto_Central_LHIN <- fread("Cases of opioid-related morbidity and mortality, Toronto Central LHIN, 2003 - 01 – 2018 - 09.csv")
Ontario_Count_ED_visits.ts <- ts(Ontario$`Count of ED visits`, start = 2003, frequency = 12)
Toronto_Public_Health_Count_ED_visits.ts <- ts(Toronto_Public_Health$`Count of ED visits`, start = 2003, frequency = 12)
Toronto_Central_LHIN_Count_ED_visits.ts <- ts(Toronto_Central_LHIN$`Count of ED visits`, start = 2003, frequency = 12)
Ontario_Count_ED_visits.ts.components <- decompose(Ontario_Count_ED_visits.ts)
Toronto_Public_Health_Count_ED_visits.ts.components <- decompose(Toronto_Public_Health_Count_ED_visits.ts)
plot(Ontario_Count_ED_visits.ts.components)
plot(Toronto_Public_Health_Count_ED_visits.ts.components)
Toronto_Central_LHIN_Count_ED_visits.ts.components <- decompose(Toronto_Central_LHIN_Count_ED_visits.ts)
plot(Toronto_Central_LHIN_Count_ED_visits.ts.components)
D=1 forces seasonality
Toronto_Public_Health_Count_ED_visits.ts.arima <- auto.arima(Toronto_Public_Health_Count_ED_visits.ts, D=1)
Toronto_Public_Health_Count_ED_visits.ts.arima
Series: Toronto_Public_Health_Count_ED_visits.ts
ARIMA(3,1,1)(1,1,1)[12]
Coefficients:
ar1 ar2 ar3 ma1 sar1 sma1
0.7587 0.0642 -0.2713 -0.7898 -0.2953 -0.6304
s.e. 0.1014 0.0939 0.0771 0.0834 0.1300 0.1191
sigma^2 estimated as 177.3: log likelihood=-708.23
AIC=1430.46 AICc=1431.13 BIC=1452.65
Toronto_Public_Health_Count_ED_visits.ts.arima.forecast <- forecast(Toronto_Public_Health_Count_ED_visits.ts.arima, level = c(95), h = 24)
autoplot(Toronto_Public_Health_Count_ED_visits.ts.arima.forecast, main = "Monthly Emergency Department (ED) Visits")
Toronto_Public_Health_Rate_of_ED_visits.ts <- ts(Toronto_Public_Health$`Rate of ED visits`, start = 2003, frequency = 12)
Toronto_Public_Health_Rate_of_ED_visits.ts.components <- decompose(Toronto_Public_Health_Rate_of_ED_visits.ts)
plot(Toronto_Public_Health_Rate_of_ED_visits.ts.components)
Toronto_Public_Health_Rate_of_ED_visits.ts.arima <- auto.arima(Toronto_Public_Health_Rate_of_ED_visits.ts, D=1)
Toronto_Public_Health_Rate_of_ED_visits.ts.arima
Series: Toronto_Public_Health_Rate_of_ED_visits.ts
ARIMA(0,1,0)(1,1,1)[12]
Coefficients:
sar1 sma1
-0.2606 -0.6268
s.e. 0.1348 0.1218
sigma^2 estimated as 0.2475: log likelihood=-131.09
AIC=268.18 AICc=268.32 BIC=277.7
Toronto_Public_Health_Rate_of_ED_visits.ts.arima.forecast <- forecast(Toronto_Public_Health_Rate_of_ED_visits.ts.arima, level = c(95), h = 24)
autoplot(Toronto_Public_Health_Rate_of_ED_visits.ts.arima.forecast, main = "Monthly Emergency Department (ED) Visits")
Ontario_Count_ED_visits.ts.arima <- auto.arima(Ontario_Count_ED_visits.ts, D=1)
Ontario_Count_ED_visits.ts.arima
Series: Ontario_Count_ED_visits.ts
ARIMA(0,1,0)(0,1,2)[12]
Coefficients:
sma1 sma2
-0.8092 0.1603
s.e. 0.0885 0.0816
sigma^2 estimated as 1473: log likelihood=-894.99
AIC=1795.98 AICc=1796.12 BIC=1805.49
Ontario_Count_ED_visits.ts.arima.forecast <- forecast(Ontario_Count_ED_visits.ts.arima, level = c(95), h = 24)
autoplot(Ontario_Count_ED_visits.ts.arima.forecast, main = "Monthly Emergency Department (ED) Visits")