1

I'm trying to fit a bivariate unknown change point mixed model data comparable to the one described by Wang & McArdle, 2008 (DOI: 10.1080/10705510701758265).

I want to model a linear trend before the change point and a linear trend after the change point. The following is how I defined the respective likelihood. Is that right?

# likelihood for y1 and y2
    for(i in 1:nsubj){
        for(j in 1:ntime){

    y1[i, j] ~ dnorm(muy1[i, j], tauy1)
    muy1[i, j] <- b[i, 1] + b[i, 2] * x[i, j] + b[i, 3] * (max(0, x[i, j] - b[i, 4]))

    y2[i, j] ~ dnorm(muy2[i, j], tauy2)
    muy2[i, j] <- b[i, 5] + b[i, 6] * x[i, j] + b[i, 7] * (max(0, x[i, j] - b[i, 8]))

} }

How do I have to alter the likelihood if I assume no growth before the change point (and the intercept to be at .50) and linear growth after the change point?

Thanks in advance!

achmed
  • 33
  • 2

1 Answers1

0

The R package mcp uses JAGS to do do regression with change points, and it includes the option do have per-subject change points. Read more in the article on varying change points in mcp.

See my reply to a similar question here. Of particular interest for you, once you have a fit (fit = mcp(model, data = df)), you can see the JAGS code in cat(fit$jags_code).

To model a plateau followed by linear growth, do

model = list(
  y ~ 1,  # plateau
  1 + (1|subj) ~ 0 + x  # joined slope. Change point varies by subj
)
library(mcp)
fit = mcp(model, data = df)

Returning to your question, your likelihood looks about right if you want to model all parameters as varying-by-participant (they are all indexed with i). This looks like overkill to me, though. mcp currently only allows change points to vary and "regular" random effects on the intercepts/slopes will probably be added in the next version.

As I discuss in the article about priors in mcp (and more formally in this preprinthttps://osf.io/fzqxv/), you should think carefully about the priors for the change points. Here, you can also read how you can set the intercept to 0.5 instead of inferring it.

Jonas Lindeløv
  • 1,778
  • 1
  • 17
  • 28
  • The `mcp` package looks really promising and I'll keep an eye on it and its future developments! Coming from R and lmer I really like the fact that I can "translate" code to jags. Unfortunately, for my current project I need the random effects. – achmed Jan 20 '20 at 13:54