MHaringa / insurancerating

R-package for actuarial pricing
https://mharinga.github.io/insurancerating
68 stars 17 forks source link

Decrease the number of simulations (e.g. n_simulations = 100) #7

Closed arodionoff closed 4 months ago

arodionoff commented 4 months ago

Thank you for developing your insurancerating project, and also for removing code execution yesterday.

premiums4 <- model_data(burn_restricted3) |>
  construct_model_points() |>
  add_prediction(burn_restricted3)

head(premiums4)

It caused a consistent error:

"j (the 2nd argument inside [...]) is a single symbol but column name '%1$s' is not found. If you intended to select columns using a variable in calling scope, please try DT [, ..%1$s]. The .. prefix conveys one-level-up similar to a file system path."

It would be nice in chunck

```{r normalitysim, message = FALSE, eval = TRUE}
check_residuals(model_freq1, n_simulations = 1000) |>
   autoplot()

set this parameter to less than 1000,for example, n_simulations = 100. Since it is unclear why the phrase follows “If that is the case, it could help to increase the number of simulations (e.g. $n = 1000$).” Moreover, with n_simulations = 1000, the execution time of this code is long on some old PCs or Posit Cloud.

I dare to offer you the most compact code, instead of creating two additional variables:

MTPL2 |>    # use an anonymous function
    ( \(d) mutate(d, year = sample(2016:2019, nrow(d), replace = TRUE)) )() |>
    univariate(x = area, nclaims = nclaims, 
               exposure = exposure, by = year) |>
    autoplot(show_plots = 1)
MHaringa commented 4 months ago

Hi Alexander,

Thank you for raising this issue.

I can indeed reproduce the problem. The function in question was still experimental and had not been thoroughly tested for smoothed and/or restricted models. I have resolved this issue in the development version of the package.

Additionally, I have adjusted the number of simulations in the example.

Thank you for your feedback, and have a good day.

Best, Martin