Statistical Programming Using the R Language Lecture 4 Experimental Design & ANOVA Darren J. Fitzpatrick, Ph.D April 2016.

Slides:



Advertisements
Similar presentations
Hypothesis Testing Steps in Hypothesis Testing:
Advertisements

Inferential Statistics
Lecture 3: Null Hypothesis Significance Testing Continued Laura McAvinue School of Psychology Trinity College Dublin.
HYPOTHESIS TESTING Four Steps Statistical Significance Outcomes Sampling Distributions.
Analysis of Variance and Multiple Comparisons Comparing more than two means and figuring out which are different.
Part I – MULTIVARIATE ANALYSIS
Differentially expressed genes
Descriptive Statistics Primer
Lecture 11 Psyc 300A. Null Hypothesis Testing Null hypothesis: the statistical hypothesis that there is no relationship between the variables you are.
Intro to Statistics for the Behavioral Sciences PSYC 1900
Analysis of Differential Expression T-test ANOVA Non-parametric methods Correlation Regression.
Lecture 9: One Way ANOVA Between Subjects
Educational Research by John W. Creswell. Copyright © 2002 by Pearson Education. All rights reserved. Slide 1 Chapter 8 Analyzing and Interpreting Quantitative.
PSY 307 – Statistics for the Behavioral Sciences Chapter 19 – Chi-Square Test for Qualitative Data Chapter 21 – Deciding Which Test to Use.
Today Concepts underlying inferential statistics
Summary of Quantitative Analysis Neuman and Robson Ch. 11
Lorelei Howard and Nick Wright MfD 2008
Chapter 14 Inferential Data Analysis
Richard M. Jacobs, OSA, Ph.D.
6.1 - One Sample One Sample  Mean μ, Variance σ 2, Proportion π Two Samples Two Samples  Means, Variances, Proportions μ 1 vs. μ 2.
Chapter 12 Inferential Statistics Gay, Mills, and Airasian
Inferential Statistics
Leedy and Ormrod Ch. 11 Gray Ch. 14
AM Recitation 2/10/11.
Multiple testing in high- throughput biology Petter Mostad.
1 STATISTICAL HYPOTHESES AND THEIR VERIFICATION Kazimieras Pukėnas.
Hypothesis Testing Charity I. Mulig. Variable A variable is any property or quantity that can take on different values. Variables may take on discrete.
One-Way Analysis of Variance Comparing means of more than 2 independent samples 1.
Copyright © 2012 Wolters Kluwer Health | Lippincott Williams & Wilkins Chapter 17 Inferential Statistics.
Chapter 15 Data Analysis: Testing for Significant Differences.
Introduction To Biological Research. Step-by-step analysis of biological data The statistical analysis of a biological experiment may be broken down into.
Biostatistics, statistical software V
Statistical Decision Making. Almost all problems in statistics can be formulated as a problem of making a decision. That is given some data observed from.
Statistical Power 1. First: Effect Size The size of the distance between two means in standardized units (not inferential). A measure of the impact of.
Statistics for the Terrified Paul F. Cook, PhD Center for Nursing Research.
TAUCHI – Tampere Unit for Computer-Human Interaction ERIT 2015: Data analysis and interpretation (1 & 2) Hanna Venesvirta Tampere Unit for Computer-Human.
Analysis of variance Petter Mostad Comparing more than two groups Up to now we have studied situations with –One observation per object One.
Testing Multiple Means and the Analysis of Variance (§8.1, 8.2, 8.6) Situations where comparing more than two means is important. The approach to testing.
Biostatistics, statistical software VII. Non-parametric tests: Wilcoxon’s signed rank test, Mann-Whitney U-test, Kruskal- Wallis test, Spearman’ rank correlation.
Chapter 10: Analyzing Experimental Data Inferential statistics are used to determine whether the independent variable had an effect on the dependent variance.
Inference and Inferential Statistics Methods of Educational Research EDU 660.
One-Way ANOVA ANOVA = Analysis of Variance This is a technique used to analyze the results of an experiment when you have more than two groups.
Test for Significant Differences T- Tests. T- Test T-test – is a statistical test that compares two data sets, and determines if there is a significant.
Introduction to sample size and power calculations Afshin Ostovar Bushehr University of Medical Sciences.
Educational Research Chapter 13 Inferential Statistics Gay, Mills, and Airasian 10 th Edition.
STATISTICAL ANALYSIS FOR THE MATHEMATICALLY-CHALLENGED Associate Professor Phua Kai Lit School of Medicine & Health Sciences Monash University (Sunway.
Analysis of Variance (ANOVA) Brian Healy, PhD BIO203.
1 Statistical Significance Testing. 2 The purpose of Statistical Significance Testing The purpose of Statistical Significance Testing is to answer the.
Analyzing Statistical Inferences How to Not Know Null.
Experimental Research Methods in Language Learning Chapter 10 Inferential Statistics.
Inferential Statistics. The Logic of Inferential Statistics Makes inferences about a population from a sample Makes inferences about a population from.
Marshall University School of Medicine Department of Biochemistry and Microbiology BMS 617 Lecture 13: One-way ANOVA Marshall University Genomics Core.
Statistics in Applied Science and Technology Chapter14. Nonparametric Methods.
Two-Way (Independent) ANOVA. PSYC 6130A, PROF. J. ELDER 2 Two-Way ANOVA “Two-Way” means groups are defined by 2 independent variables. These IVs are typically.
Tuesday, April 8 n Inferential statistics – Part 2 n Hypothesis testing n Statistical significance n continued….
1.  What inferential statistics does best is allow decisions to be made about populations based on the information about samples.  One of the most useful.
Course Overview Collecting Data Exploring Data Probability Intro. Inference Comparing Variables Relationships between Variables Means/Variances Proportions.
Marshall University School of Medicine Department of Biochemistry and Microbiology BMS 617 Lecture 6 –Multiple hypothesis testing Marshall University Genomics.
Chapter 13 Understanding research results: statistical inference.
Jump to first page Inferring Sample Findings to the Population and Testing for Differences.
ANalysis Of VAriance (ANOVA) Used for continuous outcomes with a nominal exposure with three or more categories (groups) Result of test is F statistic.
Statistical Programming Using the R Language Lecture 3 Hypothesis Testing Darren J. Fitzpatrick, Ph.D April 2016.
Educational Research Inferential Statistics Chapter th Chapter 12- 8th Gay and Airasian.
Statistical Programming Using the R Language Lecture 5 Introducing Multivariate Data Analysis Darren J. Fitzpatrick, Ph.D April 2016.
Inferential Statistics Psych 231: Research Methods in Psychology.
Posthoc Comparisons finding the differences. Statistical Significance What does a statistically significant F statistic, in a Oneway ANOVA, tell us? What.
Statistical Programming Using the R Language
Statistical Programming Using the R Language
I. Statistical Tests: Why do we use them? What do they involve?
Rest of lecture 4 (Chapter 5: pg ) Statistical Inferences
Presentation transcript:

Statistical Programming Using the R Language Lecture 4 Experimental Design & ANOVA Darren J. Fitzpatrick, Ph.D April 2016

Trinity College Dublin, The University of Dublin Solutions I holder <- c() for (i in 1:ncol(affected_genes)){ t_p <- t.test(unaffected_genes[,i], affected_genes[,i], paired=T)$p.value w_p <- wilcox.test(unaffected[,i], affected[,i], paired=T)$p.value p_r <- cor(unaffected_genes[,i], affected_genes[,i], method='pearson') s_r <- cor(unaffected_genes[,i], affected_genes[,i], method='spearman') all_vals <- c(t_p, w_p, p_r, s_r) holder <- rbind(holder, all_vals) }

Trinity College Dublin, The University of Dublin Solutions II 2.4 > holder [,1] [,2] [,3] [,4] all_vals e all_vals e all_vals e class(holder) holder_df <- as.data.frame(holder) names(holder_df) <- c('t_test', 'w_test', 'pear_r', 'spear_r') row.names(holder_df) <- c('guanylin', 'pyrroline', 'apolipoprotein')

Trinity College Dublin, The University of Dublin Solutions III 2.4 > holder_df t_test w_test pear_r spear_r guanylin e pyrroline e apolipoprotein e

Trinity College Dublin, The University of Dublin Overview Type I & Type II Errors Statistical Power Effect Sizes Power Calculations Multiple Hypothesis Testing ANOVA

Trinity College Dublin, The University of Dublin Type I & Type II Errors Type I error is a false positive, i.e., reject the null hypothesis when it is true. Type I errors are controlled by the p-value. Type II error is a false negative, i.e., accept the null hypothesis when it is false. Type II errors are controlled by statistical power. H 0 : Null Hypothesis H 1 : Alternative Hypothesis

Trinity College Dublin, The University of Dublin Type I & Type II Errors H0 is TrueH0 is False Accept H0True Positive p = 1-α Type II Error p = β Reject H0Type I Error p = α Correct Decision p = 1 – β (power) H 0 : Null Hypothesis H 1 : Alternative Hypothesis α is the Type I Error Rate. A p-value threshold of < 0.05 assumes a Type I Error Rate of 5%. β is the probability of accepting the null hypothesis if it is false. 1 – α is the probability of accepting the null hypothesis if it is true. 1 – β is the probability of rejecting the null hypothesis when it is false => POWER.

Trinity College Dublin, The University of Dublin Statistical Power I Statistical power, denoted 1-β, is the probability of rejecting the null hypothesis when it is false. Statistical power is an important part of experimental design. A study may not show a difference between groups because: 1.There is no difference (true negative) 2.The study failed to detect the difference (false negative) A common reason for a false negative: inadequate sample size to detect a significant difference. Power calculations enable us to estimate the sample size required to detect a difference of a given effect size at a given p-value threshold.

Trinity College Dublin, The University of Dublin Statistical Power II There is a relationship between the four quantities: sample size effect size significance level power When you know three values, you can determine the fourth. By convention, power is usually expected to be at least 0.8. But first, a brief mention of effect sizes!

Trinity College Dublin, The University of Dublin Effect Sizes I Effect sizes attempt to give a sense of the difference between groups irrespective of whether or not it is statistically significant. correlation coefficients regression coefficients Effect sizes are daunting (at least to me) and outside regression modelling and clinical trials research, I hardly hear mention of them in the biological literature. They appear to be a big thing in the psychological/social science literature. Nonetheless, they are required for power calculations.

Trinity College Dublin, The University of Dublin Effect Sizes II There are approaches to calculating effect sizes for hypothesis tests but they are outside the scope of this course. For a t-test, you could compute Cohen's d value For an ANOVA, you can compute the f-value For a correlation, it's just the correlation coefficient. R has a package to compute effect sizes ( compute.es ) You can compute an estimated effect size from sample data in order to determine the sample size required for your study. For our purposes, the effect sizes for a t-test and an ANOVA range from 0 – 1 (this is in fact the case using Cohen's d and the f-value).

Trinity College Dublin, The University of Dublin Power Calculations I R has a nice package for power calculations called pwr. FunctionPurpose pwr.anova.test() one-way ANOVA pwr.r.test() correlation pwr.t.test() t-tests pwr.t.test(n =, d =, sig.level = 0.05, power = 0.8, type = c("two.sample", "one.sample", "paired"), alternative = c("two.sided", "less", "greater")) install.packages('pwr') library(pwr)

Trinity College Dublin, The University of Dublin Power Calculations II e.size <-seq(0, 1, by=0.1) holder <- c() for (i in 1:length(e.size)){ sample.size <- pwr.t.test(d=e.size[i], sig.level=0.05, power=0.8)$n holder <- c(holder, sample.size) }

Trinity College Dublin, The University of Dublin Power Calculations III plot(e.size, holder, xlab='Effect Sizes', ylab='Sample Size', main='T-Test') lines(e.size, holder, col='red') The larger the effect size, the smaller the sample required to detect it.

Trinity College Dublin, The University of Dublin Multiple Hypothesis Testing I A Fishing Expedition – if you wait long enough, say between now and infinity, you will probably catch a fish.

Trinity College Dublin, The University of Dublin Multiple Hypothesis Testing II Could this be The Daily Mail, I wonder?

Trinity College Dublin, The University of Dublin Multiple Hypothesis Testing III H0 is TrueH0 is False Accept H0True Positive p = 1-α Type II Error p = β Reject H0Type I Error p = α Correct Decision p = 1 – β (power) The Type I Error Rate (α = 0.05) is applicable only to a single statistical test. If you perform multiple statistical tests on a data set, you have to adjust the Type I Error Rate in order to correct for the multiple tests.

Trinity College Dublin, The University of Dublin Multiple Hypothesis Testing IV The Family Wise Error Rate The FWER adjusts p-values so that it reflects the chance of at least 1 false positive. (methods: Bonferroni, Holm) A 5% FWER means there is a 5% chance that you have at least one false positive. The False Discovery Rate The FDR adjusts p-values so as to control for the frequency of false positives permitted (methods: Benjamini- Hochberg). A 5% FDR means that you would expect 5% of your findings to be false positives. FWER is more conservative than FDR.

Trinity College Dublin, The University of Dublin Multiple Hypothesis Testing V R has a single function to adjust p-values for multiple testing. p.adjust() takes two arguments a numeric vector of p-values a method p.adjust(x, method='bonferroni') p.adjust(x, method='BH')# FDR It returns a vector of corrected p-values. For Bonferroni, corrected p-values <= 0.05 FWER of 5% For FDR, corrected p-values <= 0.05 FDR of 5%

Trinity College Dublin, The University of Dublin Analysis of Variance I Yesterday we looked at how to compare two samples (t-test, wilcoxon test). Sometimes we wish to compare the more than two groups. Protein Method Correct 1 Ubiquitin CF_AVG Ubiquitin GOR Ubiquitin PHD DeoxyHb CF_AVG DeoxyHb GOR DeoxyHb PHD Rab5c CF_AVG Rab5c GOR Rab5c PHD Prealbumin CF_AVG Prealbumin GOR Prealbumin PHD proteins 3 methods to evaluate protein secondary structure Proportion of times a method predicted the correct secondary structure

Trinity College Dublin, The University of Dublin Analysis of Variance II We want to test whether the percent correct is different based on method. We have three groups – we could do multiple T-Tests. ANOVA allows us to first determine if there is any difference. ANOVA which is capable of comparing more than two groups. Protein Method Correct 1 Ubiquitin CF_AVG Ubiquitin GOR Ubiquitin PHD DeoxyHb CF_AVG DeoxyHb GOR DeoxyHb PHD Rab5c CF_AVG Rab5c GOR Rab5c PHD Prealbumin CF_AVG Prealbumin GOR Prealbumin PHD 0.780

Trinity College Dublin, The University of Dublin Analysis of Variance III ANOVA looks at the response variable (Correct) and analyses the within group and between group variability. Within group variability can be considered noise. Accounting for within group variability, the between group variability is the signal or the variability due to method in this case. Do we have a real difference between the methods (CF_AVG, GOR, PHD) relative to the noise? Protein Method Correct 1 Ubiquitin CF_AVG Ubiquitin GOR Ubiquitin PHD DeoxyHb CF_AVG DeoxyHb GOR DeoxyHb PHD Rab5c CF_AVG Rab5c GOR Rab5c PHD Prealbumin CF_AVG Prealbumin GOR Prealbumin PHD 0.780

Trinity College Dublin, The University of Dublin Analysis of Variance IV In brief, an ANOVA looks at the ratio of between group variability and within group variability or the 'signal-to-noise'. It uses this ratio to compute an F- test statistic to decide if there is a statistical difference between groups. Protein Method Correct 1 Ubiquitin CF_AVG Ubiquitin GOR Ubiquitin PHD DeoxyHb CF_AVG DeoxyHb GOR DeoxyHb PHD Rab5c CF_AVG Rab5c GOR Rab5c PHD Prealbumin CF_AVG Prealbumin GOR Prealbumin PHD 0.780

Trinity College Dublin, The University of Dublin Analysis of Variance V anova(lm(Correct~Method, data=df)) Analysis of Variance Table Response: Correct Df Sum Sq Mean Sq F value Pr(>F) Method *** Residuals is our between group variability is our within group variability The F-value is the ratio of these two ANOVA tells us there is a difference somewhere but does not tell us which factor is causing that difference.

Trinity College Dublin, The University of Dublin Analysis of Variance VI To find where the difference lies, we have to do some post-hoc t-tests. pairwise.t.test(df$Correct, df$Method, p.adjust.method='BH') Pairwise comparisons using t tests with pooled SD data: df$Correct and df$Method CF_AVG GOR GOR PHD Notice the adjustment for multiple testing!

Trinity College Dublin, The University of Dublin Analysis of Variance VII anova(lm(Correct~Method + Protein, data=df)) Analysis of Variance Table Response: Correct Df Sum Sq Mean Sq F value Pr(>F) Method *** Protein Residuals The Two-Way ANOVA

Trinity College Dublin, The University of Dublin Analysis of Variance VIII kruskal.test(Correct~Method, data=df) Kruskal-Wallis rank sum test data: Correct by Method Kruskal-Wallis chi-squared = , df = 2, p-value = The Kruskal-Wallis Non-Parametric One Way ANOVA

Trinity College Dublin, The University of Dublin Analysis of Variance IX pairwise.wilcox.test(df$Correct, df$Method, p.adjust.method='BH') Pairwise comparisons using Wilcoxon rank sum test data: df$Correct and df$Method CF_AVG GOR GOR PHD P value adjustment method: BH Post-Hoc Pairwise Wilcoxon Tests

Trinity College Dublin, The University of Dublin Lecture 4 Problem Sheet A problem sheet entitled lecture_4_problems.pdf is located on the course website. Some of the code required for the problem sheet has been covered in this lecture. Consult the help pages if unsure how to use a function. Please attempt the problems for the next mins. We will be on hand to help out. Solutions will be posted this afternoon.

Thank You