Nonparametric tests and ANOVAs: What you need to know.

40
Nonparametric tests and ANOVAs: What you need to know
  • date post

    18-Dec-2015
  • Category

    Documents

  • view

    218
  • download

    0

Transcript of Nonparametric tests and ANOVAs: What you need to know.

Page 1: Nonparametric tests and ANOVAs: What you need to know.

Nonparametric testsand

ANOVAs: What you need to know

Page 2: Nonparametric tests and ANOVAs: What you need to know.

Nonparametric tests

• Nonparametric tests are usually based on ranks

• There are nonparametric versions of most parametric tests

Page 3: Nonparametric tests and ANOVAs: What you need to know.

Parametric

One-sample andPaired t-test

Two-sample t-test

Sign test

Mann-Whitney U-test

Nonparametric

Page 4: Nonparametric tests and ANOVAs: What you need to know.

Quick Reference Summary: Sign Test

• What is it for? A non-parametric test to compare the medians of a group to some constant

• What does it assume? Random samples• Formula: Identical to a binomial test with

po= 0.5. Uses the number of subjects with values greater than and less than a hypothesized median as the test statistic.

P(x) = probability of a total of x successesp = probability of success in each trialn = total number of trials

P(x) =n

x

⎝ ⎜

⎠ ⎟px 1− p( )

n−xP = 2 * Pr[xX]

Page 5: Nonparametric tests and ANOVAs: What you need to know.

SampleNull hypothesis

Median = mo

Null distributionBinomial n, 0.5

compare

How unusual is this test statistic?

P < 0.05 P > 0.05

Reject Ho Fail to reject Ho

Sign test

Test statisticx = number of values

greater than mo

Page 6: Nonparametric tests and ANOVAs: What you need to know.

Quick Reference Summary: Mann-Whitney U Test

• What is it for? A non-parametric test to compare the central tendencies of two groups

• What does it assume? Random samples• Test statistic: U

• Distribution under Ho: U distribution, with sample sizes n1 and n2

• Formulae:

U1 = n1n2 +n1 n1 +1( )

2− R1

U2 = n1n2 −U1

n1= sample size of group 1n2= sample size of group 2R1= sum of ranks of group 1

Use the larger of U1 or U2for a two-tailed test

Page 7: Nonparametric tests and ANOVAs: What you need to know.

SampleNull hypothesisThe two groupsHave the same

median

Null distributionU with n1, n2

compare

How unusual is this test statistic?

P < 0.05 P > 0.05

Reject Ho Fail to reject Ho

Mann-Whitney U test

Test statisticU1 or U2

(use the largest)

Page 8: Nonparametric tests and ANOVAs: What you need to know.

Mann-Whitney U test

• Large-sample approximation:

Z =2U − n1n2

n1n2 n1 + n2 +1( ) / 3

Use this when n1& n2 are both > 10Compare to the standard normal distribution

Page 9: Nonparametric tests and ANOVAs: What you need to know.

Mann-Whitney U Test

• If you have ties:– Rank them anyway, pretending they were

slightly different– Find the average of the ranks for the

identical values, and give them all that rank– Carry on as if all the whole-number ranks

have been used up

Page 10: Nonparametric tests and ANOVAs: What you need to know.

ExampleData

142542141814

Page 11: Nonparametric tests and ANOVAs: What you need to know.

ExampleSortedData

224514141418

Data

142542141814

Page 12: Nonparametric tests and ANOVAs: What you need to know.

ExampleSortedData

224514141418

Data

142542141814

TIES

Page 13: Nonparametric tests and ANOVAs: What you need to know.

ExampleSortedData

224514141418

Data

142542141814

TIES

Rank them anyway, pretending they were slightly different

Page 14: Nonparametric tests and ANOVAs: What you need to know.

ExampleRank A

224514141418

12345678

SortedDataData

142542141814

Page 15: Nonparametric tests and ANOVAs: What you need to know.

ExampleRank A

224514141418

12345678

SortedDataData

142542141814

Find the average of the ranks for the identical values, and give them all that rank

Page 16: Nonparametric tests and ANOVAs: What you need to know.

ExampleRank A

224514141418

12345678

SortedDataData

142542141814

Average = 1.5

Average = 6

Page 17: Nonparametric tests and ANOVAs: What you need to know.

ExampleRank A

224514141418

12345678

SortedDataData

142542141814

1.51.5346668

Rank

Page 18: Nonparametric tests and ANOVAs: What you need to know.

ExampleRank A

224514141418

12345678

SortedDataData

142542141814

1.51.5346668

Rank

These can now be used for the Mann-Whitney U test

Page 19: Nonparametric tests and ANOVAs: What you need to know.

Benefits and Costs of Nonparametric Tests

• Main benefit: – Make fewer assumptions about your data– E.g. only assume random sample

• Main cost: – Reduce statistical power– Increased chance of Type II error

Page 20: Nonparametric tests and ANOVAs: What you need to know.

When Should I Use Nonparametric Tests?

• When you have reason to suspect the assumptions of your test are violated– Non-normal distribution– No transformation makes the distribution

normal– Different variances for two groups

Page 21: Nonparametric tests and ANOVAs: What you need to know.

Quick Reference Summary: ANOVA (analysis of variance)• What is it for? Testing the difference among k

means simultaneously• What does it assume? The variable is

normally distributed with equal standard deviations (and variances) in all k populations; each sample is a random sample

• Test statistic: F• Distribution under Ho: F distribution with k-1

and N-k degrees of freedom

