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…

3 Responses to “pimax(mcsm)”

  1. Thank you for this! I changed iter to iterlimit in the nlm() call in Chapter.5. Another change involves replacing max with maximum in optimize/optimize calls

  2. Martyn Plummer's avatar
    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

Discover more from Xi'an's Og

Subscribe now to keep reading and get access to the full archive.

Continue reading