
Participate in weekly, hands-on workshops for bayesian computational analyses with R, walking through scripts and exercises with concise operational manuals and posted materials.
R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS.
Explore how open-source R enables scientific analysis through community packages, CRAN submissions, and clear documentation, and learn about vectors and environments.
An R script is simply a text file containing the same commands that you would enter on the command line of R.
Learn how the R environment uses graphical front ends to translate actions into console commands, access two-dimensional data frames with indexing and dollar notation, and handle missing values.
Use box plots to compare univariate distributions by gender and hours of sleep. Examine haircut prices by gender with boolean indexing in R and perform a regression.
Monte Carlo simulation performs risk analysis by building models of possible results by substituting a range of values—a probability distribution—for any factor that has inherent uncertainty. It then calculates results over and over, each time using a different set of random values from the probability functions. Depending upon the number of uncertainties and the ranges specified for them, a Monte Carlo simulation could involve thousands or tens of thousands of recalculations before it is complete. Monte Carlo simulation produces distributions of possible outcome values.
Explore the second session on Bayesian computation, contrasting frequentist and Bayesian approaches, and explaining prior-to-posterior updates with recommendations from Jim Albert and Andrew Gelman for applied and conceptual study.
Explore how dnorm() computes the height of the normal distribution’s probability density function, defaulting to mean 0 and sd 1, with optional mean, sd, and vector inputs.
The pnorm( ) function is the cumulative density function or CDF. It returns the area below the CDF and to the left up to some point "x" along the horizontal axis, for example, "x = 1."
In probability theory and applications, Bayes's rule relates the odds of event to the odds of event , before (prior to) and after (posterior to) conditioning on another event . The odds on to event is simply the ratio of the probabilities of the two events. The prior odds is the ratio of the unconditional or prior probabilities, the posterior odds is the ratio of conditional or posterior probabilities given the event . The relationship is expressed in terms of the likelihood ratio or Bayes factor, . By definition, this is the ratio of the conditional probabilities of the event given that is the case or that is the case, respectively. The rule simply states: posterior odds equals prior odds times Bayes factor.
In statistics, a likelihood function (often simply the likelihood) is a function of the parameters of a statistical model. Likelihood functions play a key role in statistical inference, especially methods of estimating a parameter from a set of statistics. In informal contexts, "likelihood" is often used as a synonym for "probability." But in statistical usage, a distinction is made depending on the roles of the outcome or parameter. Probability is used when describing a function of the outcome given a fixed parameter value. For example, if a coin is flipped 10 times and it is a fair coin, what is the probability of it landing heads-up every time? Likelihood is used when describing a function of a parameter given an outcome. For example, if a coin is flipped 10 times and it has landed heads-up 10 times, what is the likelihood that the coin is fair?
Discrete priors are in contrast to continuous priors. Discrete priors refers to a set of whole numbers describing the frequency of outcomes of some event, for example, the number of consecutive tosses of "heads" in a series of tests, or samples, of the likelihood of this event. Since cumulative density functions are continuous, one needs to apply 'adjusting functions' to discrete priors to produce continuous posterior distributions.
Beta priors may be used to approximate a continuous CDF distribution for discrete event-based occurrences, such as with the use of a binomial distribution to estimate the number of "success" and "failure" outcomes in the toss of a coin.
Explore using a beta prior for binomial data, converting expert percentiles into alpha and beta with beta select, and deriving the exact posterior via the beta density.
simulate beta posteriors from binomial data by drawing many samples from a beta distribution and visualizing the posterior shape with a histogram.
The prior predictive distribution, in a Bayesian context, is the distribution of a data point marginalized over its prior distribution.
Explore how to form predictive priors and compute the predictive distribution for future binomial data using discrete and beta priors, with simulations to estimate likely success counts.
Learn to compute predictive probabilities with beta priors in a binomial setting, simulate predictive posteriors, and construct a 90 percent interval for future successes.
The use of single parameter models may be exemplified when one is trying to estimate the most likely mean parameter values, or the most likely standard deviation parameter values, but not both (that would be a multi-parameter model).
Explore Bayesian analyses in R by simulating posteriors from a Poisson heart transplant mortality model with gamma priors on lambda.
Apply a bayesian approach with a uniform prior on taxi counts up to 200, and compute the posterior on a grid to yield a mean near 123 and sd 22.27.
"Conjugate" models in the Bayesian approach simply mean that the functional form of the density function for both the prior distribution and the posterior distribution are similar, for example, both normally distributed. However "mixtures" refers to Bayesian models where there may be two different, and competing, components to the prior distribution, and one seeks an estimate of which of the two components is more likely, or more tenable.
Explore Bayesian mixtures and how to represent competing hypotheses with priors and posteriors using beta and binomial densities in R. Learn to test a coin's fairness with two-tailed decisions.
Set up two competing models with a 50 percent prior for the coin's fairness, then update with data via a Beta-binomial framework and report the posterior and P_beta_T.
Compare non-mixture and mixture priors in a bayesian analysis of coin fairness, using beta-binomial models to obtain 90% intervals around 0.44 to 0.56 and assess robustness.
In probability theory, a probability density function (PDF), or density of a continuous random variable, is a function that describes the relative likelihood for this random variable to take on a given value. For example, the PDF for a normally-distributed random variable takes the shape of the familiar "bell curve."
Explore normal distributions with shifting means and standard deviations, plot cumulative density functions, and compute p-values using P T, P Q R, and D functions, with the Old Faithful dataset.
Analyze eruption durations with stem-and-leaf plots, histograms, and the empirical cumulative distribution function to reveal bimodal patterns and distribution shapes, then assess normality with Q-Q plots and Shapiro-Wilk test.
Bayesian analysis with R uses a Poisson-gamma mixture to update two gamma priors from deaths over exposures, producing posterior that shifts toward higher mortality and shows <5% probability of ≥0.05.
In the Bayesian approach, multiparameter models are models in which one is attempting to estimate the probability density functions for more than one parameter, for example, both the mean and standard deviation of the target posterior parameters.
In probability theory, the multinomial distribution is a generalization of the binomial distribution. For n independent trials each of which leads to a success for exactly one of k categories, with each category having a given fixed success probability, the multinomial distribution gives the probability of any particular combination of numbers of successes for the various categories.
The binomial distribution is the probability distribution of the number of successes for one of just two categories in n independent Bernoulli trials, with the same probability of success on each trial. In a multinomial distribution, the analog of the Bernoulli distribution is the categorical distribution, where each trial results in exactly one of some fixed finite number k possible outcomes, with probabilities p1, ..., pk
Compare two proportions from a 2x2 contingency table of seat belt use and fatal versus non-fatal accidents in Florida 1998, and simulate a joint posterior distribution to assess relative risk.
Simulate beta-distributed death probabilities with and without a seat belt, compare relative risk, and show that not wearing a seat belt is about eight times more likely to die.
An integral is a mathematical object that can be interpreted as an area or a generalization of area. For example, to calculate the area under the "curve" of a continuous function f(x) up to some point "x" along the horizontal axis, one might compute the integral of f(x) at "x." Computing integrals are useful for finding probabilities that are represented as areas under a continuous function "curve" or plot.
In probability theory and statistics, the beta-binomial distribution is a family of discrete probability distributions on a finite support of non-negative integers arising when the probability of success in each of a fixed or known number of Bernoulli trials is either unknown or random. The beta-binomial distribution is the binomial distribution in which the probability of success at each trial is not fixed but random and follows the beta distribution. It is frequently used in Bayesian statistics, empirical Bayes methods and classical statistics as an overdispersed binomial distribution.
Perform bayesian inference for a normal population with mean and variance using a noninformative prior on 20 observations, simulate from joint posterior to estimate mean, 90% interval, and 75th percentile.
In mathematics, rejection sampling is a basic technique used to generate observations from a distribution. It is also commonly called the acceptance-rejection method or "accept-reject algorithm" and is a type of Monte Carlo method. The method works for any distribution in with a density.
Demonstrates rejection sampling for Bayesian computation by uniformly sampling within a bounded rectangle and rejecting points above the target function f, with a triangular example.
Apply rejection sampling using a multivariate t candidate with two degrees of freedom, guided by a Laplace fit for the mode and covariance, and inspect acceptance rates and posterior contours.
In statistics, importance sampling is a general technique for estimating properties of a particular distribution, while only having samples generated from a different distribution than the distribution of interest. It is related to umbrella sampling in computational physics.
Analyze streaky baseball performance with R by converting hits to binary sequences, computing longest hitting streaks, and using Monte Carlo simulation to assess significance of a 35-game run.
Simulate random streaks by permuting 160 game outcomes to estimate the longest run distribution with 100,000 replications. Compare uniform and beta bayesian models of hitting behavior to test streakiness.
Explore Bayesian analysis with the Laplace method, updating priors with a likelihood from grouped at-bats to estimate posterior odds and detect streaks.
Bayesian Computational Analyses with R is an introductory course on the use and implementation of Bayesian modeling using R software. The Bayesian approach is an alternative to the "frequentist" approach where one simply takes a sample of data and makes inferences about the likely parameters of the population. In contrast, the Bayesian approach uses both likelihood functions and a sample of observed data (the 'prior') to estimate the most likely values and distributions for the estimated population parameters (the 'posterior'). The course is useful to anyone who wishes to learn about Bayesian concepts and is suited to both novice and intermediate Bayesian students and Bayesian practitioners. It is both a practical, "hands-on" course with many examples using R scripts and software, and is conceptual, as the course explains the Bayesian concepts. All materials, software, R scripts, slides, exercises and solutions are included with the course materials. It is helpful to have some grounding in basic inferential statistics and probability theory. No experience with R is necessary, although it is also helpful.
The course begins with an introductory section (12 video lessons) on using R and R 'scripting.' The introductory section is intended to introduce RStudio and R commands so that even a novice R user will be comfortable using R. Section 2 introduces the Bayesian Rule, with examples of both discrete and beta priors, predictive priors, and beta posteriors in Bayesian estimation. Section 3 explains and demonstrates the use of Bayesian estimation for single parameter models, for example, when one wishes to estimate the most likely value of a mean OR of a standard deviation (but not both). Section 4 explains and demonstrates the use of "conjugate mixtures." These are single-parameter models where the functional form of the prior and post are similar (for example, both normally distributed). But 'mixtures' imply there may be more than one component for the prior or posterior density functions. Mixtures enable the simultaneous test of competing, alternative theories as to which is more likely. Section 5 deals with multi-parameter Bayesian models where one is estimating the likelihood of more than one posterior variable value, for example, both mean AND standard deviation. Section 6 extends the Bayesian discussion by examining the estimation of integrals to estimate a probability. Section 7 covers the application the Bayesian approach to rejection and importance sampling and Section 8 looks at examples of comparing and validating Bayesian models.