P-values and statistical tests 3. t-test

Similar documents
Statistics Part IV Confidence Limits and Hypothesis Testing. Joe Nahas University of Notre Dame

Chapter 7: Statistical Inference (Two Samples)

Chapter 23. Inferences About Means. Monday, May 6, 13. Copyright 2009 Pearson Education, Inc.

T.I.H.E. IT 233 Statistics and Probability: Sem. 1: 2013 ESTIMATION AND HYPOTHESIS TESTING OF TWO POPULATIONS

Independent Samples t tests. Background for Independent Samples t test

Ch. 7. One sample hypothesis tests for µ and σ

Sampling distribution of t. 2. Sampling distribution of t. 3. Example: Gas mileage investigation. II. Inferential Statistics (8) t =

One-way ANOVA. Experimental Design. One-way ANOVA

One-Way Analysis of Variance (ANOVA) Paul K. Strode, Ph.D.

The One-Way Repeated-Measures ANOVA. (For Within-Subjects Designs)

Comparing Several Means: ANOVA

Two-sample inference: Continuous data

CBA4 is live in practice mode this week exam mode from Saturday!

Chemometrics. Matti Hotokka Physical chemistry Åbo Akademi University

One-Way Analysis of Variance: A Guide to Testing Differences Between Multiple Groups

Descriptive Statistics

Chapter 10: STATISTICAL INFERENCE FOR TWO SAMPLES. Part 1: Hypothesis tests on a µ 1 µ 2 for independent groups

Two sample Hypothesis tests in R.

The t-statistic. Student s t Test

Confidence Intervals, Testing and ANOVA Summary

LAB 2. HYPOTHESIS TESTING IN THE BIOLOGICAL SCIENCES- Part 2

Statistics 191 Introduction to Regression Analysis and Applied Statistics Practice Exam

QUEEN MARY, UNIVERSITY OF LONDON

Two-Sample Inferential Statistics

Design of Engineering Experiments Part 2 Basic Statistical Concepts Simple comparative experiments

PLSC PRACTICE TEST ONE

Introduction to Business Statistics QM 220 Chapter 12

Test 3 Practice Test A. NOTE: Ignore Q10 (not covered)

Analysis of Variance: Part 1

Data Analysis and Statistical Methods Statistics 651

Slides for Data Mining by I. H. Witten and E. Frank

Notes for Week 13 Analysis of Variance (ANOVA) continued WEEK 13 page 1

Ch 2: Simple Linear Regression

Review: General Approach to Hypothesis Testing. 1. Define the research question and formulate the appropriate null and alternative hypotheses.

Difference in two or more average scores in different groups

Chapter 10. Hypothesis Testing (I)

W&M CSCI 688: Design of Experiments Homework 2. Megan Rose Bryant

Confidence Intervals with σ unknown

" M A #M B. Standard deviation of the population (Greek lowercase letter sigma) σ 2

Tukey Complete Pairwise Post-Hoc Comparison

Six Sigma Black Belt Study Guides

Analysis of Variance (ANOVA) Cancer Research UK 10 th of May 2018 D.-L. Couturier / R. Nicholls / M. Fernandes

Lec 1: An Introduction to ANOVA

CHAPTER 10 ONE-WAY ANALYSIS OF VARIANCE. It would be very unusual for all the research one might conduct to be restricted to

On Assumptions. On Assumptions

Hypothesis Testing One Sample Tests

Session 8: Statistical Analysis of Measurements

One-Way Analysis of Variance. With regression, we related two quantitative, typically continuous variables.

STAT 401A - Statistical Methods for Research Workers

Homework 2: Simple Linear Regression

Hypothesis Testing in Action

AMS7: WEEK 7. CLASS 1. More on Hypothesis Testing Monday May 11th, 2015

Sociology 6Z03 Review II

Two-sample inference: Continuous Data

Chapter 24. Comparing Means. Copyright 2010 Pearson Education, Inc.

One-Way Analysis of Variance: ANOVA

MBA 605, Business Analytics Donald D. Conant, Ph.D. Master of Business Administration

Analysis of variance (ANOVA) Comparing the means of more than two groups

Two-sample inference: Continuous data

An inferential procedure to use sample data to understand a population Procedures

Topic 22 Analysis of Variance

Lecture 3: Inference in SLR

Chapter 10: Analysis of variance (ANOVA)

Inferences for Regression

2.830 Homework #6. April 2, 2009

Solutions to Practice Test 2 Math 4753 Summer 2005

Inference About Two Means: Independent Samples

Linear Combinations of Group Means

