Professional Documents
Culture Documents
Statistics For Support Slides
Statistics For Support Slides
Statistics For Support Slides
Introductory Statistics
and Hypothesis Testing
Stcp-marshallowen-5a
www.statstutor.ac.uk
Intended Learning Outcomes
At the end of today you should:
1. Have improved your ability to recall and
describe some basic applied statistical methods
2. Have developed ideas for explaining some of
these methods to students in a maths support
setting
3. Feel more confident about providing statistics
support with the topics covered
www.statstutor.ac.uk
Content
1) Summary Statistics
2) Concepts of hypothesis testing
3) T-tests
4) Confidence intervals
5) Correlation and Regression
6) Choosing the right test
7) What is a non-parametric test?
8) Statistics scenarios
9) Top tips
10) ANOVA (if time)
www.statstutor.ac.uk
What we won’t cover
Lots of maths!!!
www.statstutor.ac.uk
Data and variables
DATA: the answers to
questions or measurements One variable per
column
from the experiment
VARIABLE = measurement
which varies between
subjects e.g. height or
gender
www.statstutor.ac.uk
Data types
Data Variables
Categorical:
Scale appear as categories
Measurements/ Numerical/ Tick boxes on questionnaires
count data
www.statstutor.ac.uk
Data types
Variables
Scale Categorical
Continuous Nominal:
Discrete: Ordinal:
Measurements no meaningful
Counts/ integers obvious order
takes any value order
www.statstutor.ac.uk
Questionnaire for GCSE Maths Pupils
What data types relate to following questions?
Q1: What is your favourite subject?
Maths English Science Art French
www.statstutor.ac.uk
Questionnaire for GCSE Maths Pupils
What data types relate to following questions?
Q1: What is your favourite subject? Nominal
www.statstutor.ac.uk
Populations and samples
Taking a sample from a population
www.statstutor.ac.uk
Point estimation
Sample data is used to estimate parameters of a
population
Statistics are calculated using sample data.
Parameters are the characteristics of population data
www.statstutor.ac.uk
How can exam score data be summarised?
www.statstutor.ac.uk
Summary statistics n
Mean =
x i 1
x
n
Standard deviation (s) is a measure of how much the
individuals differ from the mean n
x 2
i x
s i 1
n 1
www.statstutor.ac.uk
Interpretation of standard deviation
The larger the standard deviation, the more
spread out the data is.
www.statstutor.ac.uk
ormal
Normal distribution
n a
Scale data
te s
of w
e l lo
w fo
it t
se ei
a m
ly
an su
To as
www.statstutor.ac.uk
data scale If have
Discussion
How could you explain to a student what we
mean by data being assumed to follow a
Normal Distribution?
www.statstutor.ac.uk
Group Frequency Table
Frequency Percent
0 but less than 10 4 6.7
10 but less than 20 9 15.0
20 but less than 30 17 28.3
30 but less than 40 15 25.0
40 but less than 50 9 15.0
50 but less than 60 5 8.3
60 or over 1 1.7
Total 60 100.0
www.statstutor.ac.uk
Histogram and Probability Distribution for
Exam Marks Data
www.statstutor.ac.uk
Histogram and Probability Distribution for
Exam Marks Data
www.statstutor.ac.uk
IQ is normally distributed
Above
average
Average
Mensa
95% of values
100 130
70
mean 1 . 96 SD mean 1 . 96 SD
100 1 . 96 15 . 3 70 100 1 . 96 15 . 3 130
95% of people have an IQ between 70 and 130
www.statstutor.ac.uk
Assessing Normality
Charts can be used to informally assess whether data is:
Normally
Or….Skewed
distributed
A. True
B. False
C. Don’t know
www.statstutor.ac.uk
Sometimes the median makes more sense!
2/3rd people
50% people
www.statstutor.ac.uk
Choosing summary statistics
Which average and measure of
spread?
Scale Categorical
www.statstutor.ac.uk
Which graph? Exercise
1st variable Only 1 variable Scale Categorical
Scale Histogram Scatter plot Box-plot/
Confidence
interval plot
Categorical Pie/ Bar Box-plot/ Stacked/
Confidence multiple bar
interval plot chart
Which graph would you use when investigating:
1) Whether daily temperature and ice cream sales were related?
www.statstutor.ac.uk
Exercise: Ticket cost comparison
Summary statistics for cost of Titanic ticket by survival
www.statstutor.ac.uk www.statstutor.ac.uk
Which graph? Solution
1st variable Only 1 variable Scale Categorical
Scale Histogram Scatter plot Box-plot/
Confidence
interval plot
Categorical Pie/ Bar Box-plot/ Stacked/
Confidence multiple bar
interval plot chart
www.statstutor.ac.uk
Exercise: Ticket cost comparison Solution
a) Is there a big difference in average ticket price by group?
The mean and median are much bigger in those who survived.
b) Which group has data which is more spread out?
The standard deviation and interquartile range are much bigger for
those who survived so that data is more spread out
c) Is the data skewed?
Yes. The medians are much smaller than the means and the plots
show the data is positively skewed.
d) Is the mean or median a better summary measure?
The median as the data is skewed
www.statstutor.ac.uk www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
Hypothesis Testing
www.statstutor.ac.uk
Hypothesis testing Framework
What the text books might say!
Always two hypotheses:
HA: Research (Alternative) Hypothesis
What we aim to gather evidence of
Typically that there is a
difference/effect/relationship etc.
H0: Null Hypothesis
What we assume is true to begin with
Typically that there is no
difference/effect/relationship etc.
www.statstutor.ac.uk
Discussion
How could you help a
student understand what
hypothesis testing is and
why they need to use it?
www.statstutor.ac.uk
Could try explaining things in the
context of “The Court Case”?
Members of a jury have to decide whether a
person is guilty or innocent based on evidence
X
Difference DOES
exist in population Type II
Error
www.statstutor.ac.uk
Prob of this = Power of test
Steps to undertaking a Hypothesis test
Define study question
Choose a
Set null and alternative hypothesis suitable
test
Calculate a test statistic
Calculate a p-value
www.statstutor.ac.uk
Example: Titanic
www.statstutor.ac.uk
Chi squared Test?
Null: There is NO association
between
class and survival
Alternative: There IS an association between
www.statstutor.ac.uk
What would be expected if the null is
true?
Same proportion of people would have died in
each class!
Overall, 809 people died out of 1309 = 61.8%
www.statstutor.ac.uk
What would be expected if the null is
true?
Same proportion of people would have died in
each class!
Overall, 809 people died out of 1309 = 61.8%
www.statstutor.ac.uk
Chi-Squared Test Actually Compares
Observed and Expected Frequencies
www.statstutor.ac.uk
Chi-squared test statistic
The chi-squared test is used when we want
to see if two categorical variables are
related
The test statistic for the Chi-squared test
2
n
Oi Ei
2
i 1 Ei
www.statstutor.ac.uk
Using SPSS
Analyse Descriptive Statistics Crosstabs
Click on ‘Statistics’ button & select Chi-squared
Test Statistic = 127.859
p- value
p < 0.001
www.statstutor.ac.uk
Chi squared distribution
The p-value is calculated using the Chi-squared
distribution for this test
Chi-squared is a skewed distribution which varies
depending on the degrees of freedom
www.statstutor.ac.uk
What’s a p-value?
The technical answer!
Probability of getting a test statistic at least as
extreme as the one calculated if the null is true
P-value
Since p < 0.05 we reject the null p < 0.001
www.statstutor.ac.uk
Titanic exercise
Were ‘wealthy’ people more likely to survive on
board the Titanic?
Option 1:
Choose the right percentages from the next
slide to investigate
Fill in the stacked bar chart with the chosen %’s
Write a summary to go with the chart
www.statstutor.ac.uk
Contingency tables exercise
Which percentages are better for investigating
whether class had an effect on survival?
Column Row
65.3% of those who died were in 3rd class 74.5% of those in 3rd class died
www.statstutor.ac.uk
Did class affect survival? Question
Fill in the %’s on the stacked bar chart and interpret
www.statstutor.ac.uk
Did class affect survival? Solution
%’s within each class are preferable due to
different class frequencies
www.statstutor.ac.uk
Did class affect survival? Solution
Data collected on 1309
passengers aboard the Titanic
was used to investigate whether
class had an effect on chances of
survival. There was evidence
(c22=127.86, p < 0.001) to
suggest that there is an
association between class and
survival.
www.statstutor.ac.uk
Low EXPECTED Cell Counts with the Chi-
squared test
Died Survived Total
SPSS
Output
www.statstutor.ac.uk
Low Cell Counts with the Chi-squared test
www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
Comparing means
Use a box-plot or
confidence
interval plot
www.statstutor.ac.uk
T-tests
Paired or Independent (Unpaired) Data?
www.statstutor.ac.uk
Comparison of hours worked in 1988
to today
Paired or unpaired?
If the same people have reported their hours for 1988
and 2014 have PAIRED measurements of the same
variable (hours)
Paired Null hypothesis: The mean of the paired
differences = 0
Independent Groups
www.statstutor.ac.uk
What is the t-distribution?
The t-distribution is similar to the standard normal
distribution but has an additional parameter called
degrees of freedom (df or v)
www.statstutor.ac.uk
Relationship to normal
As the sample size gets big, the t-distribution
matches the normal distribution
Normal curve
www.statstutor.ac.uk
CAST e-books in statistics:
t-distribution
http://cast.massey.ac.nz/collection_public.html
www.statstutor.ac.uk
Exercise
For Examples 1 and 2 (on the following four
slides) discuss the answers to the following:
www.statstutor.ac.uk
Example 1: Triglycerides
In a weight loss study, Triglyceride levels
were measured at baseline and again after
8 weeks of taking a new weight loss
treatment.
www.statstutor.ac.uk
Example 1: t-Test Results
95% Confidence
Interval of the
Difference
Std. Std. Error
Mean Sig. (2-
Deviation Mean t df
tailed)
Lower Upper
Triglyceride level at
week 8 (mg/dl) -
-11.371 80.360 13.583 -38.976 16.233 -.837 34 .408
Triglyceride level at
baseline (mg/dl)
Null Hypothesis is:
P-value =
Decision (circle correct answer): Reject Null/ Do not
reject Null
Conclusion:
www.statstutor.ac.uk
Example 1: Solution
95% Confidence
Interval of the
Std. Difference
Std. Error
Mean Deviatio Sig. (2-
Mean t df
n tailed)
Lower Upper
Triglyceride level
at week 8 (mg/dl)
-11.371 80.360 13.583 -38.976 16.233 -.837 34 .408
- Triglyceride level
at baseline (mg/dl)
www.statstutor.ac.uk
Ignore the shaded
part of the output
for now!
Example 2: t-Test Results
Levene's Test
95% CI of the
for Equality of T-test results
Difference
Variances
Sig. Mean Std. Error
F Sig. t df Lower Upper
(2-tailed) Difference Difference
Equal variances
2.328 .136 4.539 35 .000 3.648 .804 2.016 5.280
assumed
Equal variances
4.510 32.342 .000 3.648 .809 2.001 5.295
not assumed
P-value =
Decision (circle correct answer): Reject Null/ Do not
reject Null
Conclusion:
www.statstutor.ac.uk
Ignore the shaded
part of the output
for now!
Example 2: Solution
Levene's Test
95% CI of the
for Equality of T-test results
Difference
Variances
Sig. Mean Std. Error
F Sig. t df Lower Upper
(2-tailed) Difference Difference
Equal variances
2.328 .136 4.539 35 .000 3.648 .804 2.016 5.280
assumed
Equal variances
4.510 32.342 .000 3.648 .809 2.001 5.295
not assumed
IS evidence of a
P(t< -4.539) P(t>4.539)
difference in weight loss Is < 0.001 Is < 0.001
between treatment and
placebo
-4.539 4.539
www.statstutor.ac.uk
Assumptions
Every test has assumptions
Tutors quick guide shows assumptions for
www.statstutor.ac.uk
Assumptions in t-Tests
Normality: Plot histograms
◦ One plot of the paired differences for any paired data
◦ Two (One for each group) for independent samples
◦ Don’t have to be perfect, just roughly symmetric
www.statstutor.ac.uk
Histograms from Examples 1 and 2
www.statstutor.ac.uk
What if the assumptions are not met?
There are alternative tests which do not have
these assumptions
www.statstutor.ac.uk
Sampling Variation
Every sample
taken from a
population, will
Sample A contain different
n=20
Mean = 277 numbers so the
𝑥 mean varies.
Population Sample B
Mean = ? n=50 Which estimate
SD =? Mean = 274 is most reliable?
𝑥
Sample C How certain or
n=300 uncertain are
Mean = 275 we?
𝑥
www.statstutor.ac.uk
Confidence Intervals
A range of values within which we are confident (in
terms of probability) that the true value of a pop
parameter lies
A 95% CI is interpreted as 95% of the time the CI
would contain the true value of the pop parameter
i.e. 5% of the time the CI would fail to contain the true
value of the pop parameter
www.statstutor.ac.uk
CAST e-books in statistics:
Confidence Intervals
http://cast.massey.ac.nz/collection_public.html
www.statstutor.ac.uk
Confidence Interval simulation from CAST
Population
mean
www.statstutor.ac.uk
Exercise: Solution
Discuss what the interpretation is for the confidence
interval from Example 2 highlighted below:
Levene's Test
95% CI of the
for Equality of T-test results
Difference
Variances
Sig. Mean Std. Error
F Sig. t df Lower Upper
(2-tailed) Difference Difference
Equal variances
2.328 .136 4.539 35 .000 3.648 .804 2.016 5.280
assumed
www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
Investigating relationships
Variables:
Favourite subject (Nominal)
www.statstutor.ac.uk
Scatterplot
Relationship between two scale variables:
Presence of outliers
Statistic used:
r = correlation coefficient
Linear
www.statstutor.ac.uk
Correlation Coefficient r
Measures strength of a relationship between two
continuous variables -1 r 1
r = 0.9
r = 0.01
r = -0.9
www.statstutor.ac.uk
Correlation Interpretation
An interpretation of the size of the coefficient has
been described by Cohen (1992) as:
www.statstutor.ac.uk
Does chocolate make you clever or crazy?
A paper in the New England Journal of Medicine claimed a
relationship between chocolate and Nobel Prize winners
r = 0.791
http://www.nejm.org/doi/full/10.1056/NEJMon1211064
www.statstutor.ac.uk
Chocolate and serial killers
What else is related to chocolate consumption?
r = 0.52
http://www.replicatedtypo.com/chocolate-consumption-
traffic-accidents-and-serial-killers/5718.html
www.statstutor.ac.uk
Hypothesis tests for r
Tests the null hypothesis that the population
correlation r = 0 NOT that there is a strong
relationship!
www.statstutor.ac.uk
Exercise
Interpret the following correlation coefficients
using Cohen’s and explain what it means
Relationship Correlation
Average IQ and chocolate consumption 0.27
Road fatalities and Nobel winners 0.55
Gross Domestic Product and Nobel winners 0.7
Mean temperature and Nobel winners -0.6
www.statstutor.ac.uk
Exercise - solution
Relationship Correlation Interpretation
www.statstutor.ac.uk
Confounding
Is there something else affecting both chocolate
consumption and Nobel prize winners?
Number of
Chocolate
Nobel
consumption
winners
GDP (wealth)
Temperature
www.statstutor.ac.uk
Dataset for today
Factors affecting birth weight of babies
Mother
smokes = 1
www.statstutor.ac.uk
Exercise: Gestational age and birth weight
a) Describe the relationship between the gestational
age of a baby and their weight at birth.
r = 0.706
www.statstutor.ac.uk
Exercise - Solution
Describe the relationship between the gestational
age of a baby and their weight at birth.
There is a strong
positive relationship
which is linear
www.statstutor.ac.uk
Regression: Association between two
variables
Regression is useful when we want to
a) look for significant relationships between two
variables
b) predict a value of one variable for a given value
of the other
Residuals
Baby heavier Baby lighter
than predicted than
expected
Regression
line Baby the same
y ax as predicted
www.statstutor.ac.uk
Regression
Simple linear regression looks at the relationship
between two Scale variables by producing an
equation for a straight line of the form
Independent
y a x
Dependent variable variable
Intercept Slope
www.statstutor.ac.uk
Hypothesis testing
We are often interested in how likely we are to obtain
our estimated value of if there is actually no
relationship between x and y in the population
www.statstutor.ac.uk
Output from SPSS
Key regression table:
www.statstutor.ac.uk
Assumptions for regression
Assumption Plot to check
www.statstutor.ac.uk
Checking normality
Histogram of the
residuals looks
approximately normally
distributed
www.statstutor.ac.uk
What if assumptions are not met?
If the residuals are heavily skewed or the residuals show
different variances as predicted values increase, the data
needs to be transformed
Try taking the natural log (ln) of the dependent variable.
Then repeat the analysis and check the assumptions
www.statstutor.ac.uk
Exercise
Investigate whether mothers pre-pregnancy
weight and birth weight are associated using
a scatterplot, correlation and simple
regression.
www.statstutor.ac.uk
Exercise - scatterplot
Describe the relationship using the
scatterplot and correlation coefficient
r = 0.39
www.statstutor.ac.uk
Regression question
R2 = 0.152
Does the model result in reliable predictions?
www.statstutor.ac.uk
Check the assumptions
www.statstutor.ac.uk
Correlation
Pearson’s correlation = 0.39
www.statstutor.ac.uk
Regression
Pre-pregnancy weight p-value: p = 0.011
Regression equation: y = 3.16 + 0.03x
Interpretation:
There is a significant relationship between a mothers’ pre-
pregnancy weight and the weight of her baby (p = 0.011).
Pre-pregnancy weight has a positive affect on a baby’s weight
with an increase of 0.03 lbs for each extra pound a mother
weighs.
www.statstutor.ac.uk
Checking assumptions
Linear relationship
Histogram roughly peaks in the middle
No patterns in residuals
www.statstutor.ac.uk
Multiple regression
Multiple regression has several binary or
Scale independent variables
y a 1 x1 2 x2 3 x3
Categorical variables need to be recoded
as binary dummy variables
Effect of other variables is removed
(controlled for) when assessing
relationships
www.statstutor.ac.uk
Multiple regression
What affects the number of Nobel prize winners?
www.statstutor.ac.uk
Multiple regression
In addition to the standard linear regression
checks, relationships BETWEEN independent
variables should be assessed
Multicollinearity is a problem where continuous
independent variables are too correlated (r > 0.8)
Relationships can be assessed using scatterplots
and correlation for scale variables
SPSS can also report collinearity statistics on
request. The VIF should be close to 1 but under
5 is fine whereas 10 + needs checking
www.statstutor.ac.uk
Exercise
Which variables are most strongly related?
www.statstutor.ac.uk
Exercise - Solution
Which variables are most strongly related?
Gestation and birth weight (0.709)
www.statstutor.ac.uk
Logistic regression
Logistic regression has a binary dependent variable
The model can be used to estimate probabilities
www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
www.statstutor.ac.uk
Choosing the right test
1) A clearly defined research question
www.statstutor.ac.uk
Research question
Clear questions with measurable quantities
www.statstutor.ac.uk
Dependent variables
INDEPENDENT DEPENDENT
(explanatory/ (outcome)
affects
predictor) variable
variable
www.statstutor.ac.uk
What variable type is the dependent?
Dependent
Scale Categorical
Ordinal Nominal
www.statstutor.ac.uk
Are boys better at maths?
www.statstutor.ac.uk
How many variables are involved?
Two – interested in the relationship
www.statstutor.ac.uk
Data types
www.statstutor.ac.uk
Exercise:
How would you investigate the following topics?
State the dependent and independent variables and
their variable types.
Research question Dependent/ Independent/
outcome variable explanatory variable
Were Americans more likely to
survive on board the Titanic?
www.statstutor.ac.uk
Exercise: Solution
How would you investigate the following topics?
:State the dependent and independent variables and
their variable types.
Research question Dependent/ Independent/
outcome variable explanatory variable
Were Americans more likely to Survival (Binary) Nationality (Nominal)
survive on board the Titanic?
www.statstutor.ac.uk
Comparing means
Dependent = Scale
Independent = Categorical
www.statstutor.ac.uk
Comparing measurements on the same people
www.statstutor.ac.uk
Comparing means
Independent
t-test
2
Comparing BETWEEN
groups
3+
Comparing
means
Comparing
2 Paired t-test
measurements
WITHIN the same
subject
3+
www.statstutor.ac.uk
Comparing means
Independent
t-test
2
Comparing BETWEEN
groups One way
3+ ANOVA
Comparing
means
Comparing
2 Paired t-test
measurements
WITHIN the same
subject
3+ Repeated
measures
ANOVA
ANOVA = Analysis of variance
www.statstutor.ac.uk
Exercise – Comparing means
Research question Dependent Independent Test
variable variable
Do women do more Housework (hrs Gender
housework than men? per week) (Nominal)
(Scale)
Does Margarine X Cholesterol Occasion
reduce cholesterol? (Scale) (Nominal)
Everyone has
cholesterol measured
on 3 occasions
www.statstutor.ac.uk
Exercise: Solution
Research question Dependent Independent Test
variable variable
Do women do more Housework (hrs Gender Independent t-
housework than men? per week) (Nominal) test
(Scale)
Does Margarine X Cholesterol Occasion Repeated
reduce cholesterol? (Scale) (Nominal) measures ANOVA
Everyone has
cholesterol measured
on 3 occasions
www.statstutor.ac.uk
Tests investigating relationships
Investigating Dependent Independent Test
relationships between variable variable
2 categorical variables Categorical Categorical Chi-squared test
2 Scale variables Scale Scale Pearson’s correlation
Predicting the value of Scale Scale/binary Simple Linear
an dependent variable Regression
from the value of a Binary Scale/ binary Logistic regression
independent variable
www.statstutor.ac.uk
Exercise: Relationships
Research question Dependent Independent Test
variable variables
Does attendance Exam scoreAttendance
affect exam score? (Scale) (Scale)
Do women do more Housework Gender (Binary)
housework than men? (hrs per week) Hours worked
(scale) (Scale)
Were Americans more Survival Nationality
likely to survive on (Binary) (Nominal)
board the Titanic?
Survival Nationality ,
(Binary) Gender, class
www.statstutor.ac.uk
Exercise: Solution
Research question Dependent Independent Test
variable variables
Does attendance Exam scoreAttendance Correlation/
affect exam score? (Scale) (Scale) regression
Do women do more Housework Gender (Binary) Regression
housework than men? (hrs per week) Hours worked
(scale) (Scale)
Were Americans more Survival Nationality Chi-squared
likely to survive on (Binary) (Nominal)
board the Titanic?
Survival Nationality , Logistic
(Binary) Gender, class regression
www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
Non-parametric tests
Nonparametric
techniques are usually
Non-parametric based on ranks/ signs
rather than actual data
www.statstutor.ac.uk
Original Rank of
Nonparametric techniques
are usually based on ranks
or signs
Scale data is ordered and
ranked
Analysis is carried out on
the ranks rather than the
actual data
www.statstutor.ac.uk
Non-parametric tests
Non-parametric methods are used when:
– Data is ordinal
– Data does not seem to follow any particular shape or
distribution (e.g. Normal)
– Assumptions underlying parametric test not met
– A plot of the data appears to be very skewed
– There are potential influential outliers in the dataset
– Sample size is small
Note: Parametric tests are fairly
robust to non-normality. Data has
to be very skewed to be a problem
www.statstutor.ac.uk
Do these look normally distributed?
www.statstutor.ac.uk
Do these look normally distributed?
yes
no yes
www.statstutor.ac.uk
What can be done about non-normality?
If the data are not normally distributed, there are
two options:
10000
Frequency
For positively skewed data,
0
0 20 40 60 80
2000
0
0 1 2 3 4
vbarg$logA1
www.statstutor.ac.uk
Non-parametric tests
Parametric test What to check for Non-parametric test
normality
Independent t-test Dependent variable by Mann-Whitney test
group
Paired t-test Paired differences Wilcoxon signed rank test
One-way ANOVA Residuals/Dependent Kruskal-Wallis test
Repeated measures Residuals Friedman test
ANOVA
Pearson’s Correlation At least one of the Spearman’s Correlation
Co-efficient variables should be Co-efficient
normal
Notes: The residuals are the differences between the
observed and expected
Linear Regression Residualsvalues. None – transform the data
www.statstutor.ac.uk
Exercise: Comparison of housework
Which test should
be carried out to
compare the hours
of housework for
males and females?
Look at the
histograms of
housework by
gender to decide.
www.statstutor.ac.uk
Exercise: Solution
Which test should
be carried out to
compare the hours
of housework for
males and females?
www.statstutor.ac.uk
Summary
Dependent
Scale Categorical
Normally Skewed
Ordinal: Nominal:
distributed data
Non- Chi-
Parametric Non-
parametric squared
test parametric
www.statstutor.ac.uk
Scenarios
Resources available on http://www.statstutor.ac.uk/
Independent variables:
www.statstutor.ac.uk
Resume
Do you feel that you
1. Have improved your ability to recall and describe
some basic applied statistical methods?
www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
Additional material
or not
Placebo: 0.90 0.37 1.63 0.83 0.95 0.78 0.86 0.61 0.38 1.97
Alcohol: 1.46 1.45 1.76 1.44 1.11 3.07 0.98 1.27 2.56 1.32
www.statstutor.ac.uk
Mann-Whitney test
Nonparametric equivalent
to independent t-test
www.statstutor.ac.uk
Drink driving reactions
H0: There is no difference between the alcohol and
placebo populations on reaction time
www.statstutor.ac.uk
Mann-Whitney results
Interpret the results
-2.646 2.646
www.statstutor.ac.uk
Mann-Whitney results - solution
Interpret the results
p =0.008
Highly significant
evidence to suggest a
difference in the
distributions of reaction
P(Z<-2.646 )= P(Z> 2.646 )
times for those in the
0.004 = 0.004
placebo and alcohol
groups
-2.646 2.646
www.statstutor.ac.uk
community project
encouraging academics to share statistics support resources
All stcp resources are released under a Creative Commons licence
ANOVA
www.statstutor.ac.uk
How Does ANOVA Work?
ANOVA = Analysis of variance
www.statstutor.ac.uk
Within group variation
Residual =difference between an individual and
their group mean Person lost
9.2kg kg so
SSwithin=sum of squared residuals residual =9.2 –
5.15 = 4.05
Mean weight
lost on diet 3
= 5.15kg
www.statstutor.ac.uk
Between group variation
Differences between each group mean and the
overall mean
Diet 3 difference
=5.15 – 3.85 =
1.3
Overall
mean =
3.85
www.statstutor.ac.uk
Sum of squares calculations
K = number of groups
n
k
2
SSwithin xij x j
j 1 i 1
24 27 27
xi 3.3 xi 3.03 xi 5.15 430.179
2 2 2
i 1 i 1 i 1
k
SSBetween n j x j xT
j 1
www.statstutor.ac.uk
ANOVA test statistic
Test Statistic
(usually
reported in
N = total observations in all groups, papers)
K = number of groups
www.statstutor.ac.uk
Test Statistic (by hand)
Filling in the boxes
www.statstutor.ac.uk
P-value
The p-value for ANOVA is calculated using the F-
distribution
If you repeated the experiment numerous times,
you would get a variety of test statistics
p-value = probability of
getting a test statistic at least
as extreme as ours if the null is
true
Test
Statistic
www.statstutor.ac.uk
One way ANOVA
between group variation MSDiet
Test Statistic 6.197
within group variation MSError
Tests of Between-Subjects Effects
Dependent Variable: Weight lost on diet (kg)
www.statstutor.ac.uk
Post hoc tests
Which diets are significantly different?
www.statstutor.ac.uk
Pairwise comparisons
Results Test p-value
Diet 1 vs Diet 2
Diet 1 vs Diet 3
Diet 2 vs Diet 3
Report:
www.statstutor.ac.uk
Pairwise comparisons
Results Test p-value
Diet 1 vs Diet 2 P = 0.912
Diet 1 vs Diet 3 P = 0.02
Diet 2 vs Diet 3 P = 0.005
www.statstutor.ac.uk
Assumptions for ANOVA
Assumption How to check What to do if assumption
not met
Normality: The residuals Histograms/ Do a Kruskall-Wallis test
(difference between observed QQ plots/ which is non-parametric
and expected values) should be normality tests (does not assume normality)
normally distributed of residuals
Homogeneity of variance (each Levene’s test Welch test instead of ANOVA
group should have a similar and Games-Howell for post
standard deviation) hoc or Kruskall-Wallis
www.statstutor.ac.uk
Ex: Can equal variances be assumed?
Null:
p=
Conclusion:
www.statstutor.ac.uk
Exercise: Can normality be assumed?
Histogram of standardised residuals
Can normality be
assumed?
Should you:
a) Use ANOVA
www.statstutor.ac.uk
Ex: Can equal variances be assumed?
Null:
p = 0.52
Do not reject
www.statstutor.ac.uk
Ex: Can normality be assumed?
Histogram of standardised residuals
Can normality be
assumed?
Yes
Use ANOVA
Conclusion:
www.statstutor.ac.uk
Between
ANOVA Between groups
groups factor
factor
Two-way ANOVA has 2
categorical independent
between groups variables
www.statstutor.ac.uk
Two-way ANOVA
Dependent = Weight Lost
Independents: Diet and Gender
Tests 3 hypotheses:
1. Mean weight loss does not differ by diet
2. Mean weight loss does not differ by gender
3. There is no interaction between diet and
gender
What’s an interaction?
www.statstutor.ac.uk
Means plot
Mean reaction times after consuming coffee,
water or beer were taken and the results by
drink or gender were compared.
www.statstutor.ac.uk
Means/ line/ interaction plot
No interaction between gender and drink
Mean reaction
time for men
after water
Mean reaction
time for
women after
coffee
www.statstutor.ac.uk
Means plot
Interaction between gender and drink
www.statstutor.ac.uk
ANOVA
Mixed between-within ANOVA includes some repeated
measures and some between group variables
e.g. give some people margarine B instead of A and look
at the change in cholesterol over time Between
groups
Repeated measures factor
www.statstutor.ac.uk