Wednesday, September 28, 2011

For Linux / MacOS users: Easy fix for windows() command

For users of Linux / MacOS, the windows() command in R is not recognized. The analogous command is X11(). Therefore, you could go through the programs and replace every occurrence of windows(...) with X11(...). Or, you could just tell R to do it for you, by putting this line at the top of the file (but after any remove all objects command):


if ( .Platform$OS.type != "windows" ) { 
   windows <- function( ... ) X11( ... ) 
}


This tip was suggested by George Kachergis. Thanks George!

See additional graphics info at this more recent blog entry.

Sunday, September 11, 2011

Workshop, Saturday Oct. 22, Purdue University


I'll be doing at workshop at Purdue University, on the morning of Saturday October 22, 2011. 
Click here for full details.

Saturday, September 10, 2011

Review in the British Journal of Mathematical and Statistical Psychology

In a recent review of the book in the British Journal of Mathematical and Statistical Psychology*, Mark Andrews says
Though risking hyperbole, I would describe this book as revolutionary, at least in the context of psychology. It is, to my knowledge, the first book of its kind in this field to provide a general introduction to exclusively Bayesian statistical methods. In addition, it does so almost entirely by way of Monte Carlo simulation methods. While reasonable minds may disagree, it is arguable that both the general Bayesian framework advocated here, and the heavy use of Monte Carlo simulations, are destined to be the future of all data analysis, whether in psychology or elsewhere. If this is so, then Doing Bayesian Data Analysis might be something of a harbinger, rousing psychology to the new realitites of data-analysis in the 21st century. ...
Doing Bayesian Data Analysis introduces psychology to new ways of thinking and new ways of talking about and presenting data-analysis. Anyone serious about data analysis in psychology ought to read this book. At the very least, it will serve as a welcome new perspective on the field. More probably, or so it seems to me, the ideas and methods presented here will eventually be seen as the foundations for new approaches to statistics that will becomes commonplace in the near future.
I think the reviewer has a remarkably clear view of the intellectual landscape, of where psychology (and science generally) is going, and of where the book attempts to situate itself. Thank you, Mark, for such a perceptive review. Now may everyone else see as clearly as you!

* Andrews, M. (2011). Book Review. British Journal of Mathematical and Statistical Psychology. Article first published online: 5 Sep 2011. DOI: 10.1111/j.2044-8317.2011.02027.x

plotPost.R now has curve option (instead of histogram)

When plotting the distribution formed by an MCMC chain, the book uses a histogram. I've added a new option to the plotPost.R function so that it can make a curve instead. Get the new plotPost.R program from the book's web site.

An example. Suppose x is the vector of values in an MCMC chain:

x = rnorm( 10000 , 2.15 , 1 ) 
 
The usual plotPost would produce a histogram, like this:
 
histinfo = plotPost( x , breaks=30 , col="skyblue" , compVal= 0 , ROPE=c(-0.1,0.1) )
 
But the new plotPost has a showCurve option: 
 
histinfo = plotPost( x , showCurve=T , col="skyblue" , compVal= 0 , ROPE=c(-0.1,0.1) )

Notice that the "breaks" argument was removed from the command when using showCurve=T, because "breaks" only applies to histograms.
 
Why use one form or the other? A histogram reminds the viewer that the plot represents a sample of points, not a known mathematical function (even though there is a mathematical function underlying the sample). This was the motivation for using histograms in the book. Also, the curve uses a kernel density estimation technique that blurs the distribution, so the curve will tend to be not quite peaked enough and a little too wide in its tails. On the other hand, the curve might be easier to view and more aesthetically pleasing. Ultimately the choice is yours.  Now you have the choice!

Monday, August 29, 2011

Another review from a reader

Here's another review, with an extensive summary, apparently from a reader in India:
http://rkbookreviews.wordpress.com/2011/08/27/doing-bayesian-data-analysis-summary/
The reviewer's nom-de-blog is "safeisrisky". So, whoever you are, thank you for the nice review!

Sunday, August 28, 2011

Review from Dr. Joseph Hilbe

Posted on Amazon.com, May 12, 2011, by Dr. Joseph Hilbe:
I have reviewed a number of statistics texts for academic journals over the years, and have authored published reviews of some six books specifically devoted to Bayesian analysis. I consider John Kruschke's "Doing Bayesian Data Analysis" to be the best text available for learning this branch of statistics.

Learning how to craft meaningful statistical tests and models based on Bayesian methods is not an easy task. Nor is it an easy task to write a comprehensive basic text on the subject -- one that actually guides the reader through the various Bayesian concepts and mathematical operations so that they have a solid working ability to develop their own Bayesian-based analyses.

There are now quite a few texts to choose from in this area, and some are quite good. But Kruschke's text, in my opinion, is the most useful one available. It is very well written, the concepts unique to the Bayesian approach are clearly presented, and there is an excellent instructors manual for professors who have adopted the book for their classes. Kruschke uses R and WinBUGS for showing examples of the methods he describes, and provides all of the code so that the reader can adapt the methods for their own projects.

"Doing Bayesian Data Analysis" is not just an excellent text for the classroom, but also -- and I think foremost -- it is just the text one would want to work through in order to learn how to employ Bayesian methods for oneself.
Thank you, Joe!

Click here to see Joe's books on Amazon.com.

Saturday, August 27, 2011

Review in Journal of Mathematical Psychology

After a few hundred words of criticism in his recent review in the Journal of Mathematical Psychology*, Michael Smithson concludes:
"All said and done, the criticisms I have raised here are relatively minor. This is the best introductory textbook on Bayesian MCMC techniques I have read, and the most suitable for psychology students. It fills a gap I described in my recent review of six other introductory Bayesian method texts (Smithson, 2010). I look forward to using it in my own teaching, and I recommend it to anyone wishing to introduce graduate or advanced undergraduate students to the emerging Bayesian revolution."

Thank you, Michael!

* Smithson, M. (in press). Book Review. Journal of Mathematical Psychology. doi:10.1016/j.jmp.2011.05.002

Smithson, M. (2010). A review of six introductory texts on Bayesian methods.
Journal of Educational and Behavioral Statistics, 35, 371–374.

P.S. Michael comments about teaching non-Bayesian data analysis on his blog.