Table 1: Fish Biomass data set on 26 streams

Multiple Pairwise Comparison Procedures in One-Way ANOVA with Fixed Effects Model


Unit 27 One-Way Analysis of Variance

Chi-squared (χ 2 ) (1.10.5) and F-tests (9.5.2) for the variance of a normal distribution ( )

The One-Way Independent-Samples ANOVA. (For Between-Subjects Designs)

Review for Final. Chapter 1 Type of studies: anecdotal, observational, experimental Random sampling

STAT763: Applied Regression Analysis. Multiple linear regression. 4.4 Hypothesis testing

Chapter 12 - Lecture 2 Inferences about regression coefficient

HYPOTHESIS TESTING II TESTS ON MEANS. Sorana D. Bolboacă

Epidemiology Principles of Biostatistics Chapter 10 - Inferences about two populations. John Koval

Introduction. Chapter 8

z and t tests for the mean of a normal distribution Confidence intervals for the mean Binomial tests

Multiple comparisons - subsequent inferences for two-way ANOVA

4.1 Hypothesis Testing

Econometrics. 4) Statistical inference

Visual interpretation with normal approximation

Mathematical Notation Math Introduction to Applied Statistics

Analysing and presenting data: practical hints

10/31/2012. One-Way ANOVA F-test

Chapter 23: Inferences About Means

The entire data set consists of n = 32 widgets, 8 of which were made from each of q = 4 different materials.

16.400/453J Human Factors Engineering. Design of Experiments II

CIVL /8904 T R A F F I C F L O W T H E O R Y L E C T U R E - 8

CE3502. Environmental Measurements, Monitoring & Data Analysis. ANOVA: Analysis of. T-tests: Excel options

Lecture.10 T-test definition assumptions test for equality of two means-independent and paired t test. Student s t test

This is a multiple choice and short answer practice exam. It does not count towards your grade. You may use the tables in your book.

Statistics for EES Factorial analysis of variance

COMPLETELY RANDOM DESIGN (CRD) -Design can be used when experimental units are essentially homogeneous.

Chapter 9 Inferences from Two Samples

Lecture on Null Hypothesis Testing & Temporal Correlation

A discussion on multiple regression models

Transcription:

P-values and statistical tests 3. t-test Marek Gierliński Division of Computational Biology Hand-outs available at http://is.gd/statlec

Statistical test Null hypothesis H 0 : no effect Significance level α = 0.05 Data Statistic T p-value p < α Reject H 0 p α Insufficient evidence 2

One-sample t-test

One-sample t-test Null hypothesis: the sample came from a population with mean μ = 20 g 4

t-statistic n Sample x,, x.,, x 0 M - mean SD - standard deviation SE = SD/ n - standard error n From these we can find μ 2SE 2SE t = M μ SE n more generic form: t = deviation standard error 5

Student s t-distribution n t-statistic is distributed with t- distribution n Standardized Gaussian degrees of freedom n One parameter: degrees of freedom, ν n For large ν approaches Gaussian 6

William Gosset n Brewer and statistician n Developed Student s t-distribution n Worked for Guinness, who prohibited employees from publishing any papers n Published as Student n Worked with Fisher and developed the t- statistic in its current form n Always worked with experimental data n Progenitor bioinformatician? William Sealy Gosset (1876-1937) 7

William Gosset n Brewer and statistician n Developed Student s t-distribution n Worked for Guinness, who prohibited employees from publishing any papers n Published as Student n Worked with Fisher and developed the t- statistic in its current form n Always worked with experimental data n Progenitor bioinformatician? 8

Null distribution for the deviation of the mean Population of mice μ = 20 g, σ = 5 Select sample size 5 Z = t = M μ σ/ n M μ SD/ n 10 J Build distributions of M, Z and t 9

Null distribution for the deviation of the mean Original distribution Distribution of Z Gaussian μ, σ Gaussian 0, 1 Z Distribution of M Gaussian μ, σ/ n Distribution of t Gaussian 0, 1 t-distribution (ν) t 10

Null distribution for the deviation of the mean Distribution of Z Z = M μ σ/ n Gaussian 0, 1 σ - population parameter (unknown) Z Distribution of t t = M μ SD/ n = M μ SE Gaussian 0, 1 t-distribution (ν) SD - sample estimator (known) t 11

One-sample t-test n Consider a sample of n measurements o M sample mean o SD sample standard deviation o SE = SD/ n sample standard error null distribution t-distribution with 4 d.o.f. n Null hypothesis: the sample comes from a population with mean μ n Test statistic t = M μ SE n is distributed with t-distribution with n 1 degrees of freedom 12

