One way ANOVA when the data are not normally distributed (The Kruskal-Wallis test).

Similar documents
Section 0.3 The Order of Operations

Nuts and Bolts Research Methods Symposium

Nonparametric Testing

Table of Laplace Transforms

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Binary, Hexadecimal and Octal number system

for statistical analyses

Signed umbers. Sign/Magnitude otation

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

STATS PAD USER MANUAL

SAMLab Tip Sheet #1 Translating Mathematical Formulas Into Excel s Language

Lab #9: ANOVA and TUKEY tests

Intro. Scheme Basics. scm> 5 5. scm>

Organizing Your Data. Jenny Holcombe, PhD UT College of Medicine Nuts & Bolts Conference August 16, 3013

Divisibility Rules and Their Explanations

COUNTING AND CONVERTING

Week 4: Simple Linear Regression II

Frequency Distributions

4.7 Approximate Integration

Simple Graph. General Graph

But I know what most of you will do: use a calculator to convert; that's fine, IF you understand the theory.

Statistical Pattern Recognition

2.9 Linear Approximations and Differentials

Math 214 Introductory Statistics Summer Class Notes Sections 3.2, : 1-21 odd 3.3: 7-13, Measures of Central Tendency

The Power and Sample Size Application

Introduction to Counting, Some Basic Principles

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

1 Pencil and Paper stuff

FreeJSTAT for Windows. Manual

Intro to Algorithms. Professor Kevin Gold

Statistics Case Study 2000 M. J. Clancy and M. C. Linn

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

What's the Slope of a Line?

Pong in Unity a basic Intro

Why is Statistics important in Bioinformatics?

Matlab for Engineers

Enter your UID and password. Make sure you have popups allowed for this site.

6.001 Notes: Section 6.1

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

Statistical Pattern Recognition

Comparison of Means: The Analysis of Variance: ANOVA

Section 2.3: Simple Linear Regression: Predictions and Inference

CS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych

Diode Lab vs Lab 0. You looked at the residuals of the fit, and they probably looked like random noise.

Stat 5303 (Oehlert): Unreplicated 2-Series Factorials 1

Statistical Pattern Recognition

Repetition Through Recursion

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

1 Algorithm and Proof for Minimum Vertex Coloring

MA 1128: Lecture 02 1/22/2018

Introduction to Asymptotic Running Time Analysis CMPSC 122

Customizing DAZ Studio

PROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized

Table Of Contents. Table Of Contents

Denotational semantics

Averages and Variation

Copyright. For more information, please read the Disclosures and Disclaimers section at the end of this ebook. First PDF Edition, February 2013

SAS/STAT 13.1 User s Guide. The Power and Sample Size Application

Week 6, Week 7 and Week 8 Analyses of Variance

Source df SS MS F A a-1 [A] [T] SS A. / MS S/A S/A (a)(n-1) [AS] [A] SS S/A. / MS BxS/A A x B (a-1)(b-1) [AB] [A] [B] + [T] SS AxB

Computer Science 210 Data Structures Siena College Fall Topic Notes: Searching and Sorting

Types, Expressions, and States

Statistics: Interpreting Data and Making Predictions. Visual Displays of Data 1/31

Chapter 5 Errors. Bjarne Stroustrup

Macros and ODS. SAS Programming November 6, / 89

NAG C Library Function Document nag_kruskal_wallis_test (g08afc)

For searching and sorting algorithms, this is particularly dependent on the number of data elements.

Recursively Enumerable Languages, Turing Machines, and Decidability

Chapter 1. Math review. 1.1 Some sets

CSE 142/143 Unofficial Commenting Guide Eric Arendt, Alyssa Harding, Melissa Winstanley

One Factor Experiments

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

Bluman & Mayer, Elementary Statistics, A Step by Step Approach, Canadian Edition

Product Catalog. AcaStat. Software

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

The Excel Project: Excel for Accountants, Business People... from the Beginning Duncan Williamson