Page 22: Nonparametric tests and ANOVAs: What you need to know.

• Formulae:

Quick Reference Summary: ANOVA (analysis of variance)

F =MSgroupMSerror

MSerror =SSerrordferror

=SSerrorN − k

MSgroup =SSgroupdfgroup

=SSgroupk −1

SSerror = si2(ni −1)∑

SSgroup = ni(Y i −Y )2∑

Y i

Y= mean of group i= overall mean

ni = size of sample i

N = total sample size

Page 23: Nonparametric tests and ANOVAs: What you need to know.

k Samples

Null distributionF with k-1, N-k df

compare

How unusual is this test statistic?

P < 0.05 P > 0.05

Reject Ho Fail to reject Ho

ANOVA

Test statistic

F =MSgroupMSerror

Null hypothesisAll groups have the same mean

Page 24: Nonparametric tests and ANOVAs: What you need to know.

• Formulae:

Quick Reference Summary: ANOVA (analysis of variance)

F =MSgroupMSerror

MSerror =SSerrordferror

=SSerrorN − k

MSgroup =SSgroupdfgroup

=SSgroupk −1

SSerror = si2(ni −1)∑

SSgroup = ni(Y i −Y )2∑

Y i

Y= mean of group i= overall mean

ni = size of sample i

N = total sample size

There are a LOT of equations here,and this is the

simplest possible ANOVA

Page 25: Nonparametric tests and ANOVAs: What you need to know.

F =MSgroupMSerror

MSerror =SSerrordferror

=SSerrorN − k

MSgroup =SSgroupdfgroup

=SSgroupk −1

SSerror = si2(ni −1)∑

SSgroup = ni(Y i −Y )2∑

Page 26: Nonparametric tests and ANOVAs: What you need to know.

F =MSgroupMSerror

MSerror =SSerrordferror

=SSerrorN − k

MSgroup =SSgroupdfgroup

=SSgroupk −1

SSerror = si2(ni −1)∑

SSgroup = ni(Y i −Y )2∑ dfgroup = k-1

dferror = N-k

Page 27: Nonparametric tests and ANOVAs: What you need to know.

F =MSgroupMSerror

MSerror =SSerrordferror

=SSerrorN − k

MSgroup =SSgroupdfgroup

=SSgroupk −1

SSerror = si2(ni −1)∑

SSgroup = ni(Y i −Y )2∑ dfgroup = k-1

dferror = N-k

Sum of Squares df Mean Squares F-ratio

Page 28: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Tables

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment

Error

Total

Page 29: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Tables

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment

Error

Total €

SSerror = si2(ni −1)∑€

SSgroup = ni(Y i −Y )2∑

SSgroup + SSerror

Page 30: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Tables

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment k-1

Error N-k

Total N-1€

SSerror = si2(ni −1)∑€

SSgroup = ni(Y i −Y )2∑

SSgroup + SSerror

Page 31: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Tables

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment k-1

Error N-k

Total N-1€

SSerror = si2(ni −1)∑€

SSgroup = ni(Y i −Y )2∑

SSgroup + SSerror €

MSerror =SSerrordferror€

MSgroup =SSgroupdfgroup

Page 32: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Tables

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment k-1

Error N-k

Total N-1€

SSerror = si2(ni −1)∑€

SSgroup = ni(Y i −Y )2∑

SSgroup + SSerror €

MSerror =SSerrordferror€

MSgroup =SSgroupdfgroup

F =MSgroupMSerror

Page 33: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Tables

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment k-1

Error N-k

Total N-1€

SSerror = si2(ni −1)∑€

SSgroup = ni(Y i −Y )2∑

SSgroup + SSerror €

MSerror =SSerrordferror€

MSgroup =SSgroupdfgroup

F =MSgroupMSerror

*

Page 34: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Table: Example

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment 7.22 2

Error 9.41 19

Total

Page 35: Nonparametric tests and ANOVAs: What you need to know.

ANOVA Table: Example

Source of variation

Sum of squares

df Mean Squares

F ratio P

Treatment 7.22 2 3.61 7.29 0.004

Error 9.42 19 0.50

Total 16.64 21

Page 36: Nonparametric tests and ANOVAs: What you need to know.

Additions to ANOVA

• R2 value: how much variance is explained?

• Comparisons of groups: planned and unplanned

• Fixed vs. random effects

• Repeatability

Page 37: Nonparametric tests and ANOVAs: What you need to know.

Two-Factor ANOVA

• Often we manipulate more than one thing at a time

• Multiple categorical explanitory variables

• Example: sex and nationality

Page 38: Nonparametric tests and ANOVAs: What you need to know.

Two-factor ANOVA

• Don’t worry about the equations for this

• Use an ANOVA table

Page 39: Nonparametric tests and ANOVAs: What you need to know.

Two-factor ANOVA

• Testing three things:

1. Means don’t differ among treatment 1

2. Means don’t differ among treatment 2

3. There is no interaction between the two treatments

Page 40: Nonparametric tests and ANOVAs: What you need to know.

Two-factor ANOVA TableSource of variation

Sum of Squares

df Mean Square F ratio P

Treatment 1 SS1 k1 - 1 SS1

k1 - 1

MS1

MSE

Treatment 2 SS2 k2 - 1 SS2

k2 - 1

MS2

MSE

Treatment 1 * Treatment 2

SS1*2 (k1 - 1)*(k2 - 1) SS1*2

(k1 - 1)*(k2 - 1)

MS1*2

MSE

Error SSerror XXX SSerror

XXX

Total SStotal N-1