Brms model: am I using the splines correctly for adjusting?

Could you just confirm that I am using splines in a correct way.

After adjusting for age, my model (below) lognormal part started to show unrealistic (not matching with explanatory data analysis) y variable values.

`brm(bf(y ~ age + sex + (1 | county), hu ~ age + sex + (1 | county)), data = dataforhospitalcaremodels, family = hurdle_lognormal(), cores = 3, chains = 3, control = list(adapt_delta = 0.99))`

Plotting showed that y-variable and age had non-linear relationship, varying between the counties. Using the binning of age variable also solved the problem, but statisticians would not look well on that approach. Thus, I read that I should use splines (mgcv package). I tried the following:

`brm(bf(y ~ s(age) + sex + (1 | county), hu ~ s(age) + sex + (1 | county)), data = dataforhospitalcaremodels, family = hurdle_lognormal(), cores = 3, chains = 3, control = list(adapt_delta = 0.99))`

And y-variable conditional means were matching explanatory data analysis. And now the age is adjusted between the counties?

I am not entirely sure I understand the question

But if

the specification s(age, by = "country") will generate a model where country-specific non-linear effects of age are estimated.

There are some additional details one might want to consider when setting up hierarchical GAM. This seems like a good introduction.