I have a series of questions that relate to using a Generalized Additive Model concept the smoothing variable s() in brms model application to model projected claim payments for claims grouped by the year the incident occurred (Acc_Yr) as the claims age by year (Dev_Yr):

• How would I set priors for the variable s(Dev_Yr,k =3, m=2) for both the fixed and the random effects component where Dev_Yr is the smoothed variable?

• Also, how do I interpret the results for the fixed parameter which results from this model for the smoothed development year estimates given it is a single value?

• How would I simulate the implied results using the prior distribution values when using a smoothed term in a Generalized Additive Model format?

```
code_to_run_your_model(if_applicable)
```

The set of priors that I am using at this point is:

GAM_prior ← c(prior(normal(.02,.01),class=b, coef=Cal_Yr_Time),

prior(normal(-.1,.02),class=b, coef=Dev_Yr_10_Cap,dpar=sigma),

prior(student_t(3,.1,.02),class=b, coef=Dev_Yr_10_Spline,dpar=sigma))

The model is:

Model_GAM ← brm(bf(Trended_Incr_PP_Def ~ s(Dev_Yr, k=3, m=2) +Cal_Yr_Time,

sigma ~ Dev_Yr_10_Cap + Dev_Yr_10_Spline ),

iter = 4000,

prior= GAM_prior,

seed= 8603529,

control = list(adapt_delta = .99),

data = Train_Triangle_All_Operation, family = lognormal())

If possible, add also code to simulate data or attach a (subset of) the dataset you work with.

set.seed(8603529)

Triangle_Dates_Operation ← expand_grid(Acc_Yr= 2000:2021, Dev_Yr=1:30) %>%

mutate(Dev_Yr_Sqrd = Dev_Yr *Dev_Yr,
Dev_Yr_Cbd =Dev_Yr** 3,

Rptd_Cnt = case_when(

Acc_Yr == 2000 ~ 1600,

Acc_Yr == 2001 ~ 1500,

Acc_Yr == 2002 ~ 1700,

Acc_Yr == 2003 ~ 1800,

Acc_Yr == 2004 ~ 1500,

Acc_Yr == 2005 ~ 1600,

Acc_Yr == 2006 ~ 1800,

Acc_Yr == 2007 ~ 1700,

Acc_Yr == 2008 ~ 1800,

Acc_Yr == 2009 ~ 1600,

Acc_Yr == 2010 ~ 1800,

Acc_Yr == 2011 ~ 1400,

Acc_Yr == 2012 ~ 1500,

Acc_Yr == 2013 ~ 1400,

Acc_Yr == 2014 ~ 1600,

Acc_Yr == 2015 ~ 1700,

Acc_Yr == 2016 ~ 1500,

Acc_Yr == 2017 ~ 1700,

Acc_Yr == 2018 ~ 1900,

Acc_Yr == 2019 ~ 1800,

Acc_Yr == 2020 ~ 1900,

Acc_Yr == 2021 ~ 1800,

),

Cal_Yr = Acc_Yr + Dev_Yr-1

)

Change_Operation ← Triangle_Dates_Operation %>%

group_by(Acc_Yr, Dev_Yr) %>%

mutate(Ln_Dev_Yr =log(Dev_Yr),

p_rate = exp(-2 + Dev_Yr * (-.4) + Dev_Yr_Sqrd * (0) + Ln_Dev_Yr * (2.0)),

p_rate_adj =Rptd_Cnt * p_rate,

mu_ln =(2+ Dev_Yr * (-.6 )+ Dev_Yr_Sqrd * (0) + Ln_Dev_Yr * (4.5)),

sigma_ln = exp(-2.0 +Dev_Yr *.05+ Dev_Yr_Sqrd * 0 + (.0)*Ln_Dev_Yr),

Paid_Cnt = rpois(1,lambda =p_rate_adj) ,

Expected_Payment= exp(mu_ln + .5 * (sigma_ln**2)),

Mean_Payment = if_else (Paid_Cnt ==0, 0,

mean(rlnorm(Paid_Cnt,meanlog = mu_ln,sdlog=sigma_ln))),

Incr_Payment = Paid_Cnt * Mean_Payment,

Pure_Prem =Incr_Payment/Rptd_Cnt)

Cal_Yr_Trend ← expand_grid(Cal_Yr = 2000:2060) %>%

group_by(Cal_Yr) %>%

mutate(Infl_Index =rlnorm(1,.03,.02),

Loss_Cost_Adj = rlnorm(1,.01,.01),

Loss_Cost_Trend = Infl_Index* Loss_Cost_Adj,

Infl_Index_Mid =Infl_Index **.5,

Loss_Cost_Adj_Mid =Loss_Cost_Adj **.5 ,

Loss_Cost_Trend_Mid =Infl_Index_Mid * Loss_Cost_Adj_Mid)

Cal_Yr_Trend_Acc ← Cal_Yr_Trend %>%

ungroup() %>%

mutate(Accum_Trend =cumprod(Loss_Cost_Trend),

Accum_Infl_Index =cumprod(Infl_Index),

Accum_Infl_Index =cumprod(Infl_Index),

Accum_Loss_Cost_Trend_Mid =if_else(Cal_Yr == min(Cal_Yr),

Loss_Cost_Trend_Mid,

Loss_Cost_Trend_Mid* lag(Accum_Trend)),

Accum_Infl_Index_Mid =if_else(Cal_Yr == min(Cal_Yr),

Infl_Index_Mid,

Infl_Index_Mid* lag(Accum_Infl_Index)))