One-sample t-test: example n H 0 : μ = 20 g n 5 mice with body mass (g): n 19.5, 26.7, 24.5, 21.9, 22.0 null distribution t-distribution with 4 d.o.f. M = 22.92 g SD = 2.76 g SE = 1.23 g Observation p = 0.04 22.92 20 t = 1.22 ν = 4 = 2.37 p = 0.04 > mass = c(19.5, 26.7, 24.5, 21.9, 22.0) > M = mean(mass) > n = length(mass) > SE = sd(mass) / sqrt(n) > t = (M - 20) / SE [1] 2.36968 > 1 - pt(t, n - 1) [1] 0.03842385 13

Normality of data Original distribution Distribution of t

Sidedness One-sided test H 1 : M > μ Two-sided test H 2 : M μ Observation p, = 0.04 p. = 0.08 p. = 2p, 15

One-sample t-test: summary Input sample of n measurement theoretical value μ (population mean) Assumptions Usage Observations are random and independent Data are normally distributed Examine if the sample is consistent with the population mean Null hypothesis Sample came from a population with mean μ Comments Limited usage (e.g. SILAC) Works well for non-normal distribution, as long as it is symmetric 16

How to do it in R? # One-sided t-test > mass = c(19.5, 26.7, 24.5, 21.9, 22.0) > t.test(mass, mu=20, alternative="greater") One Sample t-test data: mass t = 2.3697, df = 4, p-value = 0.03842 alternative hypothesis: true mean is greater than 20 95 percent confidence interval: 20.29307 Inf sample estimates: mean of x 22.92 17

Two-sample t-test

Two samples n Consider two samples (different sizes) n Are they different? n U = 12 M U = 19.0 g S U = 4.6 g n V = 9 M V = 24.0 g S V = 4.3 g n Are their means different? n Do they come from populations with different means? 19

The null distribution for the deviation between means Population of British mice μ = 20 g, σ = 5 Normal population μ = 20 g, σ = 5 g Select two samples size 12 and 9 t = M U M V SE M U M V Build distribution of ΔM and t x 1,000,000 20

Two-sample t-test n Null hypothesis: both samples come from populations of the same mean Distribution of ΔM n H 0 : μ, = μ. n Test statistic t = M, M. SE Distribution of t is distributed with t-distribution with ν degrees of freedom 21

Case 1: equal variances n Assume that both distributions have the same variance (or standard deviation) n Use pooled variance estimator: SD.,,. = n, 1 SD.., + n. 1 SD. n, + n. 2 n And then the standard error and the number of degrees of freedom are In case of equal samples sizes, n, = n., these equations simplify: SD.,,. = SD.., + SD. SE = SD,,. n ν = 2n 2 SE = SD,,. 1 n, + 1 n. ν = n, + n. 2 22

Case 1: equal variances, example n U = 12 M U = 19.0 g SD U = 4.6 g n V = 9 M V = 24.0 g SD V = 4.3 g t-distribution SD,,. = 4.5 g SE = 1.98 g ν = 19 t = 2.499 p = 0.011 p = 0.011 (one-sided) p = 0.022 (two-sided) 23

