<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Jeff,<div>I agree that R2admb is the easiest way to get data into ADMB and get results out of it. </div><div>I have a couple of examples posted also.</div><div><a href="http://www.admb-project.org/examples/r-stuff/gamma-distributed-myxomatosis-using-r2admb">http://www.admb-project.org/examples/r-stuff/gamma-distributed-myxomatosis-using-r2admb</a></div><div><a href="http://www.admb-project.org/examples/glmm-generalized-linear-mixed-models/negative-binomial-fir-fecundity-1">http://www.admb-project.org/examples/glmm-generalized-linear-mixed-models/negative-binomial-fir-fecundity-1</a> </div><div><div><br class="webkit-block-placeholder"></div><div>The example at the first link shows a comparison of using a completed tpl file versus letting R2admb write the DATA_SECTION and PARAMETER_SECTION. The benefit of writing those sections yourself is that you can use the same tpl file on datasets of different sizes. R2admb hard codes the dimension sizes into the tpl file.</div><div><br></div><div>I also highly recommend using R2admb for getting mcmc results out of the psv file. I recently saved a colleague from reinventing the wheel by showing him the code below that runs the bcb example (distributed in admb-trunk/examples/admb-re). I'll write this up more formally sometime soon. There are also many examples coming soon from an NCEAS working group.</div><div><br></div><div>cheers,</div><div>Mollie </div><div><br></div><div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Mollie Brooks<br>Postdoctoral Researcher, Ponciano Lab<br>Biology Department, University of Florida<br><a href="http://people.biology.ufl.edu/mbrooks">http://people.biology.ufl.edu/mbrooks</a><br><br></div></div></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">library(<span style="color: #4335c6">R2admb</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">setup_admb()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">library(<span style="color: #4335c6">coda</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">compile_admb(<span style="color: #00a61c">"bcb"</span>, <span style="color: #4335c6">verbose</span>=<span style="color: #ba8914">TRUE</span>, <span style="color: #4335c6">re</span>=<span style="color: #ba8914">TRUE</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); min-height: 25px; ">run_admb(<span style="color: #00a61c">"bcb"</span>, <span style="color: #4335c6">verbose</span>=<span style="color: #ba8914">TRUE</span>, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #4335c6">mcmc</span>=<span style="color: #ba8914">TRUE</span>, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #4335c6">mcmc.opts</span>=mcmc.control(<span style="color: #4335c6">mcmc2</span>=<span style="color: #095307">1000</span>, <span style="color: #4335c6">mcmcpars</span>=c(<span style="color: #00a61c">"Py"</span>)))</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); min-height: 25px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(188, 0, 135); ">#m_admb=read_admb("bcb", mcmc=TRUE, checkterm=FALSE) #this has a bug</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); "><span style="color: #4335c6">m_admb</span>=read_admb(<span style="color: #00a61c">"bcb"</span>, <span style="color: #4335c6">checkterm</span>=<span style="color: #ba8914">FALSE</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); "><span style="color: #4335c6">mcraw</span>=read_psv(<span style="color: #00a61c">"bcb"</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">colnames(<span style="color: #4335c6">mcraw</span>)=names(coef(<span style="color: #4335c6">m_admb</span>))</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); "><span style="color: #4335c6">mmc</span>=as.mcmc(<span style="color: #4335c6">mcraw</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">densityplot(<span style="color: #4335c6">mmc</span>, <span style="color: #4335c6">asp</span>=<span style="color: #00a61c">"fill"</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 18.4px/normal Monaco; color: rgb(48, 16, 155); ">xyplot(<span style="color: #4335c6">mmc</span>)</div></div><div><br></div><div><br></div><div><div>On 30 Oct 2012, at 12:37 PM, Jeff Laake wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I'm a newbie at ADMB but have been using R for over a decade. Coming from R my inclination was to integrate R and ADMB and I found the R2admb package that Ben Bolker wrote. That package makes it quite easy to use R in constructing TPL files and drive model development from R rather than editing TPL in an IDE or text editor. In particular, I'm using model.matrix in R to create design matrices that are input as DATA into ADMB. This means a basic TPL file can be used without modification to run any number of models directly from R. I mentioned this to a colleague who said that his biggest complaint about ADMB was it's lack of tools such as model.matrix. When I showed him my approach he suggested that I post a message to the user list as others may be interested as well. The following link <a href="https://github.com/downloads/jlaake/R2admb/Intro_to_r2admb.pdf">https://github.com/downloads/jlaake/R2admb/Intro_to_r2admb.pdf</a> will take you to a pdf that shows a couple of examples. The first shows how to extend simple.tpl to fit any model and the second more useful example fits detection curves to line transect data. The code for these examples is at <a href="https://github.com/jlaake/R2admb/tree/master/Intro%20to%20R2admb">https://github.com/jlaake/R2admb/tree/master/Intro%20to%20R2admb</a><div>
<br></div><div>I'd appreciate getting any comments about its usefulness (or not) and my admb programming which I'm still learning, I believe that integration of admb into R (as in glmmADMB) will help make ADMB more mainstream in ecology and other fields.</div>
<div><br></div><div>regards --jeff laake</div>
_______________________________________________<br>Users mailing list<br><a href="mailto:Users@admb-project.org">Users@admb-project.org</a><br>http://lists.admb-project.org/mailman/listinfo/users<br></blockquote></div><br></div></body></html>