library(tidyverse)
library(ggplot2)
library(plotly)
# library(kableExtra)
library(DT)
library(data.table)
library(dygraphs)
library(latticeExtra)
library(stringr)
library(hrbrthemes)
library(patchwork)
library(tinytex)
library(dplyr)
library(Metrics)
# print the table and add filter; this will allow us view data with a filter and gives us the ability to print the filtered table from the html file.
datatable(LR_df,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
))
AggLR_COB <- LR_df %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
aggrCLR = sum(VRUInc)/sum(CATPrem),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(AggLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Table 2: ', htmltools::em('Aggregate Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
hanna_events <- LR_df %>%
filter(Event == 'Hanna')
hanna_aggr_LR <- hanna_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(hanna_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
# add caption: average Total and CAT Loss Ratios weren't too bad, however, in aggregate, you we see significant losses (19% & 27% vs. 99% and 135% respectively). Telling us there were few instances with significant losses.
hanna_aggrLR_COB <- hanna_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(hanna_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Hanna: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
laura_events <- LR_df %>%
filter(Event == 'Laura')
laura_aggr_LR <- laura_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(laura_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
laura_aggrLR_COB <- laura_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(laura_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Laura: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
sally_events <- LR_df %>%
filter(Event == 'Sally')
sally_aggr_LR <- sally_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(sally_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
sally_aggrLR_COB <- sally_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(sally_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Sally: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
delta_events <- LR_df %>%
filter(Event == 'Delta')
delta_aggr_LR <- delta_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(delta_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
delta_aggrLR_COB <- delta_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(delta_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Delta: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
zeta_events <- LR_df %>%
filter(Event == 'Zeta')
zeta_aggr_LR <- zeta_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(zeta_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
zeta_aggrLR_COB <- zeta_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(zeta_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Zeta: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
ida_events <- LR_df %>%
filter(Event == 'Ida')
ida_aggr_LR <- ida_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(ida_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
ida_aggrLR_COB <- ida_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(ida_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Ida: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
ian_events <- LR_df %>%
filter(Event == 'Ian')
ian_aggr_LR <- ian_events %>%
summarise(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(ian_aggr_LR,
rownames = FALSE,
colnames = c('# of Occurences' = 1, 'Overall Total Loss Ratio' = 2, 'Overall CAT Loss Ratio' = 3, 'Total Gain(+) | Loss(-)' = 4, 'CAT Gain(+) | Loss(-)' = 5)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
ian_aggrLR_COB <- ian_events %>%
group_by(COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
#avgTLR = mean(TotPrem_LR),
aggrCLR = sum(VRUInc)/sum(CATPrem),
#avgCLR = mean(CATPrem_LR),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(ian_aggrLR_COB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Ian: ', htmltools::em('Overall Loss Ratios by COB')),
colnames = c('Class of Business' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
tot_aggLR_byevent <- LR_df %>%
group_by(Event) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
aggrCLR = sum(VRUInc)/sum(CATPrem),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(tot_aggLR_byevent,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'All Events: ', htmltools::em('Overall Loss Ratios')),
colnames = c('Event' = 1, '# of Occurences' = 2, 'Overall Total Loss Ratio' = 3, 'Overall CAT Loss Ratio' = 4, 'Total Gain(+) | Loss(-)' = 5, 'CAT Gain(+) | Loss(-)' = 6)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
tot_aggLR_byeventCOB <- LR_df %>%
group_by(Event, COB) %>%
summarize(n = n(),
aggrTLR = sum(VRUInc)/sum(TotalPremium),
aggrCLR = sum(VRUInc)/sum(CATPrem),
net1 = sum(Tot_Gain_Loss),
net2 = sum(CAT_Gain_Loss))
datatable(tot_aggLR_byeventCOB,
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'All Events: ', htmltools::em('Overall Loss Ratios')),
colnames = c('Event' = 1, 'COB' = 2, '# of Occurences' = 3, 'Overall Total Loss Ratio' = 4, 'Overall CAT Loss Ratio' = 5, 'Total Gain(+) | Loss(-)' = 6, 'CAT Gain(+) | Loss(-)' = 7)) %>%
formatPercentage(c('Overall Total Loss Ratio', 'Overall CAT Loss Ratio'), 3) %>%
formatCurrency(c('Total Gain(+) | Loss(-)', 'CAT Gain(+) | Loss(-)'), currency = "", interval = 3, mark = ",")
test_facetwrap <- LR_df %>%
filter(TotPrem_LR > 150) %>%
ggplot(aes(TotPrem_LR, fill = Event)) +
geom_histogram() +
#labs(title = "Possible Adverse Class Selection", subtitle = "COB performance over time", x = "", y = "VRU Loss") +
facet_wrap(~ COB) +
theme_bw()
ggplotly(test_facetwrap)
This Total Loss Ratio facetwrap is to (1) identify the COBs with high loss ratios and (2) identify the events with loss ratios over 150%. Capturing this could lead us to further analysis of certain COBs. The resulting COBs and their respective performance will be visualized via premium collected vs loss incurred. It’s important to note that the resulting graphs will showcase performance for that COB, by event, as a whole.
ggplotly(LR_df %>%
filter(COB == 'Apartments') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Apartments') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Church') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Church') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Condominium') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Condominium') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Education') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Education') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Entertainment') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Entertainment') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'HotelsMotels') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: HotelsMotels') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Office') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Office') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Restaurant') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Restaurant') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Retail') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Retail') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'RetailwRefrigEquip') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: RetailwRefrigEquip') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Service') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = TotalPremium, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Total Collected Premium', title = 'High Loss COB: Service') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
test_facetwrap <- LR_df %>%
filter(CATPrem_LR > 150) %>%
ggplot(aes(CATPrem_LR, fill = Event)) +
geom_histogram() +
#labs(title = "Possible Adverse Class Selection", subtitle = "COB performance over time", x = "", y = "VRU Loss") +
facet_wrap(~ COB) +
theme_bw()
ggplotly(test_facetwrap)
This CAT Loss Ratio facetwrap is to (1) identify the COBs with high loss ratios and (2) identify the events with loss ratios over 150%. Capturing this could lead us to further analysis of certain COBs. The resulting COBs and their respective performance will be visualized via premium collected vs loss incurred. It’s important to note that the resulting graphs will showcase performance for that COB, by event, as a whole.
ggplotly(LR_df %>%
filter(COB == 'Apartments') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Apartments') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Church') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Church') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Condominium') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Condominium') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Education') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Education') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Entertainment') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Entertainment') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'GasStations') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Gas Stations') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Healthcare') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Healthcare') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'HotelsMotels') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: HotelsMotels') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Office') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Office') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Restaurant') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Restaurant') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Retail') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Retail') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'RetailwRefrigEquip') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: RetailwRefrigEquip') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Service') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Service') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)
ggplotly(LR_df %>%
filter(COB == 'Wholesalers') %>%
ggplot(aes(x = Event)) +
geom_col(aes(y = CATPrem, fill = Event)) +
geom_col(aes(y = -VRUInc)) +
labs(x = 'Event', y = 'Incurred Losses <--> Collected CAT Premium', title = 'High Loss COB: Wholesalers') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
)