---
title: "75th percentile graphs"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(nlme)
## Data prep
# working directory removed
lod_all <- read.csv("lod_all.csv")
lod_all$sin1 <- sin(2 * pi * 1 * lod_all$time / 12)
lod_all$cos1 <- cos(2 * pi * 1 * lod_all$time / 12)
lod_all$sin2 <- sin(2 * pi * 2 * lod_all$time / 12)
lod_all$cos2 <- cos(2 * pi * 2 * lod_all$time / 12)
lod_all$sin3 <- sin(2 * pi * 3 * lod_all$time / 12)
lod_all$cos3 <- cos(2 * pi * 3 * lod_all$time / 12)
lod_all$sin4 <- sin(2 * pi * 4 * lod_all$time / 12)
lod_all$cos4 <- cos(2 * pi * 4 * lod_all$time / 12)
lod_all$sin5 <- sin(2 * pi * 5 * lod_all$time / 12)
lod_all$cos5 <- cos(2 * pi * 5 * lod_all$time / 12)
lod_all$sin6 <- sin(2 * pi * 6 * lod_all$time / 12)
lod_all$cos6 <- cos(2 * pi * 6 * lod_all$time / 12)
sa <- lod_all[c(1:72,145:216),]
tas <- lod_all[73:216,]
comp <- lod_all[145:216,]
# Special trend for apparently non-linear trend in Tasmania
lod_all$tas_trend2 <- lod_all$tas_trend ^ 2
lod_all$tas_trend3 <- lod_all$tas_trend ^ 3
# Smoothed dataset for graphing
smth <- data.frame(level1 = rep(c(0, 1), c(300, 420)),
level2 = rep(c(0, 1), c(480, 240)),
time = 1:720 / 10,
trend1 = 0,
trend2 = 0,
tas_trend2 = 0,
tas_trend3 = 0)
smth$trend1[301:720] <- 1:420 / 10
smth$trend2[481:720] <- 1:240 / 10
smth$tas_trend2[481:720] <- 1:240 / 10
smth$tas_trend2 <- smth$tas_trend2 ^ 2
smth$tas_trend3[481:720] <- 1:240 / 10
smth$tas_trend3 <- smth$tas_trend3 ^ 3
smth$sin1 <- sin(2 * pi * 1 * smth$time / 12)
smth$cos1 <- cos(2 * pi * 1 * smth$time / 12)
smth$sin2 <- sin(2 * pi * 2 * smth$time / 12)
smth$cos2 <- cos(2 * pi * 2 * smth$time / 12)
smth$sin3 <- sin(2 * pi * 3 * smth$time / 12)
smth$cos3 <- cos(2 * pi * 3 * smth$time / 12)
smth$sin4 <- sin(2 * pi * 4 * smth$time / 12)
smth$cos4 <- cos(2 * pi * 4 * smth$time / 12)
smth$sin5 <- sin(2 * pi * 5 * smth$time / 12)
smth$cos5 <- cos(2 * pi * 5 * smth$time / 12)
smth$sin6 <- sin(2 * pi * 6 * smth$time / 12)
smth$cos6 <- cos(2 * pi * 6 * smth$time / 12)
```
# Claim reporting time, comparator
```{r, echo = FALSE}
################################################## Comp
g_complod75 <- lm(lod_75 ~ time + level1 + level2 + trend1 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 + sin6 + cos1 + cos2 + cos3 +
cos4 + cos5 + cos6,
data = lod_all[145:216,])
summary(g_complod75)
# Removing harmonic seasonal adjustments
g_complod75 <- lm(lod_75 ~ time + level1 + level2 + trend1 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 + cos1 + cos2 + cos4 + cos5,
data = lod_all[145:216,])
# autoregression check
acf(residuals(g_complod75), lag.max = 36)
acf(residuals(g_complod75), type = "partial", lag.max = 36)
# No evidence of autocorrelation
g_complod75_blank <- gls(lod_75 ~ time + level1 + level2 + trend1 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 + cos1 + cos2 + cos4 + cos5,
data = lod_all[145:216,],
method = "ML")
summary(g_complod75_blank)
```
# Claim reporting time, South Australia
```{r, echo = FALSE}
g_SAlod75 <- lm(lod_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = lod_all[1:72,])
summary(g_SAlod75)
# Removing harmonic seasonal adjustments
g_SAlod75 <- lm(lod_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 + cos4 + cos5,
data = lod_all[1:72,])
summary(g_SAlod75)
# autoregression check
acf(residuals(g_SAlod75), lag.max = 36)
acf(residuals(g_SAlod75), type = "partial", lag.max = 36)
# Compare models
g_SAlod75_blank <- gls(lod_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 + cos4 + cos5,
data = sa[1:72,],
method = "ML")
# did not conver; g_SAlod75_q10 <- gls(lod_75 ~ time + level1 + trend1 +
# sin1 + sin2 + sin3 + sin4 + sin5 + cos4 + cos5,
# data = sa[1:72,],
# correlation = corARMA(q = 10, form = ~10),
# method = "ML")
# Final model
summary(g_SAlod75_blank)
```
# Claim reporting time, Tasmania
```{r, echo = FALSE}
g_TASlod75 <- lm(lod_75 ~ time + level2 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = lod_all[73:144,])
summary(g_TASlod75)
# Removing harmonic seasonal adjustments
g_TASlod75 <- lm(lod_75 ~ time + level2 + trend2 +
sin1 + sin3 + sin4 + cos4 + cos5,
data = lod_all[73:144,])
summary(g_TASlod75)
################################################## Comp
# autoregression check
acf(residuals(g_TASlod75), lag.max = 36)
acf(residuals(g_TASlod75), type = "partial", lag.max = 36)
# Compare models (no correlated residuals)
g_TASlod75_blank <- gls(lod_75 ~ time + level2 + trend2 +
sin1 + sin3 + sin4 + cos4 + cos5,
data = lod_all[73:144,],
method = "ML")
# Final model
summary(g_TASlod75_blank)
```
# Insurer decision time, comparator
```{r, echo = FALSE}
################################################## Comp
# Regression, insurer decision
g_compdec75 <- lm(dec_75 ~ time + level1 + level2 + trend1 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 + sin6 + cos1 + cos2 + cos3 +
cos4 + cos5 + cos6,
data = lod_all[145:216,])
summary(g_compdec75)
# Removing harmonic seasonal adjustments
g_compdec75 <- lm(dec_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,])
summary(g_compdec75)
################################################## Comp
# autoregression check
acf(residuals(g_compdec75), lag.max = 36)
acf(residuals(g_compdec75), type = "partial", lag.max = 36)
g_compdec75_blank <- gls(dec_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
method = "ML")
g_compdec75_p1 <- gls(dec_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
correlation = corARMA(p = 1, form = ~time),
method = "ML")
g_compdec75_q1 <- gls(dec_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
correlation = corARMA(q = 1, form = ~time),
method = "ML")
g_compdec75_p1q1 <- gls(dec_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
correlation = corARMA(p = 1, q = 1, form = ~time),
method = "ML")
anova(g_compdec75_blank, g_compdec75_p1, g_compdec75_q1, g_compdec75_p1q1)
anova(g_compdec75_blank, g_compdec75_p1, g_compdec75_p1q1)
summary(g_compdec75_p1)
```
# Insurer decision time, South Australia
```{r, echo = FALSE}
# Regression, insurer decision
g_SAdec75 <- lm(dec_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = sa[1:72,])
summary(g_SAdec75)
# Removing harmonic seasonal adjustments
g_SAdec75 <- lm(dec_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,])
summary(g_SAdec75)
# autoregression check
acf(residuals(g_SAdec75), lag.max = 36)
acf(residuals(g_SAdec75), type = "partial", lag.max = 36)
g_SAdec75_blank <- gls(dec_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
method = "ML")
g_SAdec75_p1 <- gls(dec_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
correlation = corARMA(p = 1, form = ~time),
method = "ML")
g_SAdec75_q1 <- gls(dec_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
correlation = corARMA(q = 1, form = ~time),
method = "ML")
g_SAdec75_p1q1 <- gls(dec_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
correlation = corARMA(p = 1, q = 1, form = ~time),
method = "ML")
anova(g_SAdec75_blank, g_SAdec75_p1, g_SAdec75_q1, g_SAdec75_p1q1)
anova(g_SAdec75_blank, g_SAdec75_p1, g_SAdec75_p1q1)
summary(g_SAdec75_p1)
```
# Insurer decision time, Tasmania
```{r, echo = FALSE}
g_TASdec75 <- gls(dec_75 ~ time + level2 + trend2 + tas_trend2 + tas_trend3 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = lod_all[73:144,],
method = "ML")
summary(g_TASdec75)
# Removing harmonic seasonal adjustments
g_TASdec75 <- lm(dec_75 ~ time + level2 + trend2 + tas_trend2 + tas_trend3 + sin1,
data = lod_all[73:144,],
method = "ML")
summary(g_TASdec75)
# Comparing models
g_TASdec75_l <- gls(dec_75 ~ time + level2 + trend2,
data = lod_all[73:144,],
method = "ML")
g_TASdec75_s <- gls(dec_75 ~ time + level2 + trend2 + tas_trend2 + sin1,
data = lod_all[73:144,],
method = "ML")
g_TASdec75_c <- gls(dec_75 ~ time + level2 + trend2 + tas_trend2 + tas_trend3 + sin1,
data = lod_all[73:144,],
method = "ML")
anova(g_TASdec75_l, g_TASdec75_s, g_TASdec75_c)
################################################## Comp
# autoregression check
acf(residuals(g_TASdec75_c), lag.max = 36)
acf(residuals(g_TASdec75_c), type = "partial", lag.max = 36)
g_TASdec75_blank <- gls(dec_75 ~ time + level2 +
trend2 + tas_trend2 + tas_trend3 + sin1,
data = lod_all[73:144,],
method = "ML")
summary(g_TASdec75_blank)
```
# Total time, comparator
```{r, echo = FALSE}
################################################## Comp
## Regression, total time
g_comptot75 <- lm(tot_75 ~ time + level1 + level2 + trend1 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 + sin6 + cos1 + cos2 + cos3 +
cos4 + cos5 + cos6,
data = lod_all[145:216,])
summary(g_comptot75)
# Removing harmonic seasonal adjustments
g_comptot75 <- lm(tot_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,])
# autoregression check
acf(residuals(g_comptot75), lag.max = 36)
acf(residuals(g_comptot75), type = "partial", lag.max = 36)
# Check models
g_comptot75_blank <- gls(tot_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
method = "ML")
g_comptot75_p1 <- gls(tot_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
correlation = corARMA(p = 1, form = ~time),
method = "ML")
g_comptot75_q1 <- gls(tot_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
correlation = corARMA(q = 1, form = ~time),
method = "ML")
g_comptot75_p1q1 <- gls(tot_75 ~ time + level1 + level2 + trend1 + trend2,
data = lod_all[145:216,],
correlation = corARMA(p = 1, q = 1, form = ~time),
method = "ML")
anova(g_comptot75_blank, g_comptot75_p1, g_comptot75_q1, g_comptot75_p1q1)
anova(g_comptot75_blank, g_comptot75_p1, g_comptot75_p1q1)
summary(g_comptot75_p1)
```
# Total time, South Australia
```{r, echo = FALSE}
g_SAtot75 <- lm(tot_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = sa[1:72,])
summary(g_SAtot75)
# Removing harmonic seasonal adjustments
g_SAtot75 <- lm(tot_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,])
################################################## Comp
# autoregression check
acf(residuals(g_SAtot75), lag.max = 36)
acf(residuals(g_SAtot75), type = "partial", lag.max = 36)
g_SAtot75_blank <- gls(tot_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
method = "ML")
g_SAtot75_p1 <- gls(tot_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
correlation = corARMA(p = 1, form = ~time),
method = "ML")
g_SAtot75_q1 <- gls(tot_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
correlation = corARMA(q = 1, form = ~time),
method = "ML")
g_SAtot75_p1q1 <- gls(tot_75 ~ time + level1 + trend1 +
sin1,
data = lod_all[1:72,],
correlation = corARMA(p = 1, q = 1, form = ~time),
method = "ML")
anova(g_SAtot75_blank, g_SAtot75_p1, g_SAtot75_q1, g_SAtot75_p1q1)
anova(g_SAtot75_blank, g_SAtot75_p1, g_SAtot75_p1q1)
summary(g_SAtot75_p1)
```
# Total time, Tasmania
```{r, echo = FALSE}
g_TAStot75 <- lm(tot_75 ~ time + level2 + trend2 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = lod_all[73:144,])
summary(g_TAStot75)
# Removing harmonic seasonal adjustments
g_TAStot75 <- lm(tot_75 ~ time + level2 + trend2 +
sin1,
data = lod_all[73:144,])
################################################## Comp
# autoregression check
acf(residuals(g_TAStot75), lag.max = 36)
acf(residuals(g_TAStot75), type = "partial", lag.max = 36)
# Check models
g_TAStot75_blank <- gls(tot_75 ~ time + level2 + trend2 +
sin1,
data = lod_all[73:144,],
method = "ML")
g_TAStot75_p1 <- gls(tot_75 ~ time + level2 + trend2 +
sin1,
data = lod_all[73:144,],
correlation = corARMA(p = 1, form = ~time),
method = "ML")
g_TAStot75_q1 <- gls(tot_75 ~ time + level2 + trend2 +
sin1,
data = lod_all[73:144,],
correlation = corARMA(q = 1, form = ~time),
method = "ML")
g_TAStot75_p1q1 <- gls(tot_75 ~ time + level2 + trend2 +
sin1,
data = lod_all[73:144,],
correlation = corARMA(p = 1, q = 1, form = ~time),
method = "ML")
anova(g_TAStot75_blank, g_TAStot75_p1, g_TAStot75_q1, g_TAStot75_p1q1)
anova(g_TAStot75_blank, g_TAStot75_p1, g_TAStot75_p1q1)
summary(g_TAStot75_p1)
```
# Worker reporting time (report), comparator
```{r, echo = FALSE}
## Regression, employer reporting time
g_compreport75 <- lm(report_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 + sin6 + cos1 + cos2 + cos3 +
cos4 + cos5 + cos6,
data = lod_all[145:216,])
summary(g_compreport75)
# Removing harmonic seasonal adjustments
g_compreport75 <- lm(report_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + cos1 + cos2 + cos3 + cos4 + cos5,
data = lod_all[145:216,])
# autoregression check
acf(residuals(g_compreport75), lag.max = 36)
acf(residuals(g_compreport75), type = "partial", lag.max = 36)
g_compreport75_blank <- gls(report_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + cos1 + cos2 + cos3 + cos4 + cos5,
data = lod_all[145:216,],
method = "ML")
g_compreport75_p8 <- gls(report_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + cos1 + cos2 + cos3 + cos4 + cos5,
data = lod_all[145:216,],
correlation = corARMA(p = 8, form = ~time),
method = "ML")
# did not converge g_compreport75_q11 <- gls(report_75 ~ time + level1 + trend1 +
# sin1 + sin2 + sin3 + sin4 + cos1 + cos2 + cos3 + cos4 + cos5,
# data = lod_all[145:216,],
# correlation = corARMA(q = 11, form = ~time),
# method = "ML")
# did not converge; g_compreport75_p8q11 <- gls(report_75 ~ time + level1 + trend1 +
# sin1 + sin2 + sin3 + sin4 + cos1 + cos2 + cos3 + cos4 + cos5,
# data = lod_all[145:216,],
# correlation = corARMA(p = 8, q = 11, form = ~time),
# method = "ML")
anova(g_compreport75_blank, g_compreport75_p8)
summary(g_compreport75_p8)
```
# Worker reporting time (report), South Australia
```{r, echo = FALSE}
g_SAreport75 <- lm(report_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = lod_all[1:72,])
summary(g_SAreport75)
# Removing harmonic seasonal adjustments
g_SAreport75 <- lm(report_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos5,
data = lod_all[1:72,])
################################################## Comp
# autoregression check
acf(residuals(g_SAreport75), lag.max = 36)
acf(residuals(g_SAreport75), type = "partial", lag.max = 36)
g_SAreport75_blank <- gls(report_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos5,
data = lod_all[1:72,],
method = "ML")
g_SAreport75_p11 <- gls(report_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos5,
data = lod_all[1:72,],
correlation = corARMA(p = 11, form = ~time),
method = "ML")
g_SAreport75_q11 <- gls(report_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos5,
data = lod_all[1:72,],
correlation = corARMA(q = 11, form = ~time),
method = "ML")
# did not converge, g_SAreport75_p11q11 <- gls(report_75 ~ time + level1 + trend1 +
# sin1 + sin3 + sin4 + cos5,
# data = lod_all[1:72,],
# correlation = corARMA(p = 11, q = 11, form = ~time),
# method = "ML")
anova(g_SAreport75_blank, g_SAreport75_p11, g_SAreport75_q11)
summary(g_SAreport75_p11)
```
# Employer reporting time (notif), comparator
```{r, echo = FALSE}
g_compnotif75 <- lm(notif_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 + sin6 + cos1 + cos2 + cos3 +
cos4 + cos5 + cos6,
data = lod_all[145:216,])
summary(g_compnotif75)
# Removing harmonic seasonal adjustments
g_compnotif75 <- lm(notif_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos5,
data = lod_all[145:216,])
# check autocorrelation
acf(residuals(g_compnotif75), lag.max = 36)
acf(residuals(g_compnotif75), type = "partial", lag.max = 36)
g_compnotif75_blank <- gls(notif_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos3 + cos5,
data = lod_all[145:216,],
method = "ML")
g_compnotif75_p10 <- gls(notif_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos3 + cos5,
data = lod_all[145:216,],
correlation = corARMA(p = 10, form = ~time),
method = "ML")
g_compnotif75_q3 <- gls(notif_75 ~ time + level1 + trend1 +
sin1 + sin3 + sin4 + cos3 + cos5,
data = lod_all[145:216,],
correlation = corARMA(q = 3, form = ~time),
method = "ML")
# did not converge g_compnotif75_p10q2 <- gls(notif_75 ~ time + level1 + trend1 +
# sin1 + sin3 + sin4 + cos3 + cos5,
# data = lod_all[145:216,],
# correlation = corARMA(p = 10, q = 3, form = ~time),
# method = "ML")
anova(g_compnotif75_blank, g_compnotif75_p10, g_compnotif75_q3)
summary(g_compnotif75_blank)
```
# Employer reporting time (notif), South Australia
```{r, echo = FALSE}
g_SAnotif75 <- lm(notif_75 ~ time + level1 + trend1 +
sin1 + sin2 + sin3 + sin4 + sin5 +
sin6 + cos1 + cos2 + cos3 + cos4 + cos5 + cos6,
data = lod_all[1:72,])
summary(g_SAnotif75)
# Removing harmonic seasonal adjustments
g_SAnotif75 <- lm(notif_75 ~ time + level1 + trend1 + sin4,
data = lod_all[1:72,])
################################################## Comp
# autoregression check
acf(residuals(g_SAnotif75), lag.max = 36)
acf(residuals(g_SAnotif75), type = "partial", lag.max = 36)
g_SAnotif75_blank <- gls(notif_75 ~ time + level1 + trend1 + sin4,
data = lod_all[1:72,],
method = "ML")
g_SAnotif75_p6 <- gls(notif_75 ~ time + level1 + trend1 + sin4,
data = lod_all[1:72,],
correlation = corARMA(p = 6, form = ~time),
method = "ML")
anova(g_SAnotif75_blank, g_SAnotif75_p6)
summary(g_SAnotif75_blank)
```
## Combined graphs
```{r, echo = FALSE}
par(mfrow = c(3, 2))
par(oma = c(4, 4, 0, 0)) # make room (i.e. the 4's) for the overall x and y axis titles
par(mar = c(2, 2, 2, 2)) # make the plots be closer together
lab <- c(0.5, 6.5, 18.5, 30.5, 42.5, 54.5, 66.5, 72.5)
tick <- c(3.5, 12.5, 24.5, 36.5, 48.5, 60.5, 69.5)
# Total
pred_SAtot75 <- predict(g_SAtot75_p1, type = "response", smth)
pred_TAStot75 <- predict(g_TAStot75_p1, type = "response", smth)
pred_comptot75 <- predict(g_comptot75_p1, type = "response", smth)
## Plot with predicted models and points
plot(lod_all$tot_75[1:72],
type = "n",
ylim = c(0, 120),
xlab = "Year",
ylab = "75th percentile days",
main = "Total time",
bty = "l",
xaxt = "n",
frame.plot = FALSE,
panel.first = grid(nx = NA, ny = NULL, col = "darkgrey"))
abline(v = 30.5, lty = 2, lwd = 2, col = "darkorange1")
abline(v = 48.5, lty = 2, lwd = 2, col = "dodgerblue1")
axis(1, at = lab, labels = F)
axis(1, at = tick, labels = 2006:2012, tick = F)
points(lod_all$time[1:72], lod_all$tot_75[1:72],
type = "p",
pch = 19,
col = "darkorange1")
points(lod_all$time[73:144], lod_all$tot_75[73:144],
type = "p",
pch = 19,
col = "dodgerblue1")
points(lod_all$time[145:216], lod_all$tot_75[145:216],
type = "p",
pch = 19,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_comptot75,
lwd = 2,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_SAtot75,
lwd = 2,
col = "darkorange1")
lines((1:720 / 10 + .5),
pred_TAStot75,
lwd = 2,
col = "dodgerblue1")
# Legend
plot(lod_all$med_lod,
type = "n",
xaxt = "n",
yaxt = "n",
ann = FALSE,
bty = "n")
legend("center",
legend = c("South Australia", "South Australia implementation",
"Tasmania", "Tasmania implementation",
"Comparator"),
col = c("darkorange1", "darkorange1",
"dodgerblue1", "dodgerblue1",
"darkgrey"),
pch = c(19, NA, 19, NA, 19),
lty = c(1, 2, 1, 2, 1),
lwd = 2,
inset = .5,
bty = "n")
# Claim reporting
pred_SAlod75 <- predict(g_SAlod75_blank, type = "response", smth)
pred_TASlod75 <- predict(g_TASlod75_blank, type = "response", smth)
pred_complod75 <- predict(g_complod75_blank, type = "response", smth)
## Plot with predicted models and points
plot(lod_all$lod_75[1:72],
type = "n",
ylim = c(0, 50),
xlab = "Year",
ylab = "75th percentile days",
main = "Claim reporting time",
bty = "l",
xaxt = "n",
frame.plot = FALSE,
panel.first = grid(nx = NA, ny = NULL, col = "darkgrey"))
abline(v = 30.5, lty = 2, lwd = 2, col = "darkorange1")
abline(v = 48.5, lty = 2, lwd = 2, col = "dodgerblue1")
axis(1, at = lab, labels = F)
axis(1, at = tick, labels = 2006:2012, tick = F)
points(lod_all$time[1:72], lod_all$lod_75[1:72],
type = "p",
pch = 19,
col = "darkorange1")
points(lod_all$time[73:144], lod_all$lod_75[73:144],
type = "p",
pch = 19,
col = "dodgerblue1")
points(lod_all$time[145:216], lod_all$lod_75[145:216],
type = "p",
pch = 19,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_complod75,
lwd = 2,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_SAlod75,
lwd = 2,
col = "darkorange1")
lines((1:720 / 10 + .5),
pred_TASlod75,
lwd = 2,
col = "dodgerblue1")
# Insurer decision
pred_SAdec75 <- predict(g_SAdec75_p1, type = "response", smth)
pred_TASdec75 <- predict(g_TASdec75_blank, type = "response", smth)
pred_compdec75 <- predict(g_compdec75_p1, type = "response", smth)
## Plot with predicted models and points
plot(lod_all$dec_75[1:72],
type = "n",
ylim = c(0, 80),
main = "Insurer decision time",
xlab = "Year",
ylab = "75th percentil days",
bty = "l",
xaxt = "n",
frame.plot = FALSE,
panel.first = grid(nx = NA, ny = NULL, col = "darkgrey"))
abline(v = 30.5, lty = 2, lwd = 2, col = "darkorange1")
abline(v = 48.5, lty = 2, lwd = 2, col = "dodgerblue1")
axis(1, at = lab, labels = F)
axis(1, at = tick, labels = 2006:2012, tick = F)
points(lod_all$time[1:72], lod_all$dec_75[1:72],
type = "p",
pch = 19,
col = "darkorange1")
points(lod_all$time[73:144], lod_all$dec_75[73:144],
type = "p",
pch = 19,
col = "dodgerblue1")
points(lod_all$time[145:216], lod_all$dec_75[145:216],
type = "p",
pch = 19,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_compdec75,
lwd = 2,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_SAdec75,
lwd = 2,
col = "darkorange1")
lines((1:720 / 10 + .5),
pred_TASdec75,
lwd = 2,
col = "dodgerblue1")
# Worker reporting
pred_SAreport75 <- predict(g_SAreport75_p11, type = "response", smth)
pred_compreport75 <- predict(g_compreport75_p8, type = "response", smth)
## Plot with predicted models and points
plot(lod_all$report_75[1:72],
type = "n",
ylim = c(0, 40),
main = "Worker reporting time",
xlab = "Year",
ylab = "Median days",
bty = "l",
xaxt = "n",
frame.plot = FALSE,
panel.first = grid(nx = NA, ny = NULL, col = "darkgrey"))
abline(v = 30.5, lty = 2, lwd = 2, col = "darkorange1")
axis(1, at = lab, labels = F)
axis(1, at = tick, labels = 2006:2012, tick = F)
points(lod_all$time[1:72], lod_all$report_75[1:72],
type = "p",
pch = 19,
col = "darkorange1")
points(lod_all$time[145:216], lod_all$report_75[145:216],
type = "p",
pch = 19,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_compreport75,
lwd = 2,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_SAreport75,
lwd = 2,
col = "darkorange1")
# Employer reporting
pred_SAnotif75 <- predict(g_SAnotif75_blank, type = "response", smth)
pred_compnotif75 <- predict(g_compnotif75_blank, type = "response", smth)
# Plot with predicted models and points
plot(lod_all$notif_75[1:72],
type = "n",
ylim = c(0, 15),
main = "Employer reporting time",
xlab = "Year",
ylab = "Median days",
bty = "l",
xaxt = "n",
frame.plot = FALSE,
panel.first = grid(nx = NA, ny = NULL, col = "darkgrey"))
abline(v = 30.5, lty = 2, lwd = 2, col = "darkorange1")
axis(1, at = lab, labels = F)
axis(1, at = tick, labels = 2006:2012, tick = F)
points(lod_all$time[1:72], lod_all$notif_75[1:72],
type = "p",
pch = 19,
col = "darkorange1")
points(lod_all$time[145:216], lod_all$notif_75[145:216],
type = "p",
pch = 19,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_compnotif75,
lwd = 2,
col = "darkgrey")
lines((1:720 / 10 + .5),
pred_SAnotif75,
lwd = 2,
col = "darkorange1")
mtext('Year', side = 1, outer = TRUE, line = 2)
mtext('75th percentile days', side = 2, outer = TRUE, line = 2)
```