-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-summary.Rmd
88 lines (78 loc) · 2.72 KB
/
03-summary.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Executive Summary {#summary}
Estimated unpaid loss & ALAE as of `r params$val_date`:
```{r summary, fig.cap = "Summary of Loss & ALAE"}
paid_proj <- latest(paid_tri) %>%
left_join(sel_paid_cdfs[, -3], by = "age") %>%
mutate(paid_proj = value * cdfs)
rpt_proj <- latest(rpt_tri) %>%
left_join(sel_rpt_cdfs[, -3], by = "age") %>%
mutate(rpt_proj = value * cdfs)
est_ult <- left_join(paid_proj[, c(1, 5)], rpt_proj[, c(1, 5)], by = "origin") %>%
mutate(sel_ult = rpt_proj)
out <- left_join(latest(paid_tri), latest(rpt_tri), by = c("origin", "age")) %>%
select(-age)
names(out)[2:3] <- c("paid", "reported")
out <- out %>%
mutate(case = reported - paid) %>%
left_join(est_ult[, c("origin", "sel_ult")], by = "origin") %>%
mutate(ibnr = sel_ult - reported,
unpaid = sel_ult - paid)
out_display <- out %>%
blank_row() %>%
totals_row(cols = 2:7, label_col = 1)
col_names <- htmltools::withTags(table(
class = 'display',
thead(
tr(
th(rowspan = 2, "Policy Period"),
th(colspan = 6, paste0("Loss & ALAE at ", params$accounting_date))
),
tr(
th("[1]", br(), "Paid", style = 'text-align: center'),
th("[2]", br(), "Reported", style = 'text-align: center'),
th("[3]", br(), "Case", style = 'text-align: center'),
th("[4]", br(), "Ultimate", style = 'text-align: center'),
th("[5]", br(), "IBNR", style = 'text-align: center'),
th("[6]", br(), "Unpaid", style = 'text-align: center')
)
)
))
DT::datatable(
out_display,
rownames = FALSE,
container = col_names,
options = list(
dom = 't',
ordering = FALSE,
columnDefs = list(
list(targets = 0, class = "dt-center")
)
),
escape = FALSE
) %>%
formatCurrency(
2:7,
currency = "",
digits = 0
) %>%
frameWidget(height = '100%')
```
Notes:
[1] and [2] *provided by `r params$company_short`*
[3] *= [2] - [1]*
[4] *see figure \@ref(fig:sel-ult)*
[5] *= [4] - [2]*
[6] *= [4] - [1]*
```{r}
library(RColorBrewer)
plot_ly(out, x = ~origin, y = ~paid, type = 'bar', name = 'Paid', marker = list(color="#1C2F2F"),
text = ~paste0("Paid: ", paid)) %>%
add_trace(y = ~case, name = 'Case', marker = list(color="#264E86"),
text = ~paste0("Case: ", case)) %>%
add_trace(y = ~round(ibnr, 0), name = 'IBNR', marker = list(color="#5E88FC"),
text = ~paste0("IBNR: ", ibnr)) %>%
layout(yaxis = list(title = 'Loss & ALAE'),
xaxis = list(title = 'Policy Period'),
barmode = 'stack') %>%
config(displaylogo = FALSE, displayModeBar = FALSE)
```