Monotonic/shape constrained splines still possible in brms?

Hoping that @paul.buerkner or anyone else might be able to weigh in on whether it is (still?) possible to include monotonic spline terms in models fit with brms. I saw a thread from Jan '19 indicating that it is workable, though possibly involving some modifications to the scam pacakge. However, when I run the minimal working example posted on that thread (here) after modifying the scam source code as suggested, the resulting smooths are decidedly not monotonic. Of course, alternative suggestions for incorporating monotonic smooth of continuous covariates would be also welcome. Thanks!

# minimal example
library(brms)
library(scam) # N.B. this is compiled from source with modifications per referenced post
b = brm(time ~ s(age, bs = "mpi"), data = kidney)
marginal_smooths(b, spaghetti = T, nsamples = 10)

# system info
version
               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
minor          6.2                         
year           2019                        
month          12                          
day            12                          
svn rev        77560                       
language       R                           
version.string R version 3.6.2 (2019-12-12)
nickname       Dark and Stormy Night 

# brms version: 2.10.0
3 Likes

I don’t know to be honest. I am also confused why scam doesn’t naturally play well with the standard post-processing of mgcv that I apply in brms but I am sure the authors have good reasons for this other behavior. It may be worth asking the package maintainer of scam about this. Right now, brms works well only with smooths that follow the standard mgcv logic so can be reliability post-processed in brms.

2 Likes