Skip to content

Instantly share code, notes, and snippets.

@benwhalley
Last active December 8, 2015 15:29
Show Gist options
  • Save benwhalley/6d2114808689163997f9 to your computer and use it in GitHub Desktop.
Save benwhalley/6d2114808689163997f9 to your computer and use it in GitHub Desktop.
// simulated data
// y = depression, t=timepoint (1 to 3), therapist=therapistcluster, id=patient
// 3 level model: observations nested in people in therapists
mixed y t || therapist: t, nocons || id:, stddev
// same model (???) using stata bayesian model fit
bayesmh y i.id i.therapist i.therapist#c.t, likelihood(normal({var_residual})) noconstant ///
prior({y:_cons}, normal(0,100)) ///
prior({var_therapist}, igamma(.001, .001)) ///
prior({var_u}, igamma(0.001,0.001)) ///
prior({var_residual}, igamma(.001, .001)) ///
prior({y:i.id}, normal({y:_cons}, {var_u})) ///
prior({y:i.therapist}, normal(0, 100)) ///
prior({y:t}, normal(0, 100)) ///
prior({y:i.therapist#c.t}, normal({y:t}, {var_therapist})) ///
/// extra block commands go here but omitted for clarity see below
mcmcs(2000) burnin(1000)
/// i've split these out, but some exta block commands to tell it to split the updates which are used in the model above
block({var_residual}, gibbs) ///
block({var_u}, gibbs) ///
block({var_therapist}, gibbs) ///
block({y:_cons}, gibbs) ///
block({y:i.id}, gibbs) ///
block({y:t}, gibbs) ///
block({y:i.therapist#c.t}, gibbs) ///
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment