Introducing Monte Carlo methods with R.

From MaRDI portal





The programming language R is a modern tool for consideration and practical solving of problems in statistics. In Chapter 1 -- Basic R programming -- the elements of the programming language R are introduced. Here, input and output data structures and basic programming commands for this language are discussed and illustrated. In Section 1.1 an introduction to the structure, the work and the objects of the language R is given. The problem for the interface that can integrate programs in other languages is developed. In Section 1.2, it is shown how to install the language R. In Section 1.3, the main mathematical objects -- scalars, vectors, matrices, arrays, time series, a list and data frame classes, functions and graphics are considered, and it is shown how to realize those in the language R. In Sections 1.4 and 1.5 all standard statistical distributions are considered with several programming shortcuts. Basic and not-so-basic distributions are described with graphics and histograms. It is shown how Monte Carlo approximations can be used. In Section 1.6, some graphical possibilities of the language R are shown. With an example, the use of the command ``cunsum is illustrated which is particularly handy when checking Monte Carlo convergence. In Section 1.7, it is shown how new functions and libraries can be created by everyone and can be added to web depositories. In Sections 1.8 and 1.9, the problems of input and output of data objects and how they can be administrated by the language R are considered. In Section 1.10, the package called ``Mcsm for Monte Carlo statistical methods is described. In Section 1.11 there are many exercises related with the theory and practice of the language R. In Chapter 2 -- Random variable generation -- practical techniques that can produce random variables from both standard and non-standard distributions by using computer programs are presented. In Section 2.1, methods based on Monte Carlo simulations are considered. These methods produce pseudo-random numbers based on an initial value \(u_{0}\) of a uniform \({\mathcal U}(0,1)\) sequence and a transformation \(D,\) and, then, the uniform generator produces a sequence \((u_{i}) = (D^{i}(u_{0}))\) of values in \((0,1).\) In Section 2.1.1, the basic uniform generator in R is used to realize the above purpose. In Section 2.1.2, the probability integral transform is used to transform any random variable into a uniform random variable and vice versa. In Section 2.2, the general transformation methods are considered. In section 2.2.1, the Box-Muller algorithm is used to obtain a normal random variable. In Section 2.2.2, the so-called ``all-purpose algorithm is used to generate discrete random variables. Two examples are considered. In Section 2.2.3, the probability distribution is represented as a mixture distribution. In Section 2.3, the algorithm of the so-called accept-reject methods is developed. How this algorithm works is illustrated with examples. A criticism of the accept-reject algorithm is given. In Section 2.4, many additional exercises are presented, some with a few remarks. In section 3, the major concepts of Monte Carlo methods are introduced. The advantages of the availability of computer-generated random variables to approximate univariate and multidimensional integrals are discussed. In Section 3.1, two major classes of numerical problems -- optimization problems and integration problems -- are discussed and illustrated with examples. In Section 3.2, the basic notions of Monte Carlo approximations as a by-product of the law of large numbers are introduced. In Section 3.3, the importance sampling method is studied. In Section 3.3.1, examples related to an arbitrary change of reference measure are solved. In Section 3.3.2, sampling importance resampling is considered and illustrated by examples. In Section 3.3.3, it is shown how the selection of the importance function can be realized. In Section 3.4, many additional exercises are given. In Chapter 4, the specifics of variance estimation and control for Monte Carlo methods are presented. In Section 4.2, confidence bands of the variation are constructed. In Section 4.3, the basic difficulty when assessing convergence for importance sampling is illustrated with two examples. In Section 4.4, the notions of effective sample size and the so-called perplexity are defined and some of their properties are proved. In Section 4.5, for an iid sequence \(X_{1}, X_{2}, \dots , X_{n}\), an error bound on the sequence \((\overline{X}_{m} = {1 \over m} \sum_{i=1}^{m} X_{i})_{1 \leq m \leq n}\) is obtained. An algorithm that simulates Brownian motions is constructed and verified by a Monte Carlo experiment. The confidence bands produced by two importance sampling approximations based on normal and Cauchy samples are compared. In Section 4.6, a technique, called Rao-Blackwellization, is used to calculate the conditional expectation in Monte Carlo expressions. The results are given by one example and are illustrated by graphics. Also, an accept-reject method for the target density based on the instrumental distribution is considered. In Section 4.7, global acceleration strategies are considered. In Sections 4.7.2 and 4.7.3, respectively, antithetic variables and control variates are used to estimate integrals and to reduce the variance of the Monte Carlo estimator. These techniques are developed by examples and are illustrated by graphics. In Section 4.5, several exercises are proposed. In Chapter 5, stochastic search techniques to reach a maximum or a minimum of a function are developed and also simulations are used with the purpose to optimize the approximation of functions. In Section 5.1, the optimization problems are divided into two kinds to find the extrema of a function over a domain and to find the solutions of an implicit equation over a domain. In Section 5.2, two examples are considered. In the first one, the problem of maximizing the likelihood of a Cauchy sample is solved and its programming is realized using R. In the second one, the problem of the likelihood associated with the mixture model is considered and realized in R. Section 5.3 is dedicated to produce stochastic search technique to determine the maximum or minimum of a function. In Section 5.3.1, the notion of a basic solution is presented with examples and graphics. In Section 5.3.2, the stochastic gradient methods are developed and used for numerical optimization. In Section 5.3.3, an alternative method of simulation, the so called simulated annealing, is used to solve problems in the discrete case and in the continuous one. This method is applied to Cauchy likelihood and is realized in R. In Section 5.4, the concept of stochastic approximations is developed. In Section 5.4.1, the optimizing Monte Carlo approximation is applied and realized in R to solve the problem of a simple probit model in Bayesian analysis. In Section 5.4.2, the mixture model is expressed as a missing-data model such that the observed likelihood can be computed in manageable time. In Section 5.4.3, the concept of the expectation-maximization algorithm (EM algorithm) is developed and it is applied to solve two examples. Also, in Section 5.4.4, a Monte Carlo representation of the EM algorithm is realized. In Section 5.5, many additional exercises are given. In Chapter 6, simulation methods based on Markov chains are developed. The Metropolis-Hastings algorithm is considered as one of the most general Markov chain Monte Carlo (MCMC) algorithms. In Section 6.2, a quick refresher on Markov chains, just the basics needed to understand the algorithms, is given. The main notions, such as Markov chains, probability distributions, transition kernels, random walks, stationary probability distributions, are recalled. In Section 6.3, the basic Metropolis-Hastings algorithms are developed. In Section 6.3.1, it is shown how the Metropolis-Hastings algorithm associated with an objective target function and the conditional density produces a Markov chain. In Section 6.3.2, as a special case of the original Metropolis-Hastings algorithm, the so-called independent Metropolis-Hastings algorithm is developed and realized in R. The operation of this algorithm is illustrated by several examples and exercises. In Section 6.4, the problem of a selection of candidates is considered. In Section 6.4.1, the concept of the random walk Metropolis-Hastings algorithm is given. As an application of this method, the formal problem of generating a normal distribution based on a random walk is solved. In section 6.4.2, the concept of the Langevin algorithm of Roberts and Rosental is developed and realized in R. The random walk Metropolis-Hastings algorithm is also applied to discrete support targets. In Section 6.5, the problem of the possibility of achieving an ``optimal choice for the candidate distribution in the Metropolis-Hastings algorithm is discussed. In Section 6.6, many additional exercises are given. Chapter 7 extends the scope of MCMC algorithms by studying another class of now common MCMC methods, called Gibbs sampling. In Section 7.2, the concept of the two-stage Gibbs sampler algorithm is developed and applied to solve problems related with the bivariate normal model and the beta-binomial distribution. In Section 7.3, the multistage Gibbs sampler algorithm is given and applied to problems of the multivariate normal density and the one-way random effects model. In Section 7.4, the concepts of missing data and latent variable models are presented and illustrated by examples. The slice sampler algorithm is given and illustrated. In Section 7.5, the hierarchical model is defined by a sequence of conditional distributions. In Section 7.6, a few issues that may arise in the implementation of the Gibbs sampler are proposed. Practical implementations as a reparametrization, a Rao-Blackwellization, a Metropolis within Gibbs and hybrid strategies, improper prior are realized. Section 7.7 contains many additional exercises. In Chapter 8, different monitoring methods are presented to check for the convergence of an MCMC algorithm and to answer the most commonly asked question about MCMC, namely ``When do we stop our MCMC algorithm?. Two notions of convergence for MCMC algorithms, namely convergence to the stationarity distribution and convergence of the ergodic average, are presented. In Section 8.2.4, the generic functions of the coda package are given. In Sections 8.3 and 8.4, the processes of monitoring the convergence to stationarity and monitoring the convergence of averages, respectively, are considered. In Section 8.5, adaptive MCMC algorithms are used to calibrate the convergence diagnoses. The existing amcmc package introduced by Rosental is discussed. There are examples for illustration. In Section 8.6, many additional exercises are presented. The book contains also references, an index of R terms and a subject index.




Cited in
(only showing first 100 items - show all)


Describes a project that uses

Uses Software






This page was built for publication: Introducing Monte Carlo methods with R.

Report a bug (only for logged in users!)Click here to report a bug for this page (MaRDI item Q5850829)