(Refer Slide Time 04:53)

Notebook Assignments

Problem One: A Quick Algebra Review

Linked Lists. What is a Linked List?

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

Programming for Engineers Introduction to C

Part II Composition of Functions

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute

CS 4349 Lecture October 18th, 2017

What s New in Spotfire DXP 1.1. Spotfire Product Management January 2007

Monday. A few notes on homework I want ONE spreadsheet with TWO tabs

Calculations with Sig Figs

Notes on Non-Chronologic Backtracking, Implication Graphs, and Learning

Is the statement sufficient? If both x and y are odd, is xy odd? 1) xy 2 < 0. Odds & Evens. Positives & Negatives. Answer: Yes, xy is odd

CHAPTER 3: Data Description

When using computers, it should have a minimum number of easily identifiable states.

(Refer Slide Time 3:31)

Using Computator page F or t or means or r -> d. Effect Sizes (ES) & Meta-Analyses. Using Computator page F or t or means or r -> d

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

Algorithm Analysis. College of Computing & Information Technology King Abdulaziz University. CPCS-204 Data Structures I

NAG Library Function Document nag_kruskal_wallis_test (g08afc)

Skill 1: Multiplying Polynomials

More Summer Program t-shirts

Section 4 General Factorial Tutorials

Transcription:

One way ANOVA when the data are not normally distributed (The Kruskal-Wallis test). Suppose you have a one way design, and want to do an ANOVA, but discover that your data are seriously not normal? Just like with the MWU test as replacement for the t-test, there is the Kruskal-Wallis test for a one way ANOVA. In fact, if you have just two groups, the KW test will give you the identical results to a MWU test (sort of like a ANOVA gives the same result as a equal variance t-test). Before we look at the KW test, note that there are other things that we can do: Remember transformations. They can make non-normal data normal. That's probably the only way to deal with more complicated designs. Things like a two way ANOVA, nested designs, etc., don't have non-parametric equivalents (well, there is one for two way designs... more on that later). Check out your text in chapter 13 for some ideas. Let's introduce the KW test: Just like the MWU test, if make no assumptions other than randomness, we can use the KW test pretty much anytime. It has no other assumptions we need to worry about. But what are we testing now? H 0 : H 1 : All k population distributions are identical At least one of these is different (tends to yield larger/smaller observations than the others). Just like last time, though, if we assume distributions are similar except in location, we can use means (or medians) instead. Then proceed as usual: - select α - calculate test statistic (let s call it W*) - compare it to a value from KW tables - if W* to W table (but see below), then reject. So, what is W*? It s a bit messy, and is given by (note I'm doing things just a bit differently from the text):

W * = 1 S 2 k 2 i=1 n i N N 1 2 4 (Your text (on page 217) uses a slightly different formula). Yech! But let s not give up yet. It s really not that difficult. Let s figure out what the various parts of this are: N = total sample size (= n*, using our ANOVA notation) = sum of the ranks of the i th sample: n i = R X ij j=1 This says, take the rank of each of the x s and sum these values for each sample (this is very similar to the way we did things in the MWU test (in this class)). Notice that the very first thing we ll have to do is to rank our observations from smallest to largest (write in the rank next to our each of our observations). S 2 = an analogue of the variance (notice this is capitalized). It s given as follows: S 2 = 1 N 1 R X ij 2 N N 1 2 all ranks 4 Okay, now you re really worried. But let s stick with it for just a little longer. This says, Sum up all the square of each of the ranks, then subtract the other quantity (the one involving N). That s not too bad. Now we know how to calculate W* (it ll be much more obvious after an example). But what about W? - This is a bit of a problem. Remember how you needed to have n and n (n 1 and n 2 in our class) in the Mann-Whitney U-test? - now we have 2, 3, 4... or more samples, so we really can t list the probabilities for everything. - Let s take another quick look at W*. It turns out if there are no ties, we can re-write it as: W * = 12 k 2 3 N 1 N N 1 i=1 n i This is identical to the formula in your text for no ties.

