pimax(mcsm)

The function pimax from our package mcsm is used in to reproduce Figure 5.11 of our book Introducing Monte Carlo Methods with R. (The name comes from using the Pima Indian R benchmark as the reference dataset.) I got this email from Josué

I ran the ‘pimax’ example from the mcsm manual, and it gave me the following message:

> pimax(Nsim = 10^3)
Error in raaj[t, ] = apply(as.matrix(aas), 1, margap) :
number of items to replace is not a multiple of replacement length
> pimax()
Error in raaj[t, ] = apply(as.matrix(aas), 1, margap) :
number of items to replace is not a multiple of replacement length

but when running pimax(10^2) on my machine I did get the following picture and no error message. So I wonder if this is a matter of version of R or something else…

2 Responses to “pimax(mcsm)”

  1. Martyn Plummer Says:

    The function margap() embedded in the pimax function ends with a for loop. But since R 2.10.0 for loops always return NULL, so you need to put an explicit call to return() at the end of this function.

    See the NEWS file:

    o for(), while(), and repeat() loops now always return NULL as
    their (invisible) value. This change was needed to address a
    reference counting bug without creating performance penalties
    for some common use cases.

    • Thank you, Martyn! This is the drawback of having built that package with an older version of R (2.6.2!)… I will then try to correct this obsolescence asap!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 701 other followers