Documente Academic
Documente Profesional
Documente Cultură
Session 1:
Mizanur Khondoker
Department of Biostatistics
Institute of Psychiatry, King’s College London
29 September 2011 1
Outline
Session 1
1. Introduction to statistics
2
Learning outcome
3
Introduction to statistics
What is statistics?
• Statistics is also
• used for making informed decisions, and
• misused intentionally or accidentally.
4
Descriptive and Inferential Statistics
5
Descriptive and Inferential Statistics (cont’d.)
" Confidence interval: the 95% confidence interval for the mean reduction
(%) in right hippocampal volume was (3.8,13.3).
6
Descriptive statistics
" Mathematically mean (m) for a set of n measurements (xi) is given by:
n
∑ xi
i =1
m=
n
" The median – is a value that falls in the middle position when the
measurements are ordered from smallest to largest
" For even number of measurements, there will be two middle values, and
the median is estimated as the average of the two values. 8
Measures of centre (cont’d.)
• For example, consider a set of alcohol misuse scores measured on
a random sample of n = 5 violent offenders: 2, 9, 11, 5, and 6
• To find the sample mean we calculate:
2 + 9 + 11 + 5 + 6 33
Mean = ------------------------ = -------- = 6.6
5 5
Score
2 5 6 9 11
Median
9
Measures of spread/variability
• Distributions of datasets having the same centre (mean) may look different
because of the way the numbers are spread out from the centre
13
Descriptive statistics and estimation
• Descriptive statistics are actually used to estimate or
represent the unknown value of a population parameter
• For example:
" the sample mean (m) of a set of quantitative data can be used to
estimate the unknown population mean (µ)
" the sample proportion (p) of a certain category can be used to
estimate the unknown population proportion (π)
18
Test of Hypothesis
19
The null and alternative hypotheses
• A hypothesis is a statement concerning one or more population
parameter(s)
• It reflects the investigator’s belief about the unknown parameters
• There are two competing hypotheses in a test problem:
" the null hypothesis (H0), and
" the alternative hypothesis (H1)
• If there is enough evidence against innocence, the court will reject the
innocence hypothesis and declare the defendant guilty
• Otherwise the court will find the accused not guilty
21
The philosophy of a statistical test (cont’d.)
• The same philosophy applies to statistical test
• Suppose an investigator believes that mean hippocampal volume of
healthy subjects is different from that of AD patients
• The investigator formulates the null and alternative hypotheses:
• H0: Mean hippocampal volume is the same in healthy controls and AD
patients (µ1- µ2 = 0)
• H1: There is a difference between the mean volumes (µ1- µ2 ≠ 0)
• For the test problem in the last slide, the test statistic will be the
standardised observed difference (t-statistic):
24
One tailed and two-tailed tests (cont’d.)
• We choose right tailed
test when we are
confident that negative
difference can happen
only by chance
25
Two-sample t-test
• A two-sample t-test is generally used to formally compare the means
of two groups or populations
• Assumptions:
" Observations are independent of each other
" The two groups to be compared are independent of each other
" Population data from which the samples data are drawn are normally
distributed.
" The variances of the populations to be compared are equal (a modified
version of the test is available for unequal variances)
• Empirical studies of the t-test have demonstrated that these
assumptions can be violated to some extent without substantial
effect on the results
26
Example: t-test comparing two means
• Consider the hippocampal volume dataset for 14
Controls and 14 AD patients
• We want to test the hypothesis:
Control
Data are approximately
normally distributed
(symmetric)
27
Example: t-test comparing two means (cont’d.)
SPSS Output
29
Variable types and measurement scales
Variables
Qualitative Quantitative
(categorical) (quantity/amount)
30
Parametric and non-parametric tests
Normal Parametric
Distribution Tests
Yes
Continuous
Data
32
Choice of Statistical test –comparing two means
33
References
• Mendenhall, W., Beaver, R. J. and Beaver, B. M. (2008). Introduction to
Probability and Statistics, Cengage Learning.
• Agresti, A. and Finlay, b. (2009) Statistical Methods for the Social Sciences
(4th edition), Pearson Prentice Hall.
34
End of Session 1
35
Basic statistics for research
Session 2:
Daniel Stahl
Department of Biostatistics
Institute of Psychiatry, King’s College London
29 September 2011
36
First lecture: Descriptive and inferential statistics
• Descriptive statistics:
" summarizing meaningful aspects of your data, such as
measures of locations (mean, median) or spread/variability
(standard deviation, Interquartile range),
" assessing the distribution of the data: normally distributed?,
outliers?
• Inferential statistics:
" are used to draw inferences about a population from a sample in
order to generalize (make assumptions about this wider
population) and/or make predictions about the future.
o Null-Hypothesis testing
o Parameter estimation (point estimation, e.g. treatment effect and
precision, e.g. Standard error or confidence interval)
37
Outline
1. Scale of data and descriptive and inferential statistics
2. Comparing two independent groups
3. Comparing two paired (dependent) groups
4. [Comparing more than two groups]
5. Association between two variables
6. Outlook: Regression
38
Learning outcomes
39
1. Scale of data
We get data by measuring something = assign a number to a trait or
event
The way that the numbers are assigned determines the scale of
measurement.
The type of descriptive and inference statistics depends on the scale of
the data!
40
Scale of data
We get data by measuring something = assign a number to a trait or
event
The way that the numbers are assigned determines the scale of
measurement.
The type of descriptive and inference statistics depends on the scale of
the data!
41
• Gender: Nominal/binary, categorical
• Eye color: Nominal, categorical
• Grade: Ordinal/rank, categorical
• Weight and height: Continuous
• Number of dogs: Discrete/Count
42
Descriptive statistics: location and spread
Scale of
measurement
Age groups
Males 17 (81%) Median: 3 Mean age of males:
Females: 4 (19%) LQ.=1 & UQ.= 5, 35.5 years (SD=5.5)
Min=0, Max=5 43
Inference: Comparing two independent groups
Comparing two
independent groups
Objective:
• The aim of the study was to evaluate over 18 months whether depression
was associated with mortality in people with their first foot ulcer.
46
Which type of scale?
47
Type of scales
48
Are there differences in depressed and not-
depressed patients?
49
Are there differences in depressed and not-
depressed patients?
50
Outline
1. Scale of data and descriptive and inferential statistics
2. Comparing two independent groups
3. Comparing two paired (dependent) groups
4. Comparing more than two groups
5. Association between two variables
6. Outlook: Regression
51
Categorical data
• Are there differences in mortality between depressed and not
depressed patients?
Crosstab
In our sample 11.7% of the not depressed patients (20 out of 171 )
died within 18 months while 24.4% of the depressed patients died
(20 out of 82). 52
Main steps of statistical analysis
• Define the Null and alternative Hypotheses under study
" H0: There is no difference/no effect
" H1: There is a difference
• Choose a statistical test
• Collect the data
• Present descriptive statistics
• Calculate the test statistics specific to H0
• Compare the value of the test statistics from a known
probability distribution and obtain a p-value.
• Reject the Null-Hypothesis if the p-value is very small
(usually<0.05)
• Estimate the parameter of interest for the true population
and a measure of precision (95% Confidence interval)
53
Chi2 test and Odds ratio
Chi-Square Tests
95% Confidence
Interval
Value Lower Upper
Odds Ratio for dead in
2.435 1.226 4.840
first 18 months (no / yes)
For cohort any DSM-IV
depression = not 1.418 1.028 1.956
depressed
For cohort any DSM-IV
.582 .400 .846
depression = depressed
N of Valid Cases 253
Chi-Square Tests
Asymp. Sig.
Value df (2-sided)
Pearson Chi-Square .921a 2 .631
Likelihood Ratio .916 2 .633
Linear-by-Linear
.888 1 .346
Association
N of Valid Cases 253
a. 0 cells (.0%) have expected count less than 5. The
minimum expected count is 23.98.
Alcohol
consumption
Mann-Whitney U 6719.500
Wilcoxon W 21425.500
Z -.545
Asymp. Sig. (2-tailed) .586
a. Grouping Variable: any DSM-IV depression
Std. Error
any DSM-IV depression N Mean Std. Deviation Mean
HbA1c baseline depressed
79 8.427 2.1848 .2458
(999=missing,
777=missing not depressed
because died) 166 8.378 1.9972 .1550
• The mean HbA1c level of depressed individuals in our data set was 8.427
(SD=2.185) for depressed individuals and 8.378 (SD=2.00) for not
depressed individuals.
Independent Samples Test
• A t-test for independent samples for equal variances showed that there were
no significant differences between the two populations. The estimated mean
difference is 0.489 (95% C.I. =-0.53 to 0.62). 58
Assumptions of t-test
and many other parametric tests
59
Assessing normal distribution: Histograms
• Plot a histogram and compare it with a normal distribution
curve for this mean and standard deviation.
30
not depressed
20
30
depressed
20
10
0
5.0 7.5 10.0 12.5 15.0
HbA1c baseline
Negatively skewed
Symmetric
Positively skewed 61
Assessing homogeneity of variances
• The populations from which the samples are drawn should have equal
variances.
• This can be determined by visual inspection of the data, looking at the
spread or standard deviation (SD) of the data.
• A rule of thumb says that the SD of the group with the larger SD should
not be more than twice as large (Howell 1997).
Report
• The SDs of the two groups are very similar (2.2 versus 2.0). We can
assume homogeneity of variances.
• If the assumption is violated an unequal sample t-test can be used.
62
Remember: Standard deviation = Variance
Non-parametric tests
• If the assumptions of normal distribution are seriously violated
an alternative non-parametric test can be selected such as
Mann Whitney U test instead of independent t-test and
63
Using the Mann Whitney U Test instead of t-test
Are there differences in HbA1c between depressed and not-depressed group at
baseline?
Median Percentile 25 Percentile 75 Minimum Maximum
any DSM-IV not depressed HbA1c baseline 8.2 6.9 9.4 4.5 15.5
depression depressed HbA1c baseline 7.9 6.8 9.7 5.1 14.5
The median HBA1c level was 8.2 (25 Quartile=6.9, 75% Q=9.4)for depressed
individuals and 7.9 (25% Q=6.8, 75% Q.=9.7) for not depressed individuals.
Test Statisticsa
HbA1c
baseline
Mann-Whitney U 6465.500
Wilcoxon W 9625.500
Z -.177
Asymp. Sig. (2-tailed) .860
a. Grouping Variable: any DSM-IV depression
64
Questions
• Are there changes over time in HbA1c from baseline to
12 month follow-up?
• Independent test?
65
Changes over times: paired data
• Are there changes over time in HbA1c?
• Independent test?
" The same persons are observed at baseline and 12 months
follow-up. The data are not independent but paired (dependent).
• Which test would you use?
" A paired t-test would be appropriate
• Could you think about potential problems of the
analysis?
" Some people died during the 12 months. Perhaps they are the
ones who did not improve. This could cause a bias in our test
" Perhaps depressed and non-depressed patients change
differently.
" The assumptions of the test may be violated
66
Outline
1. Scale of data and descriptive and inferential statistics
2. Comparing two independent groups
3. Comparing two paired (dependent) groups
4. Comparing more than two groups
5. Association between two variables
6. Outlook: Regression
67
3. Comparing two paired (dependent) groups
e.g. the same person is observed at two occasions
Comparing
two paired groups
Paired samples
McNemar Test Wilcoxon Test t-test
Std. Error
Mean N Std. Deviation Mean
Pair HbA1c 12 month
8.192 191 1.8050 .1306
1 follow-up
HbA1c baseline 8.567 191 1.9920 .1441
• The HbA1c level in our sample (N=191) changed from 8.567 (SD=1.99) at
baseline to 8.192 (SD=1.81) at 12 months follow-up.
Paired Samples Test
Paired Differences
95% Confidence
Interval of the
Std. Error Difference
Mean Std. Deviation Mean Lower Upper t df Sig. (2-tailed)
Pair HbA1c 12 month
1 follow-up - -.3749 2.0352 .1473 -.6654 -.0844 -2.546 190 .012
HbA1c baseline
50
40
Frequency
30
20
10
Mean =-0.37
Std. Dev. =2.035
N =191
0
-10.00 -5.00 0.00 5.00 10.00
diff_HbA1c
Test Statisticsb
HbA1c 12
month
follow-up -
HbA1c
baseline
Z -2.444a
Asymp. Sig. (2-tailed) .015
a. Based on positive ranks.
b. Wilcoxon Signed Ranks Test
73
4. Comparing more than 2 groups
• Are there differences in alcohol consumption or HbA1c levels
between ethnic groups: Caucasian, African and Afro-
Caribbean?
Estimates
75
One-way ANOVA for continuous data
• The ANOVA uses an F test to determine whether there
exists a significant difference between group means.
• When the F test rejects the null hypothesis, we know
that at least two groups are different from each other.
• Usually we want to know which groups are different from
each other doing pairwise comparisons (using a t-
statistics).
• If we compare more than 3 groups we need to adjust for
multiple testing using Tukey or Bonferroni adjustments to
reduce the risk of obtaining a false positive result.
76
One-way ANOVA
• Example comparing HbA1c levels between three ethnic
groups
Tests of Between-Subjects Effects
77
Pairwise comparisons
Estimates
80
Comparing more that two paired samples
Repeated measurement ANOVA
Comparing more than
two paired groups
One-way repeated
Cochran’s Q Friedman Test measurement
Analysis of variance
82
Association between two variables
• A correlation describes the strength and direction of a relationship
between two random variables.
• The two variables are measured on each of the n individuals, e.g.
height and age of infants, age and HbA1c level
• A scatter plot allows us to visually assess a relationship between the
two variables:
• Is there a relationship between age of infant and height?
84.0
82.0
Height in cm
80.0
78.0
76.0
18 20 22 24 26 28 30
83
age in months
Association between two variables
• There is a linear relationship between two variables if a
straight line drawn through the midst of the data points
provide a good approximation to the observed
relationship.
84
Pearson correlation
• The strength and direction of a linear relationship between two
continuous random variables is measured by Pearson product
correlation coefficient:
• Denoted by r (sample) and ρ (rho) (Population)
• Ranges fromi -1 (perfect negative) to +1 (perfect positive correlation)
• Value of 0 indicates no correlation
• Value does not depend on measurement units
• r2 is the percentage of variance in variable 1 which is explained by
variable 2 (or vice versa)
85
86
Relationship between age and HbA1c
15.0
12.5
7.5
R Sq Linear = 0.022
5.0
Correlations
HbA1c
age baseline
age Pearson Correlation 1 -.148*
Sig. (2-tailed) .020
N 253 245
HbA1c baseline Pearson Correlation -.148* 1
Sig. (2-tailed) .020
N 245 245
*. Correlation is significant at the 0.05 level (2-tailed).
88
Spearman correlation
• is a non-parametric measure of statistical dependence
between two variables
• transforms the data into ranks
• Ranks can be assigned to outcomes from continuous and
ordinal scales
• is simply a Pearson’s correlation with ranked data
• often denoted by the Greek letter ρ (rho) or as rs, The
coefficient is more robust against outliers.
• The coefficient is sensitive to any monotonic relationship, not
just linear ones.
89
Relationship between age and HbA1c
Spearman’s correlation
Correlations
HbA1c
age baseline
Spearman's rho age Correlation Coefficient 1.000 -.170**
Sig. (2-tailed) . .008
N 253 245
HbA1c baseline Correlation Coefficient -.170** 1.000
Sig. (2-tailed) .008 .
N 245 245
**. Correlation is significant at the 0.01 level (2-tailed).
90
Rank data: Alcohol consumption versus HbA1c
15.0
12.5
HbA1c baseline
10.0
7.5
R Sq Linear = 6.72E-5
5.0
Correlations
Alcohol consumption
HbA1c Alcohol
baseline consumption
Spearman's rho HbA1c baseline Correlation Coefficient 1.000 .022
Sig. (2-tailed) . .730
N 245 245
Alcohol consumption Correlation Coefficient .022 1.000
Sig. (2-tailed) .730 .
N 245 253
Association between
two variables
Phi or Pearson’s
Pearson’s
contingency coefficient Spearman’s Rank
correlation
(more common: correlation
Odds ratio) 92
Outline
1. Scale of data and descriptive and inferential statistics
2. Comparing two independent groups
3. Comparing two paired (dependent) groups
4. Comparing more than two groups
5. Association between two variables
6. Outlook: Regression
93
6. Outlook: Correlation and regression
94
6. Outlook: Correlation and regression
• Correlation quantifies the strength of a relationship between two
variables but does not describe the relationship.
• It does not inform about the change in one variable change for each
unit increase in the other!
• Correlation does not assume a causal relationship between the two
variables.
• If we assume that one variable y is dependent on another variable x
(causal relationship) we can use linear regression to describe the
effect of x on y.
• Regression can be extended to include several independent
variables, for example:
" HbA1c at baseline on age and alcohol consumption
• or even a mix of categorical and continuous variables:
" HbA1c at baseline on age, alcohol consumption, sex and
depression.
95
Literature
• Book chapter: Stahl, D. & Leese, M. (2010) Research Methods and Statistics. In: Psychiatry
- An Evidence-Based Text for the MRCPsych Students. Hodder Arnold
Final proof copy in: R:\Applications\Courses\MSc book chapter
• Agresti, A. and Finlay, b. (2009)Statistical Methods for the Social Sciences (4th edition),
Pearson Prentice Hall.
• Other books:
" Mendenhall, W., Beaver, R. J. & Beaver, B. M. (2008). Introduction to Probability and Statistics,
Cengage Learning.
" Peat, J & Barton, B. (2005) Medical Statistics: A Guide to Data Analysis and Critical Appraisal.
Mass.: Blackwell Publishing Ltd.
" Campbell, M.J., Machin, d. & Walters, S.J. (2007) Medical Statistics: A Textbook for the Health
Sciences (Medical Statistics), 4th ed. Chichester: Wiley-Blackwell.
" Petrie, A. & Sabin, C. (2009) Medical statistics at a glance 3rd ed. Oxford: Blackwell.
• Software:
" Kinnear, P.R. & Gray, C.D. (2010) SPSS 18 made simple. London: Psychology Press.
" Andy Field’s web page at http://www.statisticshell.com/ provides a good resource for ANOVA (one
way, repeated, mixed, two way, posthoc comparisons) and regression and shows screenshots of
how to do the analyses in SPSS.
" Koehler, U. & Kreuter, F. (2010) Data analysis using STATA. College Station: STATA Press 96
End of Session 2
Thank you!
97