BayesFactor Examples

Similar documents
Statistics Lab #7 ANOVA Part 2 & ANCOVA

Non-Linear Regression. Business Analytics Practice Winter Term 2015/16 Stefan Feuerriegel

Discussion Notes 3 Stepwise Regression and Model Selection

22s:152 Applied Linear Regression

BIOL 458 BIOMETRY Lab 10 - Multiple Regression

Linear Model Selection and Regularization. especially usefull in high dimensions p>>100.

Variable selection is intended to select the best subset of predictors. But why bother?

9.1 Random coefficients models Constructed data Consumer preference mapping of carrots... 10

Generalized Additive Models

Model Selection and Inference

Demo yeast mutant analysis

22s:152 Applied Linear Regression

EXST 7014, Lab 1: Review of R Programming Basics and Simple Linear Regression

Analysis of variance - ANOVA

The theory of the linear model 41. Theorem 2.5. Under the strong assumptions A3 and A5 and the hypothesis that

Statistical Analysis of Series of N-of-1 Trials Using R. Artur Araujo

Stat 500 lab notes c Philip M. Dixon, Week 10: Autocorrelated errors

1 The SAS System 23:01 Friday, November 9, 2012

Salary 9 mo : 9 month salary for faculty member for 2004

Regression on the trees data with R

Non-linear Modelling Solutions to Exercises

Introduction to Statistical Analyses in SAS

Stat 5100 Handout #14.a SAS: Logistic Regression

Regression Lab 1. The data set cholesterol.txt available on your thumb drive contains the following variables:

Multiple Linear Regression: Global tests and Multiple Testing

Minitab 17 commands Prepared by Jeffrey S. Simonoff

5.5 Regression Estimation

Workshop 8: Model selection

2.830J / 6.780J / ESD.63J Control of Manufacturing Processes (SMA 6303) Spring 2008

Regression. Notes. Page 1 25-JAN :21:57. Output Created Comments

Orange Juice data. Emanuele Taufer. 4/12/2018 Orange Juice data (1)

Stat 5303 (Oehlert): Response Surfaces 1

Yelp Star Rating System Reviewed: Are Star Ratings inline with textual reviews?

Chapter 6: Linear Model Selection and Regularization

Section 3.2: Multiple Linear Regression II. Jared S. Murray The University of Texas at Austin McCombs School of Business

CDAA No. 4 - Part Two - Multiple Regression - Initial Data Screening

Multivariate Analysis Multivariate Calibration part 2

TI-83 Users Guide. to accompany. Statistics: Unlocking the Power of Data by Lock, Lock, Lock, Lock, and Lock

TABEL DISTRIBUSI DAN HUBUNGAN LENGKUNG RAHANG DAN INDEKS FASIAL N MIN MAX MEAN SD

ST512. Fall Quarter, Exam 1. Directions: Answer questions as directed. Please show work. For true/false questions, circle either true or false.

Moving Beyond Linearity

Set up of the data is similar to the Randomized Block Design situation. A. Chang 1. 1) Setting up the data sheet

Statistical Bioinformatics (Biomedical Big Data) Notes 2: Installing and Using R

Lecture 13: Model selection and regularization

Repeated Measures Part 4: Blood Flow data

610 R12 Prof Colleen F. Moore Analysis of variance for Unbalanced Between Groups designs in R For Psychology 610 University of Wisconsin--Madison

E-Campus Inferential Statistics - Part 2

Descriptives. Graph. [DataSet1] C:\Documents and Settings\BuroK\Desktop\Prestige.sav

36-402/608 HW #1 Solutions 1/21/2010

Using the SemiPar Package

A Knitr Demo. Charles J. Geyer. February 8, 2017

Mixed Effects Models. Biljana Jonoska Stojkova Applied Statistics and Data Science Group (ASDa) Department of Statistics, UBC.

Regression. Page 1. Notes. Output Created Comments Data. 26-Mar :31:18. Input. C:\Documents and Settings\BuroK\Desktop\Data Sets\Prestige.

Package stepnorm. R topics documented: April 10, Version Date

Stat 8053, Fall 2013: Additive Models

