<div dir="ltr"><div class="gmail_default">I think I've seen this somewhere out there on the webs... <br><br><a href="http://dirk.eddelbuettel.com/blog/2011/07/14/">http://dirk.eddelbuettel.com/blog/2011/07/14/</a><br></div>

</div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br><div><br></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>-------------------------------------------------------------------------<br>

J.P. Olmsted</font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font><br></font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>029 Corwin (Office)</font></font></font></div>

<div><span style="font-size:small;font-family:arial,helvetica,sans-serif;color:rgb(102,102,102)">130 Corwin Hall (Mail)</span><br></div><div><span style="font-size:small;font-family:arial,helvetica,sans-serif;color:rgb(102,102,102)"><br>

</span></div><div><span style="font-size:small;font-family:arial,helvetica,sans-serif;color:rgb(102,102,102)">Politics Department</span><br></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>Princeton University</font></font></font></div>

<div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>Princeton, NJ 08544</font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font><br></font></font></font></div>

<div><font color="#666666"><font face="arial, helvetica, sans-serif"><font><br></font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>t: 609.258.6202</font></font></font></div>

<div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>f: 609.258.1110<br></font></font><font face="arial, helvetica, sans-serif"><a href="mailto:jolmsted@princeton.edu" target="_blank">jolmsted@princeton.edu</a></font><br>

</font><div><font face="arial, helvetica, sans-serif"><font color="#666666"><a href="http://about.me/olmjo" target="_blank">http://about.me/olmjo</a><font><br></font><font></font><font>-------------------------------------------------------------------------</font></font><br>

</font></div></div></div></div>
<br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 11:31 AM, Jonathan Olmsted <span dir="ltr"><<a href="mailto:jolmsted@princeton.edu" target="_blank">jolmsted@princeton.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div class="gmail_default" style="font-size:small">Just my quick thoughts:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Bayesian MCMC is what brought me to Rcpp. So, I have always found those examples the most compelling. This is precisely because good R coding can't improve performance on these problems and the gain in computational performance really justified the development cost as opposed to cases where you come out with a time profit only in the *very* long-run.</div>


<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">In particular, I usually work with models that are conceptually similar to factor analysis (i.e., nothing on the "right-hand side is observed"). This is relevant because the next place one might go if R is slow for these problems is JAGS. Or maybe it's the first place you go. I'm not sure. Anyway, JAGS (as of when I last looked into it) doesn't handle the things I was doing efficiently. It used a less efficient sampler because it didn't detect that conditional on every other parameter, I was updating something that came from a Normal dist. So, with just a vanilla Gibbs step, I could out perform JAGS' slice sampler (where efficiency = increase in Effective Sample Size / time).</div>


<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I settled on Rcpp for these problems before Stan was really out there, so I haven't doubled-back to see how Stan would factor in to someone's decision-making process. Taken together:</div>


<div class="gmail_default" style="font-size:small"><div><ol><li>If you are doing MCMC in R for a model that isn't packaged, you have to code it by hand<br></li><li>Even if your R code is efficient, your runtime will be slow</li>


<li>Outside options don't get you too much improvement (e.g. JAGS), but they get you some</li><li>For some problems, that just isn't fast enough and Rcpp-based C++ code can help you get you a lot more speedup with a reduced learning curve</li>


</ol><div>Particularly nice about this class of problems is that it "straightforward" on the implementation side. It focuses on computation (not advanced features of C++ or the nuances of R objects), the algorithm is conceptually simple, and you don't have to rely on boost or armadillo or anything beyond basic C++. Lastly, with all the recent sugar, MCMC Rcpp code is veryR-like.</div>


</div><div><br></div><div>Also, while it's never a complaint of mine, there is often some conceptual hurdle for folks looking at an example like simulating pi and seeing how it applies to their work. At least with MCMC, it is a bit closer to a real application. I'm not saying it's anyone else's job to jump that hurdle for them, but if it can be removed for free, why not?</div>


<div><br></div></div><div class="gmail_default" style="font-size:small">Apologies for long-windedness.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">


-Jonathan</div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br><div><br></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>-------------------------------------------------------------------------<br>


J.P. Olmsted</font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font><br></font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>029 Corwin (Office)</font></font></font></div>


<div><span style="font-size:small;font-family:arial,helvetica,sans-serif;color:rgb(102,102,102)">130 Corwin Hall (Mail)</span><br></div><div><span style="font-size:small;font-family:arial,helvetica,sans-serif;color:rgb(102,102,102)"><br>


</span></div><div><span style="font-size:small;font-family:arial,helvetica,sans-serif;color:rgb(102,102,102)">Politics Department</span><br></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>Princeton University</font></font></font></div>


<div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>Princeton, NJ 08544</font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font><br></font></font></font></div>


<div><font color="#666666"><font face="arial, helvetica, sans-serif"><font><br></font></font></font></div><div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>t: 609.258.6202</font></font></font></div>


<div><font color="#666666"><font face="arial, helvetica, sans-serif"><font>f: 609.258.1110<br></font></font><font face="arial, helvetica, sans-serif"><a href="mailto:jolmsted@princeton.edu" target="_blank">jolmsted@princeton.edu</a></font><br>


</font><div><font face="arial, helvetica, sans-serif"><font color="#666666"><a href="http://about.me/olmjo" target="_blank">http://about.me/olmjo</a><font><br></font><font></font><font>-------------------------------------------------------------------------</font></font><br>


</font></div></div></div></div><div><div class="h5">
<br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 10:19 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
I'm giving a talk to the Chicago RUG that is limited to 30 mins, and I would<br>
like to include some nice examples (besides standards like Fibonacci and<br>
SimulatingPi).  The other talk is on ggplot(2), so the house may be full with<br>
new users / non-C++ hackers.<br>
<br>
What examples should I talk about?  Bonus points for links for list<br>
questions, StackOverflow questions, or Rcpp Gallery posts.<br>
<span><font color="#888888"><br>
Dirk<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</font></span></blockquote></div><br></div></div></div>
</blockquote></div><br></div>