(If there are no ties, then use this formula - it s a lot easier) The stuff in the sum symbol is kind of analogous to what we observed -we re using the actual ranks and getting a kind of sum (squared and adjusted by n i, but still a sum). The 3(N+1) term is kind of what we would expect for the sums if the ranks were basically equal in each sample. The term in front of the sum symbol is another type of expected value. {Note: the sum of a bunch of numbers going from 1...n = n(n+1)/2, so you might recognize that both 3(N+1) and the quantity out front are a little similar)}. So we have an observed quantity (-) an expected quantity, where the observed is also divided by an expected quantity. Sound just a little familiar? As it turns out W* has (approximately) the Chi-square distribution. So what do you look up for W? A Chi-square value with k-1 degrees of freedom. Your text takes a different approach, and for small sample sizes and less than four groups gives you the exact values in table B.13. We'll just stick with the Chisquare approach since it's much easier. As mentioned, this is an approximation, and exact tables do exist, but they take up a good portion of a book, and your text only does this for small n and k up to 4. So how does it all work?? An example (let s use an example similar to the pig diet example, but this time we're looking at sheep (it's the same example the 214 text uses to introduce one way ANOVA): Let s do H 0 : the diets are all the same. H 1 : at least one of the diets is different. α =.05 Diet 1 Diet 2 Diet 3 value rank rank 2 value rank rank 2 value rank rank 2 8 2 4 9 3.5 12.25 15 7 49 16 8.5 72.25 16 8.5 72.25 10 5 25 9 3.5 12.25 21 12 144 17 10 100 11 6 36 6 1 1 18 11 121 Sum ( ) 14 88.5 41 385 23 175 n i 3 5 4 Notice that N = n* = 12; also notice that the highest rank is 12, so everything s fine so far (if one or more values are tied, you need to use the average rank). Now we calculate S 2 :

S 2 = 1 132 11 649 12 4 = 12.909 Now we merely plug all this into W* to get: W * = 1 12.909 142 3 412 5 232 4 12 132 4 = 2.075 Let s get W table, using our Chi-square table and 2 d.f.: W table = 5.99 And since W* < W table, we fail to reject and conclude we have no evidence to show the diets are different. Let s summarize: When do you use KW? When you don t meet the assumptions of (one way) ANOVA: As usual, with a larger sample size, ANOVA will start to do better, and you don t need to worry about the normal assumption as much. What about equal variances? If you're worried about unequal variances, don't test for equal means. Use the general form of the KW test. How about power? Pretty good; even when the data are normal it doesn t do too badly. Why not use it all the time? As you probably know by now, ANOVA is much more flexible. The number of designs available for ANOVA is almost endless. And even though the power isn t bad, it isn t the best test to use if data are normal. Multiple comparisons are available for the KW test, but we just don t have time to discuss this as well. We didn t do too much with the theory here. The basic idea is very similar to that of the Mann- Whitney U test, the only odd thing is that we can get away with using Chi-square tables instead of exact tables. Doing Kruskal-Wallis in R: The basic setup is almost identical to a one way ANOVA. Here's the above diet example in R: gain <- scan() 8 16 9 9 16 21 11 18 15 10 17 6

diet <- scan() 1 1 1 2 2 2 2 2 3 3 3 3 diet <- factor(diet) kruskal.test(gain ~ diet) Kruskal-Wallis rank sum test data: gain by diet Kruskal-Wallis chi-squared = 2.0748, df = 2, p-value = 0.3544 (R calls the test statistics Kruskal-Wallis chi-squared ) Finally, what about two way or more complicated designs? The Kruskal-Wallis test is designed for one-way type analyses. There are other non-parametric tests for more complicated designs; if you need to use something like this, you can look up the Quade test or the Friedman test (the Friedman test is related to the sign test). The Friedman test works for two way designs, but isn't very powerful. The Quade test works for blocked designs, and is worth looking at if you have serious problems with normality and are using a blocked design.