Archive for demo()

local package delays

Posted in Books, R, Statistics with tags , , , , , , , , on January 25, 2013 by xi'an

When Jean-Michel and I left Berlin, a month ago, I really thought we were that close to sending the new edition of Bayesian Core. Alas, we are not done yet for a series of reasons: leaving for India did not give me enough time to complete the help manual, some codes from the original version did not seem to work any longer, apparently jeopardising a whole chapter!, and the package did not seem to compile. Yesterday, we met again and made progress that makes me much more confident. For one thing, the R code that “did not work” was an original spreadsheet of Bayesian Core that we turned into functions towards the completion of the bayess package. However, due to sloppy programming at the time, we had used global variables that were called inside functions without being (explicitly) declared as variables. When those R codes got turned into functions, variables defined inside those functions were no longer global and recognised by the other functions defined within those same functions… Silly me! Once this issue got spotted by Jean-Michel, as well as the use of a few && instead of &’s, the whole problem unravelled rather quickly and we got a compiled package by the end of the day, even though some of the demos (reproducing the outcome found in the text) are still bugged. Stay tuned!

How to use mcsm

Posted in Books, R, Statistics with tags , , , , , on February 28, 2010 by xi'an

Within the past two days, I received this email

Dear Prof.Robert
I have just bought your recent book on Introducing Monte Carlo Methods with R.  Although I have checked your web page for the R programs (bits of the code in the book, codes for generating the figures and tec – not the package available on cran)  used in the book, I have not found them.
I wonder whether you could make them available.
Thank you very much for your time and patience.
Yours Sincerely

and that one

Dear Prof. Robert,
I bought “Introducing Monte Carlo Methods with R” from Amazon booksore. I am a teacher at [...] University, and I choose this book as a textbook in my class.
I can not find the R package “mcsm” according to your book (page 5). Where can I download the R package “mcsm”?
I highly appreciate your help.
Best regards,

so I fear that readers may miss the piece of information provided in the book. As indicated on pages 36-37 of Introducing Monte Carlo Methods with R, mcsm is a registred R package, readers can therefore download it manually from CRAN,  but they should first try using install.packages in R as this is both easier and safer. (They should check on the main R project webpage for more help in installing packages.)

Another useful information for readers is that the code used on the examples of Introducing Monte Carlo Methods with R is available from mcsm through the demo command/code. Typing demo(Chapter.3) starts the production of the examples of Chapter 3:

> demo(Chapter.3)

demo(Chapter.3)
————————
Type  <Return>   to start :
> # Section 3.1, Introduction
>
> ch=function(la){ integrate(function(x){x^(la-1)*exp(-x)},0,Inf)$val}
> plot(lgamma(seq(.01,10,le=100)),log(apply(as.matrix(
+  seq(.01,10,le=100)),1,ch)),xlab=”log(integrate(f))”,
+  ylab=expression(log(Gamma(lambda))),pch=19,cex=.6)
> S=readline(prompt=”Type  <Return>   to continue : “)
Type  <Return>   to continue :

and obviously the same for all other chapters. This also means the code is available in the corresponding file, something like

/usr/lib/R/site-library/mcsm/demo/Chapter.3.R

depending on your system.

Follow

Get every new post delivered to your Inbox.

Join 551 other followers