Complete_Triangle_Operation ← left_join(Change_Operation,Cal_Yr_Trend_Acc, by=c(‘Cal_Yr’)) %>%

mutate(Trended_Incr_Payment = Incr_Payment * Accum_Loss_Cost_Trend_Mid,

Trended_Incr_Payment_Def =Trended_Incr_Payment/Accum_Infl_Index_Mid,

Trended_Incr_PP =Trended_Incr_Payment/Rptd_Cnt,

Trended_Mean_Payment = Mean_Payment * Accum_Loss_Cost_Trend_Mid,

Trended_Mean_Payment_Def = Trended_Mean_Payment/Accum_Infl_Index_Mid,

Trended_Incr_PP_Def =Trended_Incr_Payment_Def/Rptd_Cnt,

Paid_Cnt_Freq =Paid_Cnt/Rptd_Cnt,

Ln_Paid_Cnt_Freq = log(Paid_Cnt_Freq),

Inv_Rptd_Cnt =1/Rptd_Cnt,

Ln_Trd_Incr_PP =log(Trended_Incr_PP),

Ln_Trd_Incr_PP_Def =log(Trended_Incr_PP_Def),

Ln_Mean_Payment_No_Trend =log(Mean_Payment),

Ln_Mean_Payment_Def =log(Trended_Mean_Payment_Def),

Cal_Yr_Time = Cal_Yr - 2000,

Dev_Yr_6_Cap = if_else(Dev_Yr < 6, Dev_Yr,

as.integer(6) ),

Dev_Yr_6_Spline=if_else(Dev_Yr < 6,0,

Dev_Yr-5),

Dev_Yr_6_Cap_Sqrd = Dev_Yr_6_Cap * Dev_Yr_6_Cap ,

```
Dev_Yr_1_Factor = as.factor(case_when(
Dev_Yr == 1 ~ 1,
Dev_Yr >1 ~2
)),
Dev_Yr_8_Cap = if_else(Dev_Yr < 8, Dev_Yr,
as.integer(8) ),
Dev_Yr_8_Spline=if_else(Dev_Yr < 8,0,
Dev_Yr-7),
Dev_Yr_8_Cap_Sqrd = Dev_Yr_8_Cap * Dev_Yr_8_Cap ,
Dev_Yr_1_Factor = as.factor(case_when(
Dev_Yr == 1 ~ 1,
Dev_Yr >1 ~2
)),
Dev_Yr_3_Factor = as.factor(case_when(
Dev_Yr == 1 ~ 1,
Dev_Yr == 2 ~2,
Dev_Yr == 3 ~3,
Dev_Yr > 3 ~4
)),
Dev_Yr_2_Factor = as.factor(case_when(
Dev_Yr == 1 ~ 1,
Dev_Yr == 2 ~2,
Dev_Yr > 2 ~3
)),
Dev_Yr_3_14_Factor = as.factor(case_when(
Dev_Yr == 1 ~ 1,
Dev_Yr == 2 ~2,
Dev_Yr == 3 ~3,
Dev_Yr == 4 ~4,
Dev_Yr == 5 ~4,
Dev_Yr == 6 ~4,
Dev_Yr == 7 ~4,
Dev_Yr == 8 ~4,
Dev_Yr == 9 ~4,
Dev_Yr == 10 ~4,
Dev_Yr == 11 ~4,
Dev_Yr == 12 ~4,
Dev_Yr == 13 ~4,
Dev_Yr >13 ~5,
)),
Dev_Yr_2_14_Factor = as.factor(case_when(
Dev_Yr == 1 ~ 1,
Dev_Yr == 2 ~2,
Dev_Yr == 3 ~3,
Dev_Yr == 4 ~3,
Dev_Yr == 5 ~3,
Dev_Yr == 6 ~3,
Dev_Yr == 7 ~3,
Dev_Yr == 8 ~3,
Dev_Yr == 9 ~3,
Dev_Yr == 10 ~3,
Dev_Yr == 11 ~3,
Dev_Yr == 12 ~3,
Dev_Yr == 13 ~3,
Dev_Yr >13 ~4,
)),
Dev_Yr_10_Spline =if_else(Dev_Yr < 10,0,
Dev_Yr - 9),
Dev_Yr_10_Cap =if_else(Dev_Yr < 10,Dev_Yr,
as.integer(10)),
Dev_Yr_12_Spline =if_else(Dev_Yr < 12,0,
Dev_Yr - 11),
Dev_Yr_10_Spline_Cap_15 = case_when(
Dev_Yr < 10 ~0,
Dev_Yr < 16 ~Dev_Yr-9,
Dev_Yr >15 ~15),
Dev_Yr_10_Spline_Ln =if_else(Dev_Yr < 10,0,
log(Dev_Yr_10_Spline)),
Dev_Yr_15_Spline =if_else(Dev_Yr < 15,0,
Dev_Yr - 14),
Dev_Yr_15_Spline_Ln =if_else(Dev_Yr < 15,0,
log(Dev_Yr_15_Spline)))
```

Train_Triangle_All_Operation ← Complete_Triangle_Operation %>%

filter(Cal_Yr < 2022) %>%

mutate(Z_Count= if_else(Paid_Cnt ==0,1,0))

Please also provide the following information in addition to your question:

- Operating System: Windows 10
- brms Version: 2.18.0

Looking forward to your topic!