Setting Priors for splines with `by` variables

I have a model with the term s(nvc,m=1,by=os). In the model summary, I see

Smooth Terms:
                        Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sds(snvcosDarwin_1)         0.16      0.09     0.06     0.38 1.00     1865     2139
sds(snvcosLinux_1)          0.35      0.27     0.08     1.03 1.00     2180     2867
sds(snvcosWindows_NT_1)     0.11      0.06     0.04     0.26 1.00     1734     2173

How to specify priors for the smooth terms? In prior_summary I only see

                  prior     class                         coef     group resp  dpar nlpar bound
1                               b
...
...
7                             sds              s(nvc,m=1,by=os)

Thanks much

If you do get_prior(your_model_formula,your_data,your_family) it should give you the answer.

It’ll be something like

prior<- prior_string("normal(0,3)",class="b",coef="snvc:osLinux_1")+
  prior_string("normal(0,3)",class="b",coef="snvc:osWindows_NT_1")+
  prior_string("student_t(10,0,5)",class="sds")...

You can use paste() or paste0() to make it simpler if you have lots of levels to your factor

prior<-prior_string("normal(0,3)",class="b",coef=paste0(paste("snvc",unique(model_data$os),sep=":")"_1"))+...

You get the idea :)

Edit

Btw, setting priors on these can be hard. So, best to set them and then sample from the prior by specifying sample_prior=“only” in the brm call. Then you can see if it’s reasonable by looking at spaghetti plots with marginal/conditional effects. You don’t want priors that allow completely unrealistic associations etc.

Nice idea! thanks