Case 2: unequal variances n Assume that distributions have different variances n Welch s t-test n Find individual standard errors (squared): SE., = SD,. SE. n. = SD.., n. n Find the common standard error: SE = SE,. + SE.. n Number of degrees of freedom ν SE,. + SE... SE, [ [ n, 1 + SE. n. 1 24

Case 2: unequal variances, example n U = 12 M U = 19.0 g SD U = 4.6 g n V = 9 M V = 24.0 g SD V = 4.3 g t-distribution SE. U = 1.8 g. SE. V = 2.1 g. SE = 1.96 g ν = 18 t = 2.524 p = 0.011 p = 0.011 (one-sided) p = 0.021 (two-sided)

What if variances are not equal? n Say, our samples come from two populations: o English: μ = 20 g, σ = 5 g o Scottish: μ = 20 g, σ = 2.5 g Equal variance t-statistic simulation t-distribution n Equal variance t-statistic does not represent the null hypothesis n t-test on samples: o equal : t = 4.17, p = 2.8 10 \[ o unequal : t = 4.56, p = 1.4 10 \[ Unequal variance t-statistic n Unless you are certain that the variances are equal, use the Welch s test 26

P-values vs. effect size n U = 12 n V = 9 logfc = 0.33 p = 0.022 n U = 100 n V = 100 logfc = 0.11 p = 0.022 27

P-value is not a measure of biological significance

Two-sample t test: summary Input two samples of n, and n. measurements Assumptions Usage Observations are random and independent (no before/after data) Data are normally distributed Compare sample means Null hypothesis Samples came from populations with the same means Comments Works well for non-normal distribution, as long as it is symmetric 29

How to do it in R? # Two-sided t-test, equal variances > English = c(16.5, 21.3, 12.4, 11.2, 23.7, 20.2, 17.4, 23, 15.6, 26.5, 21.8, 18.9) > Scottish = c(19.7, 29.3, 27.1, 24.8, 22.4, 27.6, 25.7, 23.9, 15.4) > t.test(english, Scottish, var.equal=t) Two Sample t-test data: English and Scottish t = -2.4993, df = 19, p-value = 0.02177 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -9.0903223-0.8041221 sample estimates: mean of x mean of y 19.04167 23.98889 # Two-sided t-test, unequal variances > t.test(english, Scottish, var.equal=f) Welch Two Sample t-test data: English and Scottish t = -2.5238, df = 17.969, p-value = 0.02125 30

Paired t-test

Paired t-test n Samples are paired n For example: mouse weight before and after obesity treatment n Null hypothesis: there is no difference between before and after n M` - the mean of the individual differences n Example: mouse body mass (g) Before: 21.4 20.2 23.5 17.5 18.6 17.0 18.9 19.2 After: 22.6 20.9 23.8 18.0 18.4 17.9 19.3 19.1 32

Paired t-test n Samples are paired n Find the differences: n b = x b y b then M - mean SD - standard deviation SE = SD / n - standard error The test statistic is t = M SE Non-paired t-test (Welch) M d M e = 0.46 g SE = 1.08 g t = 0.426 p = 0.34 M = 0.28 g SE = 0.17 g t = 2.75 p = 0.03 Paired test n t-distribution with n 1 degrees of freedom 33

How to do it in R? # Paired t-test > before = c(21.4, 20.2, 23.5, 17.5, 18.6, 17.0, 18.9, 19.2) > after = c(22.6, 20.9, 23.8, 18.0, 18.4, 17.9, 19.3, 19.1) > t.test(before, after, paired=t) Paired t-test data: before and after t = -2.7545, df = 7, p-value = 0.02832 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.85953136-0.06546864 sample estimates: mean of the differences -0.4625 34

F-test

Variance n One sample of size n n Sample variance. SD 0\, = 1 n 1 f x b M. b Sample mean Residual n Generalized variance: mean square n where MS = SS ν o SS - sum of squared residuals o ν - number of degrees of freedom 36

Comparison of variance n Consider two samples o English mice, n U = 12 o Scottish mice n V = 9 n U = 12 SD U. = 21 g 2 n V = 9 SD V. = 19 g 2 n We want to test if they come from the populations with the same variance, σ. n Null hypothesis: σ,. = σ.. n We need a test statistic with known distribution 37

Gedankenexperiment Population of British mice μ = 20 g, σ = 5 null distribution Select two samples size 12 and 9 F = SD U. SD V. Build distribution of F 38

Test to compare two variances n Consider two samples, sized n, and n. n Null hypothesis: they come from distributions with the same variance n H h : σ,. = σ.. F-distribution, ν, = 11, ν. = 8 n Test statistic: F = SD,. SD.. is distributed with F-distribution with n, 1 and n. 1 degrees of freedom Remainder Test statistic for two-sample t-test: t = M, M. SE 39

F-test n English mice: SD U = 4.61 g, n U = 12 n Scottish mice: SD V = 4.32 g, n U = 9 n Null hypothesis: they come from distributions with the same variance F-distribution, ν, = 11, ν. = 8 Observation n Test statistic: F = 4.61. 4.32. = 1.139 ν U = 11 ν V = 8 p = 0.44 p = 0.44 > 1 - pf(1.139, 11, 8) [1] 0.4375845 40

Two-sample variance test (F-test): summary Input two samples of n, and n. measurements Usage compare sample variances Null hypothesis samples came from populations with the same variance Comments requires normality of data right now, it might look pointless, but is necessary in ANOVA. Very important test! 41

How to do it in R? # Two-sample variance test > var.test(english, Scottish, alternative= greater ) F test to compare two variances data: English and Scottish F = 1.1389, num df = 11, denom df = 8, p-value = 0.4376 alternative hypothesis: true ratio of variances is greater to 1 95 percent confidence interval: 0.3437867 Inf sample estimates: ratio of variances 1.138948 42

Hand-outs available at http://tiny.cc/statlec