[Rcpp-devel] Help with an Rcpp and CppBugs example

Dirk Eddelbuettel edd at debian.org
Sat Oct 1 21:29:43 CEST 2011


On 1 October 2011 at 15:03, Shige Song wrote:
| Any examples showing how CppBugs and Rcpp work together will be good.
| I am particularly interested in knowing how GLM models and GLMM models
| can be estimated that way.
| 
| Thanks in advance.

Well, maybe you should really try these two things:

  i)  take the five or six small examples in Whit's git repo, and read up on
      the inline package and its cxxfunction() to wrap them -- given the
      /working example/ I just provided you yesterday, this is not all that hard.

  ii) take glm / glmm code you and try to make it work with CppBugs in
      standalone mode as per Whit's examples in hit repo.  Then revisit i)
      and wrap it too.

Dirk
 
| Best,
| Shige
| 
| On Sat, Oct 1, 2011 at 1:52 PM, Whit Armstrong <armstrong.whit at gmail.com> wrote:
| > I'm happy to provide more examples of cppbugs with inline and Rcpp.
| >
| > Is there something in particular you had in mind?
| >
| > -Whit
| >
| >
| > On Sat, Oct 1, 2011 at 7:05 AM, Shige Song <shigesong at gmail.com> wrote:
| >> Dear Whit,
| >>
| >> I have been playing with other examples you provided in the github
| >> repository. The one Dirt sent, however, is the only example that I can
| >> find from the internet showing how CppBugs works with Rcpp (and R). As
| >> I see it, such a combination has great potential providing a flexible
| >> yet powerful Bayesian computational tool.
| >>
| >> Very nice work, and thanks for the suggestion.
| >>
| >> Best,
| >> Shige
| >>
| >> On Fri, Sep 30, 2011 at 10:06 PM, Whit Armstrong
| >> <armstrong.whit at gmail.com> wrote:
| >>> Shige,
| >>>
| >>> That example is quite dated at this point.  The CppBugs api has
| >>> changed a lot since then and is likely to change more in the near
| >>> future.
| >>>
| >>> Please git pull the latest from github, and ping me if you have any issues.
| >>>
| >>> There are also quite a few pure c++ examples the the 'test' dir to get
| >>> you started.
| >>>
| >>> In the next major release of CppBugs you will be able to declare the
| >>> objects directly in R, but give me a few months to get that working.
| >>>
| >>> -Whit
| >>>
| >>>
| >>> On Fri, Sep 30, 2011 at 9:40 PM, Shige Song <shigesong at gmail.com> wrote:
| >>>> Dear Dirk,
| >>>>
| >>>> Thank you very much for the suggestions and the upated file. Your file
| >>>> actually works flawlessly on my system. It looks really interesting
| >>>> and educational.
| >>>>
| >>>> Thanks also for the great work on Rcpp, really amazing piece of
| >>>> software you got there.
| >>>>
| >>>> Best,
| >>>> Shige
| >>>>
| >>>> On Fri, Sep 30, 2011 at 9:11 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
| >>>>>
| >>>>> Shige,
| >>>>>
| >>>>> There is no way to sugarcoat this: you have to learn to live with, and learn
| >>>>> from, the compiler errors and relate them to the actual code. Using Rcpp
| >>>>> still means programming in the context of a C++ compiler.
| >>>>>
| >>>>>
| >>>>> You also need Whit's CppBugs repo from github _installed somewhere_ so that
| >>>>>
| >>>>>  #include <cppbugs/cppbugs.hpp>
| >>>>>
| >>>>> works. Plus the same for Conrad's Armadillo as we have
| >>>>>
| >>>>>  #include <armadillo>
| >>>>>
| >>>>> And to top it all off, you probably need a bunch of Boost installed as
| >>>>> CppBugs uses it.  If all that is a given, then you can run the attached file
| >>>>> 'whit.r' as I do below. This file served as in example in the Rcpp workshop
| >>>>> in April and I just fetched it from my sources. The version posted then is
| >>>>> likely a little outdated.  But this one works:
| >>>>>
| >>>>> $ r whit.R
| >>>>> Loading required package: methods
| >>>>>   user  system elapsed
| >>>>>  0.220   0.020   0.236
| >>>>> $b
| >>>>> [1] -0.3303790  0.5276294
| >>>>>
| >>>>> $ar
| >>>>> [1] 0
| >>>>>
| >>>>> $
| >>>>>
| >>>>> Whether you use Rscript or r (from littler) does not matter.  The updated
| >>>>> whit.r is attached.  It builds and runs, I have no idea if it makes any
| >>>>> sense... I think it regresses y ~ X with both being noise so there.
| >>>>>
| >>>>> Hope this helps,  Dirk
| >>>>>
| >>>>>
| >>>>>
| >>>>>
| >>>>> --
| >>>>> New Rcpp master class for R and C++ integration is scheduled for
| >>>>> San Francisco (Oct 8), more details / reg.info available at
| >>>>> http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
| >>>>>
| >>>>>
| >>>> _______________________________________________
| >>>> Rcpp-devel mailing list
| >>>> Rcpp-devel at lists.r-forge.r-project.org
| >>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
| >>>
| >>
| >
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
New Rcpp master class for R and C++ integration is scheduled for 
San Francisco (Oct 8), more details / reg.info available at
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php


More information about the Rcpp-devel mailing list