Skip to content

Commit

Permalink
Merge pull request #38 from jimbrig/develop
Browse files Browse the repository at this point in the history
Upstream Feature Branch Merges
  • Loading branch information
jimbrig authored Feb 15, 2022
2 parents 60b2cbe + 1cb7600 commit c329277
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Imports:
utils
Suggests:
actuar,
covr,
dbplyr,
devtools,
fplot,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ importFrom(dbx,dbxInsert)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,case_when)
importFrom(dplyr,coalesce)
importFrom(dplyr,collect)
importFrom(dplyr,desc)
Expand Down
30 changes: 16 additions & 14 deletions R/actuary-claim_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
#' @return a list containing a) claim details b) transactional history c) interactive timeline
#' @export
#'
#' @importFrom dplyr arrange filter distinct select pull mutate rowwise lag transmute
#' @importFrom dplyr arrange filter distinct select pull mutate rowwise lag transmute case_when
#' @importFrom formattable currency
#' @importFrom lubridate as_date
#' @importFrom shiny HTML
#' @importFrom timevis timevis
view_claim_history <- function(claim_id, claims_data = NULL) {

if (is.null(claims_data)) claims_data <- claims_transactional
if (is.null(claims_data)) {
claims_data <- claims_transactional
}

claim_dat <- dplyr::filter(claims_data, .data$claim_id == .env$claim_id) |>
dplyr::arrange(.data$transaction_date)
Expand All @@ -43,7 +45,7 @@ view_claim_history <- function(claim_id, claims_data = NULL) {
incr_rept = .data$reported - dplyr::lag(.data$reported, default = 0, order_by = .data$transaction_date),
incr_case = .data$case - dplyr::lag(.data$case, default = 0, order_by = .data$transaction_date),
incr_status = paste0(dplyr::lag(.data$status, default = "NEW", order_by = .data$transaction_date), " -> ", .data$status),
status_details = case_when(
status_details = dplyr::case_when(
.data$incr_status == "NEW -> Open" ~ "Status: Claim Opened",
.data$incr_status == "Open -> Open" ~ "Status: No Change",
.data$incr_status == "Closed -> Closed" ~ "Status: No Change",
Expand Down Expand Up @@ -92,21 +94,21 @@ view_claim_history <- function(claim_id, claims_data = NULL) {

trans_hist_out <- dplyr::select(
claim_trans_hist,
-c(`Transaction ID`,
`Paid Change`,
`Case Reserve Change`,
`Reported Change`,
`Status Details`,
`Status`,
`Transaction Details`)
-c(.data$`Transaction ID`,
.data$`Paid Change`,
.data$`Case Reserve Change`,
.data$`Reported Change`,
.data$`Status Details`,
.data$`Status`,
.data$`Transaction Details`)
)

timeline <- dplyr::transmute(
claim_trans_hist,
id = `Transaction ID`,
content = `Transaction Date`,
start = `Transaction Date`,
title = shiny::HTML(`Transaction Details`)
id = .data$`Transaction ID`,
content = .data$`Transaction Date`,
start = .data$`Transaction Date`,
title = shiny::HTML(.data$`Transaction Details`)
) |>
timevis::timevis(options = list("tooltip.overflowMethod" = "none"))

Expand Down
8 changes: 7 additions & 1 deletion R/actuary-simulate_claims.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
#' @param start_date,end_date Character/Date - Start and End dates for simulation to create claims within (experience_period).
#' @param seed Numeric - the seed is used to isolate randomness during statistical simulations.
#' @param loss_distribution Character - must be one of the distributions mentioned in the details below. Defaults to lognormal.
#' @param probability_open Numeric - must be within `0 < x < 1` and represents probability a claim is open when running binomial simulations for claims' status.
#' @param params Parameters associated with the specified `loss_distribution`
#' in a list (i.e. `list(mean_log = 7.5, sd_log = 1.5)` for lognormal distribution).
#' @param status_prob_open Numeric - must be within `0 < x < 1` and represents
#' probability a claim is open when running binomial simulations for claims'
#' status.
#' @param cache Boolean/Logical - enable caching?
#' @param ... If needed
#'
#' @details
#'
Expand Down
2 changes: 1 addition & 1 deletion R/meta-globals.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
utils::globalVariables(
c(
""
"claims_transactional"
)
)
Binary file added inst/images/loss-reserving-workflow-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
11 changes: 10 additions & 1 deletion man/simulate_claims.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c329277

Please sign in to comment.