Speed

206 views
Skip to first unread message

burakb

unread,
Oct 19, 2010, 7:50:45 AM10/19/10
to PyMC
Hi everyone,

I am comparing Gelman's radon examples written in R, to PyMC
equivalents found from these links:

http://github.com/armstrtw/pymc_radon

http://healthyalgorithms.wordpress.com/2009/12/02/multilevel-hierarchical-modeling-what-it-can-and-cannot-do-in-python/

Both of these run *much* slower than the R code. Am I doing something
wrong? Do I have to install something else, a native library perhaps
to speed things up? The code from second example is so slow that it's
not worth waiting for the result. I have pymc-2.1 alpha.

Thanks,

Whit Armstrong

unread,
Oct 19, 2010, 8:06:04 AM10/19/10
to py...@googlegroups.com
which particular example are you running?

My version of the scaled wishart was slower, but Abe had a few
suggestions to speed it up.

For the simple varying intercepts/slopes, the pymc examples should be
faster than R/Jags. I don't recall exactly from memory, but I think I
got about a 4x speedup.

-Whit

> --
> You received this message because you are subscribed to the Google Groups "PyMC" group.
> To post to this group, send email to py...@googlegroups.com.
> To unsubscribe from this group, send email to pymc+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pymc?hl=en.
>
>

Aaron MacNeil

unread,
Oct 19, 2010, 8:12:32 AM10/19/10
to py...@googlegroups.com, PyMC
> --

Yup - the second example is slow because it is looped, which is the pymc
downside. On the upside, Python likes arrays, and this creates the
speedier solution in the first example.

As for why it doesn't run as fast as R - and forgive this question - but
are you comparing pymc to an R-coded mcmc scheme?

Aaron

burakb

unread,
Oct 19, 2010, 8:17:32 AM10/19/10
to PyMC
I am running run_radon_varying_intercept.py, and the R code from ARM
16.3. All code is here:

http://dl.dropbox.com/u/1570604/aspfiles/arm/16.3.zip

There is negligible difference between the two, in this case R being >
5 faster. Unless I did something wrong.

On Oct 19, 3:06 pm, Whit Armstrong <armstrong.w...@gmail.com> wrote:
> which particular example are you running?
>
> My version of the scaled wishart was slower, but Abe had a few
> suggestions to speed it up.
>
> For the simple varying intercepts/slopes, the pymc examples should be
> faster than R/Jags.  I don't recall exactly from memory, but I think I
> got about a 4x speedup.
>
> -Whit
>
> On Tue, Oct 19, 2010 at 7:50 AM, burakb <burakbayra...@gmail.com> wrote:
> > Hi everyone,
>
> > I am comparing Gelman's radon examples written in R, to PyMC
> > equivalents found from these links:
>
> >http://github.com/armstrtw/pymc_radon
>
> >http://healthyalgorithms.wordpress.com/2009/12/02/multilevel-hierarch...

burakb

unread,
Oct 19, 2010, 8:19:31 AM10/19/10
to PyMC
By R I mean "R using JAGS or WinBUGS". R for short. :)

Whit Armstrong

unread,
Oct 19, 2010, 8:25:31 AM10/19/10
to py...@googlegroups.com
Did you run the R examples with the same number of chains/interations?

I see:

warmstrong@krypton:/tmp/stats.tmp$ grep 'n.iter' *.R
16.3-BUGS.R: "radon.1.bug", n.chains=3, n.iter=10, debug=TRUE)
16.3-JAGS.R: "radon.1.bug", n.chains=3, n.iter=10)
warmstrong@krypton:/tmp/stats.tmp$


vs the pymc example 10k iterations, 1 chain:

warmstrong@krypton:/tmp/stats.tmp$ grep 'iter' *.py
16.3.py:M.sample(iter=50e3, burn=10e3, thin=5)
warmstrong@krypton:/tmp/stats.tmp$

-Whit

Reply all
Reply to author
Forward
0 new messages