What is the Kruskal Wallis Test?
The Kruskal Wallis H test uses ranks instead of actual data.
The Kruskal Wallis test is the non parametric alternative to the One Way ANOVA. Non
parametric means that the test doesn’t assume your data comes from a particular distribution.
The H test is used when the assumptions for ANOVA aren’t met (like the assumption of
normality). It is sometimes called the one-way ANOVA on ranks, as the ranks of the data
values are used in the test rather than the actual data points.
The test determines whether the medians of two or more groups are different. Like most
statistical tests, you calculate a test statistic and compare it to a distribution cut-off point. The
test statistic used in this test is called the H statistic. The hypotheses for the test are:
H0: population medians are equal.
H1: population medians are not equal.
The Kruskal Wallis test will tell you if there is a significant difference between groups.
However, it won’t tell you which groups are different. For that, you’ll need to run a Post
Hoc test.
Examples
You want to find out how test anxiety affects actual test scores. The independent variable
“test anxiety” has three levels: no anxiety, low-medium anxiety and high anxiety. The
dependent variable is the exam score, rated from 0 to 100%.
You want to find out how socioeconomic status affects attitude towards sales tax increases.
Your independent variable is “socioeconomic status” with three levels: working class, middle
class and wealthy. The dependent variable is measured on a 5-point Likert scale from
strongly agree to strongly disagre
Running the H Test
Sample question: A shoe company wants to know if three groups of workers have different
salaries:
Women: 23K, 41K, 54K, 66K, 78K.
Men: 45K, 55K, 60K, 70K, 72K
Minorities: 18K, 30K, 34K, 40K, 44K.
Step 1: Sort the data for all groups/samples into ascending order in one combined set.
20K
23K
30K
34K
40K
41K
44K
45K
54K
55K
60K
66K
70K
72K
90K
Step 2: Assign ranks to the sorted data points. Give tied values the average rank.
20K 1
23K 2
30K 3
34K 4
40K 5
41K 6
44K 7
45K 8
54K 9
55K 10
60K 11
66K 12
70K 13
72K 14
90K 15
Step 3: Add up the different ranks for each group/sample.
Women: 23K, 41K, 54K, 66K, 90K = 2 + 6 + 9 + 12 + 15 = 44.
Men: 45K, 55K, 60K, 70K, 72K = 8 + 10 + 11 + 13 + 14 = 56.
Minorities: 20K, 30K, 34K, 40K, 44K = 1 + 3 + 4 + 5 + 7 = 20.
Step 4: Calculate the H statistic:
Where:
n = sum of sample sizes for all samples
c = number of samples,
Tj = sum of ranks in the jth sample,
nj = size of the jth sample.
H = 6.72
Step 5: Find the critical chi-square value, with c-1 degrees of freedom. For 3 – 1 degrees of
freedom and an alpha level of .05, the critical chi square value is 5.9915.
Step 6: Compare the H value from Step 4 to the critical chi-square value from Step 5.
If the critical chi-square value is less than the H statistic, reject the null hypothesis that the
medians are equal.
If the chi-square value is not less than the H statistic, there is not enough evidence to suggest
that the medians are unequal.
In this case, 5.9915 is less than 6.72, so you can reject the null hypothesis.
https://www.statisticshowto.datasciencecentral.com/kruskal-wallis/
by Stephanie, Feb 24 2016
What is a T test?
The t-distribution, used for the t-test. Image: Carnegie Mellon.
The t test tells you how significant the differences between groups are; In other words it lets
you know if those differences (measured in means/averages) could have happened by chance.
Examples
: Let’s say you have a cold and you try a naturopathic remedy. Your cold lasts a couple of
days. The next time you have a cold, you buy an over-the-counter pharmaceutical and the
cold lasts a week. You survey your friends and they all tell you that their colds were of a
shorter duration (an average of 3 days) when they took the homeopathic remedy. What
you really want to know is, are these results repeatable? A t test can tell you by comparing the
means of the two groups and letting you know the probability of those results happening by
chance.
: Student’s T-tests can be used in real life to compare means. For example, a drug company
may want to test a new cancer drug to find out if it improves life expectancy. In an
experiment, there’s always a control group (a group who are given a placebo, or “sugar pill”).
The control group may show an average life expectancy of +5 years, while the group taking
the new drug might have a life expectancy of +6 years. It would seem that the drug might
work. But it could be due to a fluke. To test this, researchers would use a Student’s t-test to
find out if the results are repeatable for an entire population.
Paired Samples T Test By hand
Sample question: Calculate a paired t test by hand for the following data:
Step 1: Subtract each Y score from each X score.
Step 2: Add up all of the values from Step 1.
Set this number aside for a moment.
Step 3: Square the differences from Step 1.
Step 4: Add up all of the squared differences from Step 3.
Step 5: Use the following formula to calculate the t-score:
ΣD: Sum of the differences (Sum of X-Y from Step 2)
ΣD2: Sum of the squared differences (from Step 4)
(ΣD)2: Sum of the differences (from Step 2), squared.
Step 6: Subtract 1 from the sample size to get the degrees of freedom. We have 11 items,
so 11-1 = 10.
Step 7: Find the p-value in the t-table, using the degrees of freedom in Step 6. If you don’t
have a specified alpha level, use 0.05 (5%). For this sample problem, with df=10, the t-value
is 2.228.
Step 8: Compare your t-table value from Step 7 (2.228) to your calculated t-value (-2.74).
The calculated t-value is greater than the table value at an alpha level of .05. The p-value is
less than the alpha level: p <.05. We can reject the null hypothesis that there is no difference
between means.
Note: You can ignore the minus sign when comparing the two t-values, as ± indicates the
direction; the p-value remains the same for both directions.
https://www.statisticshowto.datasciencecentral.com/probability-and-statistics/t-test/
Z-Test: When Population Variance is Known
Let's start by acknowledging that it is completely unrealistic to think that we'd find ourselves
in the situation of knowing the population variance, but not the population mean. Therefore,
the hypothesis testing method that we learn on this page has limited practical use. We study it
only because we'll use it later to learn about the "power" of a hypothesis test (by learning how
to calculate Type II error rates). As usual, let's start with an example.
Example
Boys of a certain age are known to have a mean weight of μ = 85 pounds. A complaint is
made that the boys living in a municipal children's home are underfed. As one bit of
evidence, n = 25 boys (of the same age) are weighed and found to have a mean weight
of x¯ = 80.94 pounds. It is known that the population standard deviation σ is 11.6 pounds (the
unrealistic part of this example!). Based on the available data, what should be concluded
concerning the complaint?
Solution. The null hypothesis is H0: μ = 85, and the alternative hypothesis is HA: μ < 85. In
general, we know that if the weights are normally distributed, then:
Z=X¯−μσ/n−−√
follows the standard normal N(0,1) distribution. It is actually a bit irrelevant here whether or
not the weights are normally distributed, because the same size n = 25 is large enough for the
Central Limit Theorem to apply. In that case, we know that Z, as defined above, follows at
least approximately the standard normal distribution. At any rate, it seems reasonable to use
the test statistic:
Z=X¯−μ0σ/n−−√
for testing the null hypothesis
H0:μ=μ0
against any of the possible alternative hypotheses HA:μ≠μ0, HA:μ<μ0, and HA:μ>μ0.
For the example in hand, the value of the test statistic is
Z=80.94−8511.6/25−−√=−1.75
The critical region approach tells us to reject the null hypothesis at the α = 0.05 level if Z <
−1.645. Therefore, we reject the null hypothesis because Z = −1.75 < −1.645, and therefore
falls in the rejection region:
As always, we draw the same conclusion by using the P-value approach. Recall that the P-
value approach tells us to reject the null hypothesis at the α = 0.05 level if the P-value ≤ α =
0.05. In this case, the P-value is P(Z < −1.75) = 0.0401
As expected, we reject the null hypothesis because the P-value = 0.0401 < α = 0.05.
https://newonlinecourses.science.psu.edu/stat414/node/269/https://science.psu.edu/
The Spearman correlation coefficient, rs, can take values from +1 to -1. A rs of +1 indicates
a perfect association of ranks, a rs of zero indicates no association between ranks and a rs of -
1 indicates a perfect negative association of ranks. The closer rs is to zero, the weaker the
association between the ranks.
An example of calculating Spearman's correlation
To calculate a Spearman rank-order correlation on data without any ties we will use the
following data
Marks
English 56 75 45 71 62 64 58 80 76 61
Maths 66 70 40 60 65 56 59 77 67 63
English (mark) Maths (mark) Rank (English) Rank (maths) d d2
56 66 9 4 5 25
75 70 3 2 1 1
45 40 10 10 0 0
71 60 4 7 3 9
62 65 6 5 1 1
64 56 5 9 4 16
58 59 8 8 0 0
80 77 1 1 0 0
76 67 2 3 1 1
61 63 7 6 1 1
We then complete the following table:
Where d = difference between ranks and d2 = difference squared.
We then calculate the following
We then substitute this into the main equation with the other information as follows
as n = 10. Hence, we have a ρ (or rs) of 0.67. This indicates a strong positive relationship
between the ranks individuals obtained in the maths and English exam. That is, the higher
you ranked in maths, the higher you ranked in English also, and vice versa.
https://statistics.laerd.com/statistical-guides/spearmans-rank-order-correlation-statistical-
guide-2.php
An ANOVA test is a way to find out if survey or experiment results are significant. In other
words, they help you to figure out if you need to reject the null hypothesis or accept the
alternate hypothesis. Basically, you’re testing groups to see if there’s a difference between
them. Examples of when you might want to test different groups:
A group of psychiatric patients are trying three different therapies: counseling, medication
and biofeedback. You want to see if one therapy is better than the others.
A manufacturer has two different processes to make light bulbs. They want to know if one
process is better than the other.
Students from different colleges take the same exam. You want to see if one college
outperforms the other
There are two main types: one-way and two-way. Two-way tests can be with or without
replication.
One-way ANOVA between groups: used when you want to test two groups to see if there’s a
difference between them.
Two way ANOVA without replication: used when you have one group and you’re double-
testing that same group. For example, you’re testing one set of individuals before and after
they take a medication to see if it works or not.
Two way ANOVA with replication: Two groups, and the members of those groups are doing
more than one thing. For example, two groups of patients from different hospitals trying two
different therapies.
How to run an ANOVA
These tests are very time-consuming by hand. In nearly every case you’ll want to use
software. For example, several options are available in Excel:
Two way ANOVA in Excel with replication and without replication.
One way ANOVA in Excel 2013.
Running the test in Excel.
ANOVA tests in statistics packages are run on parametric data. If you have rank or ordered
data, you’ll want to run a non-parametric ANOVA (usually found under a different heading
in the software, like “nonparametric tests“).
Steps
It is unlikely you’ll want to do this test by hand, but if you must, these are the steps you’ll
want to take:
Find the mean for each of the groups.
Find the overall mean (the mean of the groups combined).
Find the Within Group Variation; the total deviation of each member’s score from the Group
Mean.
Find the Between Group Variation: the deviation of each Group Mean from the Overall
Mean.
Find the F statistic: the ratio of Between Group Variation to Within Group Variation.
https://www.statisticshowto.datasciencecentral.com/probability-and-statistics/hypothesis-
testing/anova/
What is a Chi Square Test?
There are two types of chi-square tests. Both use the chi-square statistic and distribution for
different purposes:
A chi-square goodness of fit test determines if a sample data matches a population. For more
details on this type, see: Goodness of Fit Test.
A chi-square test for independence compares two variables in a contingency table to see if
they are related. In a more general sense, it tests to see whether distributions of categorical
variables differ from each another.
A very small chi square test statistic means that your observed data fits your expected data
extremely well. In other words, there is a relationship.
A very large chi square test statistic means that the data does not fit very well. In other words,
there isn’t a relationship.
The Chi-Square Test gives a "p" value to help you decide!
Example: "Which holiday do you prefer?"
Beach Cruise
Men 209 280
Women 225 248
Does Gender affect Preferred Holiday?
If Gender (Man or Woman) does affect Preferred Holiday we say they are dependent.
By doing some special calculations (explained later), we come up with a "p" value:
p value is 0.132
Now, p < 0.05 is the usual test for dependence. In this case p is greater than 0.05, so we
believe the variables are independent (ie not linked together).
In other words Men and Women probably do not have a different preference for Beach
Holidays or Cruises.
https://www.mathsisfun.com/data/chi-square-test.html