Data-Splitting Models for O3 Data

. predict mod1. graph mod1 ed, connect(l) xlabel ylabel l1(model1 predicted income) b1(years of education)

2017 ITRON EFG Meeting. Abdul Razack. Specialist, Load Forecasting NV Energy

Quantitative Methods in Management

Brief Guide on Using SPSS 10.0

An introduction to SPSS

Package condir. R topics documented: February 15, 2017

Stat 5303 (Oehlert): Unbalanced Factorial Examples 1

22s:152 Applied Linear Regression DeCook Fall 2011 Lab 3 Monday October 3

Regression Analysis and Linear Regression Models

Factorial ANOVA with SAS

Goals of the Lecture. SOC6078 Advanced Statistics: 9. Generalized Additive Models. Limitations of the Multiple Nonparametric Models (2)

Subset Selection in Multiple Regression

Quantitative Understanding in Biology Module II: Model Parameter Estimation Lecture IV: Quantitative Comparison of Models

Poisson Regression and Model Checking

Exponential Random Graph Models for Social Networks

Differentiation of Cognitive Abilities across the Lifespan. Online Supplement. Elliot M. Tucker-Drob

One Factor Experiments

R Workshop Guide. 1 Some Programming Basics. 1.1 Writing and executing code in R

StatCalc User Manual. Version 9 for Mac and Windows. Copyright 2018, AcaStat Software. All rights Reserved.

NCSS Statistical Software

Linear Methods for Regression and Shrinkage Methods

THE UNIVERSITY OF BRITISH COLUMBIA FORESTRY 430 and 533. Time: 50 minutes 40 Marks FRST Marks FRST 533 (extra questions)

Illustrations - Simple and Multiple Linear Regression Steele H. Valenzuela February 18, 2015

( ) = Y ˆ. Calibration Definition A model is calibrated if its predictions are right on average: ave(response Predicted value) = Predicted value.

Organizing data in R. Fitting Mixed-Effects Models Using the lme4 Package in R. R packages. Accessing documentation. The Dyestuff data set

Exploratory model analysis

What is machine learning?

CH9.Generalized Additive Model

Parallel line analysis and relative potency in SoftMax Pro 7 Software

Recall the expression for the minimum significant difference (w) used in the Tukey fixed-range method for means separation:

Applied Regression Modeling: A Business Approach

Fly wing length data Sokal and Rohlf Box 10.1 Ch13.xls. on chalk board

SYS 6021 Linear Statistical Models

CHAPTER 3. BUILDING A USEFUL EXPONENTIAL RANDOM GRAPH MODEL

Screening Design Selection

Multiple Linear Regression

Logical operators: R provides an extensive list of logical operators. These include

Predictive Checking. Readings GH Chapter 6-8. February 8, 2017

R-Square Coeff Var Root MSE y Mean

Rstudio GGPLOT2. Preparations. The first plot: Hello world! W2018 RENR690 Zihaohan Sang

Introduction to R, Github and Gitlab

SAS Workshop. Introduction to SAS Programming. Iowa State University DAY 2 SESSION IV

Fathom Dynamic Data TM Version 2 Specifications

Two-Stage Least Squares

Transcription:

BayesFactor Examples Michael Friendly 04 Dec 2015 The BayesFactor package enables the computation of Bayes factors in standard designs, such as one- and two- sample designs, ANOVA designs, and regression. Some examples taken from http://bayesfactorpcl.r-forge.r-project.org/ Load the package require(bayesfactor, quietly=true) ************ Welcome to BayesFactor 0.9.12-2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com). Type BFManual() to open the manual. ************ Independent groups t-test The ttestbf function is used to obtain Bayes factors corresponding to tests of a single sample's mean, or tests that two independent samples have the same mean. The chickwts data set has six groups, but we reduce it to two for the example. data(chickwts) Restrict to two groups chicks = chickwts[chickwts$feed %in% c("horsebean","linseed"),] Drop unused factor levels chicks$feed = factor(chicks$feed) Plot data plot(weight ~ feed, data = chicks, main = "Chick weights")

