Fixing GP parameters in brms

For the model:

fit = brm(y ~ gp(x), data)

Is there a way to just set sdgp and lscale to constant values (not infer them)?

Not from the brms interface. You would need to create the underlying stan code via make_stancode and then amend it.

1 Like

Yo @paul.buerkner, how difficult would it be to add a fixed parameter class to brms?

Like right now I might specify set_prior("normal(0, 1)", class = "sd") in my model. What’d it take to get something like set_prior("fixed(1.5)", class = "sd"), where all the parameters that matched that would just get moved to data and set to a certain value (1.5, in this case)?

@andrewgelman bought this up yesterday for some regression experiments he wants to do. I hacked together something once using make_stancode, but it’d be way easier to experiment with if it were a brms feature.

I guess this is me just asking you if you could do this in a not-so-thinly veiled way :D. I offer you my praise and adoration! And also I’ll offer you Andrew’s praise and adoration he probably won’t mind. But also if it’s easy and you think I could manage it (if I just dug in) tell me that and I’ll go dig in.


Hi, Paul. I’m happy to give more background on why this would be a good thing. I guess we could also hack something using some R script to move code from the parameters block to the data block in the Stan program, and then demonstrate with some examples how great it works, and that would motivate including it as a standard feature. I think this will come up a lot and be super useful to lots of users.

I agree with the two of you and had several use cases for this feature myself in the past. I opened an issue for it on github

Comments are welcome.

If I find the time, I may try to implement it next week.


In the latest github version of brms, fixing parameter values is now fully supported! See for examples. I would be grateful if people could try out this new feature and give me feedback on how well it works.


Hi, Paul. That’s sounds great! I’ll have to try it out.

To install from github (where this version is currently) you’ll need to do: