Information on bayesm

Tips on running bayesm  

  1. You need to “load” the package by using the library command, library(bayesm). If you want to avoid loading the package every time you invoke R, put library(bayesm) in your .Rprofile file.
  2. bayesm has many functions defined in it. The “turn-key” or “end-user” functions start with the letter r, e.g. rmnpGibbs is the Gibbs sampler for the multinomial probit model. Use“mcmc”) to produce a list of these functions.
  3. Check the examples. Each function has an example file. To view the example for a function, use the R command ?function, e.g. ?rmnpGibbs. The example will be listed at the bottom of the displayed help text. You can also find the examples in the R program directory tree, e.g. 
    C:\Program Files\R\rw2001\library\bayesm\R-ex. You may have to unzip these files.
  4. The best way is work with bayesm functions is to copy the examples into a .R file and then edit the file to read in your own data and run the function. At first, use as many defaults as possible (esp. in the Prior list) to make sure that the function is working properly on your example.

  Tips on using MCMC methods  

  1. If you are unfamiliar with MCMC methods, read chapter 3 of Bayesian Statistics and Marketing. Try some of our test examples first, before trying your own data.
  2. The “output” of an MCMC method is a set of draws of the parameters. You must decide how many draws to make and how to analyze the draws produced. MCMC methods provide an estimate of the entire posterior distribution, not just a few moments. Summarize the distribution by using histograms or quantiles. Resist the temptation to simply report the posterior mean and posterior standard deviation. For non-normal distributions, these moments have little meaning!
  3. Most of the MCMC methods implemented in bayesm run very fast so it is possible to make 10,000s of draws even for relatively large datasets in less than ½ hour – in most cases less than 5 minutes. Use this power where possible. Only the hierarchical models, rhierLinearModel, rmnlRwMixture, and rscaleUsage will take appreciably longer (> one half hour, in some cases several hours will be required).
  4. If you are having problems with using too much memory, set keep in the Mcmc parameter list to more than 1.  You will need a minimum of 500 MB of memory to run serious problems in bayesm.

  Extending and Adapting Our Code

  1. We hope that our code will be improved and extended by our users. Before modifying code, please examine the fully commented versions of the functions in bayesmR source for all functions (zipfile).  View C source code. View C++ source code.  Download bayesm.dll.
  2. Many of our functions start with checks on the arguments; these checks take up much of the code. Strip these out to get to the essence of the code.