From antonio.fabio at gmail.com  Mon Mar 24 14:16:00 2008
From: antonio.fabio at gmail.com (Antonio, Fabio Di Narzo)
Date: Mon, 24 Mar 2008 14:16:00 +0100
Subject: [Rd] idea for GSoC: an R package for fitting Bayesian
	Hierarchical Models
In-Reply-To: <f8e6ff050803240545u1413608ek2dbeb5238d6f47bb@mail.gmail.com>
References: <b0808fdc0803210956k5b967d6paa9e572f72482df@mail.gmail.com>
	<b0808fdc0803220410n1b3fbc08k4f837a3355d04096@mail.gmail.com>
	<loom.20080324T013004-719@post.gmane.org>
	<b0808fdc0803240247j767614ebm116100a9e8944f2e@mail.gmail.com>
	<f8e6ff050803240545u1413608ek2dbeb5238d6f47bb@mail.gmail.com>
Message-ID: <b0808fdc0803240616m52ae6cxf609394523d72284@mail.gmail.com>

2008/3/24, hadley wickham <h.wickham at gmail.com>:
> >  Ya. But speeds are rather different.
>  >  I admittely missed a comparison with Umacs in my short demo.
>  >  However, from some early experiments (I'm doing while I'm writing), as
>  >  I suspected, my approach results being many times faster than Umacs,
>  >  even if one doesn't specify samplers as C code. Things goes even
>  >  better for my demo implementation if one tries to plug in samplers
>  >  specified as pure C code, which would further eliminate a lot of
>  >  memory allocations/deallocations behind those "rnorm()".
>  >
>
> There is some interesting work being done on this topic in computer
>  science - e.g.
>
>  @inproceedings{keller:2008,
>         Author = {Keller, Gabriele and Chaffey-Millar, Hugh and Chakravarty,
>  Manuel M. T. and Stewart, Don and Barner-Kowollik, Christopher},
>         Booktitle = {Proceedings of the Tenth International Symposium on
>  Practical Aspects of Declarative Languages},
>         Title = {Specialising Simulator Generators for High-Performance
>  Monte-Carlo Methods},
>         Url = {http://www.cse.unsw.edu.au/~chak/project/polysim/},
>         Year = {2008}
>  }
>
>  which explores a way to define a simulation at a high-level and then
>  compile it down to fast low-level primitives.  This seems like an
>  interesting approach, but I suspect you would struggle to find
>  students with the requisite statistical and computational backgrounds.
>
>  Hadley

Tnx for the reference: that's surely an interesting reading.

Instead of inventing a specialised meta-language for this kind of task
(I don't ever have the knowledge for doing something like that) I've
explored in the recent past the direct use of higher level languages
that can be compiled into native code. I've got most interesting
results in Steel Bank Common Lisp and OCaml. They really seem to do
what they claim :-)

However, writing something like a general purpose Gibbs sampler
framework in these languages seems to be a waste of time, as one
misses a lot of things which are already available in R. Not least:
random number generators from a lot of common distributions! Ok, one
can write wrapper code to the R standalone library, but this all looks
as extra-work.

So, waiting for an R-to-native code compiler, I think a feasible
approach can be to write R functions with pass-by-reference semantics
and a bounch of small C routines. In that respect, I was inspired by
the lush project:
http://lush.sourceforge.net
where mix of high level and C code is encouraged (note that lush at
the end has a native code compiler too).

Antonio.



[Rd] idea for GSoC: an R package for fitting Bayesian Hierarchical Models
Antonio, Fabio Di Narzo