non parametric methods dr. mohammed alahmed 1. learning objectives 1.distinguish parametric &...
TRANSCRIPT
Dr. Mohammed Alahmed
Non Parametric Methods
1
Dr. Mohammed Alahmed 2
Learning Objectives
1. Distinguish Parametric & Nonparametric Test Procedures.
2. Explain commonly used Nonparametric Test Procedures.
3. Perform Hypothesis Tests Using Nonparametric Procedures.
Dr. Mohammed Alahmed 3
Introduction
• In the previous sections we learned a lot about one-sample, two-sample, paired t-tests, ANOVA, regression. All of these tests had some basic assumptions:1. the individual samples were approximately
normal.2. the individual samples came from populations
with approximately equal variance.3. we preferred that the individual samples were of
a size greater than 30.• Methods of estimation and hypothesis testing
have been based on these assumptions.
Dr. Mohammed Alahmed 4
• These procedures are usually called parametric statistical methods because the parametric form of the distribution is assumed to be known.
• If these assumptions about the shape of the distribution are not made, and/or if the central-limit theorem also seems inapplicable because of small sample size, then non-parametric statistical methods, which make fewer assumptions about the distributional shape, must be used.
• Non-parametric tests are typically focused on the median (rather than on the mean) and involve fairly straight-forward procedures like ordering and counting.
• Most nonparametric methods based on ranks instead of original data.
Dr. Mohammed Alahmed 5
Statistical TestingTest
ParametricNon Parametric
One Quantitative Response Variable
One-Sample t-test Sign Test
One Quantitative Response Variable – Two Values from Paired Samples
Paired Sample t-test
Wilcoxon Signed Rank Test
One Quantitative Response Variable – One Qualitative Independent Variable with two groups
Two-independent Sample t-test
Wilcoxon Rank Sum or Mann Whitney Test
One Quantitative Response Variable – One Qualitative Independent Variable with three or more groups
ANOVA Kruskall Wallis
Dr. Mohammed Alahmed 6
The Sign Test
• The sign test is used to test hypotheses about the median, rather than the mean in the parametric test.
• Assume the null hypothesis is that the median of the distribution is zero.
• Tests One Population Median.• Let S = number of values greater than median.• If null hypothesis is true, S should have
binomial distribution with success probability 0.5
• More precisely, number of positive values should follow a binomial distribution with probability 0.5
• When the sample is large, the binomial distribution can be approximated with a normal distribution.
Dr. Mohammed Alahmed 7
Conducting a sign test
• State the hypotheses:– H0: median = m0 and H1: median m0 (Two-
tailed) H1: median > m0 (Right-tailed) H1: median < m0 (Left-tailed)
• Convert data to plus (+) and minus (-) signs:– Change all data to + (above m0)
or – (below m0)
– Any values = m0 change to 0
Dr. Mohammed Alahmed 8
• Compare the number of + and – signs. (Ignore 0’s.) – If the number of + signs and the
number of – signs are approximately equal, the null hypothesis is not likely to be rejected.
– If they are not approximately equal, however, it is likely that the null hypothesis will be rejected.
Dr. Mohammed Alahmed 9
Test Statistic:• When n ≤ 20, the test statistic is the smaller
number (x) of + or – signs.• When n > 20, the test statistic is:
– where X is the smaller number of + or signs and n is the sample size, i.e., the total number of + or signs (zeros excluded).
( 0.5) 0.5
2
x nzn
Dr. Mohammed Alahmed 10
Example
• Recent studies of the private practices of physicians suggested that the median length of each patient visit was 22 minutes. It is believed that the median visit length in practices is shorter than 22 minutes. A random sample of 20 visits in practices yielded, in order, the following visit lengths:
9.4 13.4 15.6 16.2 16.4 16.8 18.1 18.7 18.9 19.1 19.3 20.1 20.4 21.6 21.9 23.4 23.5 24.8 24.9 26.8
• Based on these data, is there sufficient evidence to conclude that the median visit length in practices is shorter than 22 minutes?
Dr. Mohammed Alahmed 11
• Solution:• We are interested in testing:
H0: m = 22 vs. H1: m < 22.
Dr. Mohammed Alahmed 12
Dr. Mohammed Alahmed 13
Exact test (binomial):
Dr. Mohammed Alahmed 14
The Wilcoxon Signed-Rank Test
• Wilcoxon Signed-rank test is another non-parametric test used for paired data, equivalent to the paired t-test.
• We wish to test the hypothesis that the median of the first sample equals the median of the second.
• It is nonparametric, because it is based on the ranks of the observations rather than on their actual values, as is the paired t test.Use the Wilcoxon Signed-Rank if the assumption
of normality is violated for the paired-t test
Dr. Mohammed Alahmed 15
Procedure
• The first step in this test is to compute ranks for each observation, as follows:
1. Obtain Difference Scores, di = x1i - x2i , and arrange the differences di in order of absolute value.
2. Count the number of differences with the same absolute value.
3. Ignore the observations where di = 0, and rank the remaining observations from 1 for the observation with the lowest absolute value, up to n for the observation with the highest absolute value.
4. If any differences are equal, average their ranks5. Compute the rank sum R1 of the positive differences and
the rank sum R2 of the negative differences.
6. Compare the smaller of the two rank sums with the T value, obtained from the Appendix of Wilcoxon T values (Table 11).
7. If n ≥ 16, use normal approximation.
Dr. Mohammed Alahmed 16
Example
Patient
Hours of sleep
DifferenceRankIgnoring sign
Drug Placebo
1 6.1 5.2 0.9 3.5*
2 7.0 7.9 -0.9 3.5*
3 8.2 3.9 4.3 10
4 7.6 4.7 2.9 7
5 6.5 5.3 1.2 5
6 8.4 5.4 3.0 8
7 6.9 4.2 2.7 6
8 6.7 6.1 0.6 2
9 7.4 3.8 3.6 9
10 5.8 6.3 -0.5 13rd & 4th ranks are tied hence averagedR= smaller of R1 (50.5) and R2 (4.5)
Here R = 4.5 significant at 2% level (see Table 11) indicating the drug (hypnotic) is more effective than placebo.
Dr. Mohammed Alahmed 17
Dr. Mohammed Alahmed 18
Example
• Twelve adult males were put on a diet in a weight-reducing plan. Weights were recorded before and after the diet.
• The data are shown in the table below. • Use the Wilcoxon Signed-Rank Test to
determine if the plan was successful. Use α=0.05.Before 186 171 177 168 191 172 177 191 170 171 188 187
After 188 177 176 169 196 172 165 190 165 180 181 172
Dr. Mohammed Alahmed 19
Dr. Mohammed Alahmed 20
The Wilcoxon Rank-Sum Test
• The Wilcoxon Rank-Sum Test is a nonparametric analog to the t-test for two independent samples.
• Here, we do NOT have paired data, but rather n1 values from group 1 and n2 values from group 2.
• We want to test whether the values in the groups are samples from different distributions.
Used to determine if two independent samples came from the same or equal populations
Dr. Mohammed Alahmed 21
Procedure
• Rank the data of both the groups in ascending order. If any values are equal average their ranks.
• Compute the rank sum R1 in the first sample (the choice of sample is arbitrary).
• Compare this sum with the critical ranges given in table 12.
Dr. Mohammed Alahmed 22
Example
Non-smokers (n=15) Heavy smokers (n=14)Birth wt (Kg) Rank Birth wt (Kg) Rank3.99 27 3.18 73.79 24 2.84 53.60* 18 2.90 63.73 22 3.27 113.21 8 3.85 263.60* 18 3.52 144.08 28 3.23 93.61 20 2.76 43.83 25 3.60* 183.31 12 3.75 234.13 29 3.59 163.26 10 3.63 213.54 15 2.38 23.51 13 2.34 12.71 3
Sum=272 Sum=163
* 17, 18 & 19are tied hence the ranks are averaged
Dr. Mohammed Alahmed 23
H0: the observations come from the same population
Dr. Mohammed Alahmed 24
H0: m1 = m2 H1: m1 ≠ m2
Dr. Mohammed Alahmed 25
Kruskal-Wallis One-Way Analysis of Variance
In some instances we want to compare means among more than two samples, but either the underlying distribution is far from being normal or we have ordinal data.In these situations, a non-parametric alternative to the One-way ANOVA is The Kruskal-Wallis Test.
H0: All k populations have the same median.H1: Not all of the k population medians are the same.
Like all non-parametric tests, the focus is on ranks, counting and the medians.
The hypotheses statements are written as:
Dr. Mohammed Alahmed 26
The Kruskal-Wallis test
To compare the medians of K samples (K > 2) using nonparametric methods, use the following procedure:
2
1
123( 1)
( 1)
Ki
i i
RW n
n n n
• Pool the observations over all samples, thus constructing a combined sample of size n = Σni
• Assign ranks to the individual observations, using the average rank in the case of tied observations.
• Compute the rank sum Ri for each of the k samples.• If there are no ties, compute the test statistic
n is the total number of subjects; is the rank total for each group;ni is the number of subjects in each group
Dr. Mohammed Alahmed 27
• Under the null hypothesis, this has an approximate distribution
• The approximation is OK when each group contains at least 5 observations
• For a level α test:
21K
Reject Ho if W > , otherwise do not reject Ho
21K
Dr. Mohammed Alahmed 28
Example: Depression
Does physical exercise alleviate depression? We find some depressed peopleand check that they are all equivalently depressed to begin with. Then we allocate each person randomly to one of three groups: no exercise; 20 minutes of jogging per day; or 60 minutes of jogging per day. At the end of a month, we ask each participant to rate how depressed they now feel, on a Likert scale that runs from 1 ("totally miserable") through to 100 (ecstatically happy").The appropriate test here is the Kruskal-Wallis test. We have three separategroups of participants, each of whom gives us a single score on a rating scale. Ratings are examples of an ordinal scale of measurement, and so the data are not suitable for a parametric test.The Kruskal-Wallis test will tell us if the differences between the groups areso large that they are unlikely to have occurred by chance.
Dr. Mohammed Alahmed 29
No exercis
e
Jogging for 20 minutes
Jogging for 60
minutes23 22 59
26 27 66
51 39 38
49 29 49
58 46 56
37 48 60
29 49 5644 65 62
Data
Rating on depression scale:
Dr. Mohammed Alahmed 30
Dr. Mohammed Alahmed 31
Dr. Mohammed Alahmed 32
H0: All populations have the same median.H1: Not all of the population medians are the same.
Conclusion:Since p-value < α , then reject H0
Dr. Mohammed Alahmed 33
Key Concepts
• These methods can be used when the data cannot be measured on a quantitative scale, or when
• The numerical scale of measurement is arbitrarily set by the researcher, or when
• The parametric assumptions such as normality or constant variance are seriously violated.
Dr. Mohammed Alahmed 34
Hypothesis Testing:
Categorical Data
Dr. Mohammed Alahmed 35
Introduction
• In Chapters 7 and 8, the basic methods of hypothesis testing for continuous data were presented.
• If the variable under study is not continuous but is instead classified into categories, which may or may not be ordered, then different methods of inference should be used.
Dr. Mohammed Alahmed 36
• Categorical data analysis deals with discrete data that can be organized into categories.
• The data are organized into a contingency table.
• The c2 distribution is used in categorical data analysis.
Dr. Mohammed Alahmed 37
• Independent (Explanatory) Variable is Categorical (Nominal or Ordinal)
• Dependent (Response) Variable is Categorical (Nominal or Ordinal)
• Special Cases: – 2x2 (Each variable has 2 levels)– Nominal/Nominal– Nominal/Ordinal– Ordinal/Ordinal
Dr. Mohammed Alahmed 38
Contingency Tables
• Tables representing all combinations of levels of explanatory and response variables
• Numbers in table represent Counts of the number of cases in each cell
• Row and column totals are called Marginal counts
• The contingency table is also known as a crosstabulation, because it counts the cases that fall into each pairing of the table.
Dr. Mohammed Alahmed 39
Chi-Square (χ2) and Frequency Data
• For chi‑square, the data are frequencies rather than numerical scores.
• Chi Square is used when both variables are measured on a nominal or ordinal scale.
• It can be applied to interval or ratio data that have been categorized into a small number of groups.
• It assumes that the observations are randomly sampled from the population.
• All observations are independent (an individual can appear only once in a table and there are no overlapping categories).
• It does not make any assumptions about the shape of the distribution nor about the homogeneity of variances.
• Chi-squared is based upon the differences between observed and expected frequencies
Chi-Square Statistic
• Measures how far the observed values are from the expected values
• Take sum over all cells in table• When is large, there is evidence
that H0 is false.
2
statistictestexp
expobs
)( 22
Dr. Mohammed Alahmed 40
Dr. Mohammed Alahmed 41
• Two non-parametric hypothesis tests using the chi-square statistic: 1. the chi-square test for goodness
of fit2. the chi-square test for
independence. • Assumptions
– Independent observations.– A sample size of at least 10.– Random sampling.– All observations must be used.– For the test to be accurate, the expected
frequency should be at least 5.
Dr. Mohammed Alahmed 42
Goodness-of-Fit Test
• A goodness-of-fit test is an inferential procedure used to determine whether a frequency distribution follows a claimed distribution.
• The chi-square test for goodness-of-fit is a nonparametric test when we have (nominal or ordinal) data.
• it uses frequency data from a sample to test hypotheses about the shape or proportions of a population.
Dr. Mohammed Alahmed 43
• Each individual in the sample is classified into one category on the scale of measurement.
• The data, called observed frequencies, simply count how many individuals from the sample are in each category.
• The hypotheses to these tests are written a little different than we have seen in the past because they are usually written in word.
Dr. Mohammed Alahmed 44
Example(Example 10.40 page 401 in the book)
• Diastolic blood-pressure measurements were collected at home in a community-wide screening program of 14,736 adults ages 30−69 in East Boston, as part of a nationwide study to detect and treat hypertensive people. The people in the study were each screened in the home, with two measurements taken during one visit. A frequency distribution of the mean diastolic blood pressure is given in the Table in 10-mm Hg intervals.
Group (mm Hg)
<50 50 – 60 – 70 - 80 – 90 – 100 – 110- Total
Observed Frequency
57 330 2132 4584 4604 2119 659 251 14736
Dr. Mohammed Alahmed 45
• We would like to assume these measurements came from an underlying normal distribution, so that we can use parametric methods.
• We want to test:– Ho: the random variable follows normal distribution
– H1: the random variable does not follow normal distribution
• How can the above hypothesis be tested?• To test this hypothesis:
– Estimate parameters from data. – Compute expected counts. – Compute the test statistic used for contingency
tables. – This will now have a chi-squared distribution
under the null hypothesis.
Dr. Mohammed Alahmed 46
Dr. Mohammed Alahmed 47
Enter the expected frequency from Table 10.22
Dr. Mohammed Alahmed 48
Conclusion:We reject the null hypothesis. Thus the normal model does not provide an adequate fit to the data.
Dr. Mohammed Alahmed 49
Test of Independence
• The chi-square test of independence is probably the most frequently used hypothesis test in the social sciences.
• The chi-square test of independence is used to determine whether there is association between a row variable and column variable in a contingency table constructed from sample data.
Dr. Mohammed Alahmed 50
• Hypothesis:H0: The row variable is independent of the
column variable.H1: The row variable is dependent (related to) the column variable.
• Test Statistic:
n
CREE ii
thus,
n size sample Total
alColumn tot totalRow Expected
Expected
Observed
Dr. Mohammed Alahmed 51
Example
Smoking
Lung cancer
TotalPositive Negative
Obs. Exp. Obs. Exp.
Smoker15 7.67 8
15.33
23
Non smoker
512.3
332
24.67
37
Total 20 40 6023∗2060
To determine whether there is an association between smoking and lung cancer!
Dr. Mohammed Alahmed 52
• Hypothesis:
H0: No Relationship between smoking and lung cancerH1: The two variables are associated.
• Test statistic:
Exp
ExpObs 22 )( (𝟏𝟓−𝟕 .𝟔𝟕 )𝟐
𝟕 .𝟔𝟕+…+
(𝟑𝟐−𝟐𝟒 .𝟔𝟕)𝟐𝟐𝟒 .𝟔𝟕
= 17.045
Dr. Mohammed Alahmed 53
= 0.05df = (2 - 1)(2 - 1) = 1
Critical Value(s):χ2
1, α/2 = 3.841 from χ2 table
20 3.841
Reject
Test Statistic:
Decision:Reject H0 at = .05
Conclusion:There is evidence of a relationship between smoking and lung can-cer.
χ2 = 17.045
Dr. Mohammed Alahmed 54
Using SPSS
Dr. Mohammed Alahmed 55
Conclusion:Since p-value < α , then reject H0