prior for me() independent variable, plus mapping between brms and Stan syntax

35 views
Skip to first unread message

Shravan Vasishth

unread,
Feb 14, 2018, 6:10:17 AM2/14/18
to brms-users
Hi all,

I'm a newbie with brms. I am trying to fit a measurement error model like this:

brm(formula = y  ~ 1 + me(x,xse) + (1 | subj)+(1 | item)

how do i specify a prior on x? I used get_prior to work out that I could define a prior on something called mexxse, which is a concatentation of the name in the measurement error part. Is this correct?

The model I want to fit in Stan syntax is:

model {
  vector[N] mu;
  //priors
  true_mvdur ~ normal(0, 200);
  meanvdur ~ normal(true_mvdur, se); // measurement model
  beta[1] ~ normal(0, 200);
  beta[2] ~ normal(0, 50);
  sigma_e ~ normal(0, 100);
  sigma_u ~ normal(0, 100);
  sigma_w ~ normal(0, 100);
  u ~ normal(0, sigma_u);
  w ~ normal(0, sigma_w);
  // likelihood
  mu = beta[1] + u[subj] + w[item] + beta[2] * true_mvdur[subj];
  y ~ normal(mu, sigma_e);
}

The formula I use is:

brm(formula = y  ~ 1 + me(meanvdur,se) + (1 | subj)+(1 | item)

Is this the correct translation from Stan to brms? Looking at the stancode() output from the brms model is not very easy to parse for me as there seem to be lots of internal variables.

The priors:

priors<-c(set_prior("normal(0,200)", 
                    class = "b"),
                      set_prior("normal(0,50)", class = "b",coef="memeanvdurse"),
                      set_prior("normal(0,100)", class = "sd"),
          set_prior("normal(0,100)", class = "sigma")
          )


Paul Buerkner

unread,
Feb 14, 2018, 6:43:39 AM2/14/18
to Shravan Vasishth, brms-users
This looks correct to me. But the best check is to run the models and see if they give the same results (up to MCMC error).

Please make sure to use brms >= 2.1.0, whenever you apply me() terms, because there was a bug in the earlier versions.

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/99c83766-9ee9-4b41-bd7d-7d26d1c79de3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shravan Vasishth

unread,
Feb 15, 2018, 2:50:45 AM2/15/18
to brms-users
Yes, I asked because my Stan model results and the brms results did not match (I forgot to mention that important detail). The mismatch was because of the old version of brms I was using. Once I installed from the dev version, my results match.

thanks for the help,
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages