{"id":761,"date":"2014-01-12T18:58:40","date_gmt":"2014-01-12T18:58:40","guid":{"rendered":"http:\/\/www.georg-hosoya.de\/wordpress\/?p=761"},"modified":"2014-01-12T19:06:21","modified_gmt":"2014-01-12T19:06:21","slug":"bayesian-estimation-with-jags-and-mplus-a-quick-practical-comparison","status":"publish","type":"post","link":"https:\/\/www.georg-hosoya.de\/wordpress\/?p=761","title":{"rendered":"Bayesian estimation with JAGS and MPlus: a quick practical comparison"},"content":{"rendered":"<p>Bayesian estimation techniques were added to Mplus version 7 some time ago. Of course I was interested if MPlus and JAGS come to comparable results when let loose on data. \ud83d\ude09<\/p>\n<p>In particular I was interested in the crossclassified module of MPlus, so I wrote some code to simulate data with R and subsequently recovered the parameters with JAGS and MPlus. Recently I found out how JAGS could also be used as a data simulator for simulation studies, but this is a different topic.<\/p>\n<p>So graphically, the model I used for simulation looks like this:<br \/>\n<a href=\"http:\/\/www.georg-hosoya.de\/wordpress\/wp-content\/uploads\/2014\/01\/Diagram1.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-762\" alt=\"Diagram1\" src=\"http:\/\/www.georg-hosoya.de\/wordpress\/wp-content\/uploads\/2014\/01\/Diagram1.jpg\" width=\"797\" height=\"500\" srcset=\"https:\/\/www.georg-hosoya.de\/wordpress\/wp-content\/uploads\/2014\/01\/Diagram1.jpg 797w, https:\/\/www.georg-hosoya.de\/wordpress\/wp-content\/uploads\/2014\/01\/Diagram1-300x188.jpg 300w, https:\/\/www.georg-hosoya.de\/wordpress\/wp-content\/uploads\/2014\/01\/Diagram1-478x300.jpg 478w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><\/a><br \/>\nI have omitted the level-1 residual variances and the variances of the latent distributions in the figure for simplicity reasons. The full model specifications can be gleaned from the source code attached to this post.<\/p>\n<p>To make a long story shot: both approaches, JAGs and MPlus, pleasently come to very comparable results with regard to the parameters. At the moment I am too busy with other things to harp on this more, but I thought it is useful to put the code on the blog in case someone is interested to work on a similar topic in more detail. Thanks to Mr Asparouhov for clarifying some questions with regard to MPlus.<\/p>\n<p>The files:<br \/>\n<code>test.R<\/code>: code to simulate data from the model, recover the parameters with JAGs, also a bit of convergence diagnostics<\/p>\n<p><code>test.txt<\/code>: JAGs model file<\/p>\n<p><code>cc.inp<\/code>: MPlus input file<\/p>\n<p><code>cc.dat<\/code>: Simulated data. Will be overwritten once the simulation part of <code>test.R<\/code> is executed.<\/p>\n<p>Get the files <a href=\"http:\/\/www.georg-hosoya.de\/wordpress\/wp-content\/uploads\/2014\/01\/crossclassified.zip\">here<\/a>. The code is not very polished but should give an idea how to specify the model in MPlus and JAGs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bayesian estimation techniques were added to Mplus version 7 some time ago. Of course I was interested if MPlus and JAGS come to comparable results when let loose on data. \ud83d\ude09 In particular I was interested in the crossclassified module &hellip; <a href=\"https:\/\/www.georg-hosoya.de\/wordpress\/?p=761\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/761"}],"collection":[{"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=761"}],"version-history":[{"count":6,"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/761\/revisions"}],"predecessor-version":[{"id":773,"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/761\/revisions\/773"}],"wp:attachment":[{"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.georg-hosoya.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}