Information
on bayesm
Two ways to obtain bayesm
- Go to the CRAN network, www.r-project.org
- If you are running v2.0.0 (or
higher) of Windows version of R, use the “Packages” menu on
the button bar of the console window. Select a CRAN mirror near you, and
click on “install packages.” Choose bayesm
from the pop-up window list. The rest is automatic!
Tips on running bayesm
- 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.
- If you don't know much about
R, read Some
Useful R pointers.
- 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 help.search(“mcmc”)
to produce a list of these functions.
- 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.
- 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
- 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.
- 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!
- 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).
- 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
- 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 bayesm. R source for all
functions (zipfile). View C/C++ source for bayesm.dll.
- 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.
- If you would like to make
your own package, take a look at the guide, Making R Packages under
Windows and a simple test example.
Return to Bayesian Statistics and Marketing