Traditional t test t.test(weight ~ feed, data = chicks, var.eq=true) Two Sample t-test data: weight by feed t = -2.934, df = 20, p-value = 0.008205 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -100.17618-16.92382 sample estimates: mean in group horsebean mean in group linseed 160.20 218.75 Compute the corresponding Bayes factor using ttestbf. This is expressed as the ratio of the posterior odds of M 1 relative to M 0. bf = ttestbf(formula = weight ~ feed, data = chicks) bf Bayes factor analysis -------------- [1] Alt., r=0.707 : 5.975741 ±0% Against denominator: Null, mu1-mu2 = 0 --- Bayes factor type: BFindepSample, JZS We can sample from the posterior distribution for the numerator model. There is one chain for each parameter. chains <- posterior(bf, iterations = 10000) plot(chains[,1:2], trace=false)

Two-way ANOVA The BayesFactor package has two main functions that allow the comparison of models with factors as predictors (ANOVA): anovabf, which computes several model estimates at once, and lmbf, which computes one comparison at a time. The ToothGrowth data is a 3x2 fixed-effect ANOVA. data(toothgrowth) # plot the data library(ggplot2) ggplot(toothgrowth, aes(x=dose, y=len)) + geom_point(position=position_jitter(width=0.1)) + geom_smooth(aes(group=1), size=1.5) + facet_grid(.~ supp) + theme_bw() geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to change the smoothing method. geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to change the smoothing method. Treat dose as a factor ToothGrowth$dose = factor(toothgrowth$dose) levels(toothgrowth$dose) = c("low", "Medium", "High") summary(tooth.aov <- aov(len ~ supp*dose, data=toothgrowth)) Df Sum Sq Mean Sq F value Pr(>F) supp 1 205.4 205.4 15.572 0.000231 *** dose 2 2426.4 1213.2 92.000 < 2e-16 *** supp:dose 2 108.3 54.2 4.107 0.021860 * Residuals 54 712.1 13.2 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

There appears to be a large effect of the dosage, a small effect of the supplement type, and perhaps a hint of an interaction. We could test model simplification via stepaic (Note that using k=log(n) gives BIC) MASS:::stepAIC(tooth.aov, k=log(nrow(toothgrowth))) Start: AIC=173 len ~ supp * dose Df Sum of Sq RSS AIC <none> 712.11 173.00 - supp:dose 2 108.32 820.43 173.31 Call: aov(formula = len ~ supp * dose, data = ToothGrowth) Terms: supp dose supp:dose Residuals Sum of Squares 205.350 2426.434 108.319 712.106 Deg. of Freedom 1 2 2 54 Residual standard error: 3.631411 Estimated effects may be unbalanced The anovabf function will compute the Bayes factors of all models against the intercept-only model; by default, it will choose the subset of all models in which which an interaction can only be included if all constituent effects or interactions are included (argument whichmodels is set to withmain, indicating that interactions can only enter in with their main effects). First, we show the default behavior. bf = anovabf(len ~ supp*dose, data=toothgrowth) bf Bayes factor analysis -------------- [1] supp : 1.198757 ±0.01% [2] dose : 4.983636e+12 ±0% [3] supp + dose : 2.942959e+14 ±1.57% [4] supp + dose + supp:dose : 7.421358e+14 ±1.1% Against denominator: Intercept only --- Bayes factor type: BFlinearModel, JZS Plot bayes factors against the intercept-only model plot(bf)

In the BayesFactor package "/" divides two Bayes factor objects to create new model comparisons The model with the main effect of supp and the supp:dose interaction is preferred quite strongly over the dose-only model. plot(bf[3:4] / bf[2]) Top-down analysis Using whichmodels="top" is like backward elimination, starting from the full model. bf = anovabf(len ~ supp*dose, data=toothgrowth, whichmodels="top") bf Bayes factor top-down analysis -------------- When effect is omitted from supp + dose + supp:dose, BF is... [1] Omit dose:supp : 0.3593662 ±2.79% [2] Omit dose : 6.422682e-16 ±5.87% [3] Omit supp : 0.01045709 ±3.34% Against denominator: len ~ supp + dose + supp:dose

--- Bayes factor type: BFlinearModel, JZS plot(bf)