Piecewise Linear Mixed Models With a Random Change Point

Thank you for providing this example @paul.buerkner . I’m trying something similar, but I also want to test the hypothesis that there is a changepoint in the independent variable (age in this example). Specifically, how would you go about testing if alpha is significant. I hypothesize that it will be significant in some cases and insignificant in others in my dataset, and I want to determine which are significant.

I can get the posteriors on alpha and omega by running

coefs <- coef(fit, summary = FALSE)
alphas <- coefs[[1]][, , 3]
omegas <- inv_logit(alphas) * 10

But the bounds on omega make it difficult to test significance. How would you test to see if omega is significantly different from zero?
Thank you

using posterior samples for inference you cannot test against a value that is outside or at the boundary of the definition space unfortunately.

Thank you for your response @paul.buerkner. Of course-this makes sense.
So if you were going to use brms to set up a test to see if a one group in your dataset person in this example has a change point in it (and find that changepoint if there is one), how would you do that?
My plan is to run a model with a changepoint and one without and compare them with LOO and/or WAIC. This can tell me if I have a changepoint and then if I have one, I can find what it is.
I’m interested to hear if folks have other ideas, though.
Thank you

Is there a way to plot this trend but grouped by “person”?

I had a look online but I cannot find anthing revelant.

I ended up developing a new R package for these multiple-change point problems: {mcp}. It has native support for plotting per-group change points and fits: Varying change points • mcp.

It uses JAGS as a backend, though. Would love to do a stan version at one point.

2 Likes

I would like to model group wise, slope 1, slope 2, and change point. Is it possible with mcp?

If not, would it be possible to use your plotting framework for brms results?

Only groupwise change points for now. The upcoming version 0.4 will do multiple regression including categorical predictors and interactions, which can be used to model group-wise slopes, but it’ll be a while before it’s out.

Anyway, if you have more questions about mcp, I’m happy to continue the discussion at lindeloev/mcp · Discussions · GitHub. We should not hijack the stan forums for a discussion about an interface to JAGS ;-)