Download - SPSS2 Guide Basic Non-parametrics
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
1/24
1
SPSS FOR WINDOWS
VERSION 11.0
BASIC GUIDE II
For further information contact:
Julie Morris or Bernice Dillon
Department of Medical Statistics
Tel: x 5815, 5800
Email: [email protected]
mailto:[email protected]:[email protected]:[email protected]:[email protected] -
7/31/2019 SPSS2 Guide Basic Non-parametrics
2/24
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
3/24
Click OK
In this example, we get the following table
Chi-Square Tests
3.086b 1 .079
1.371 1 .242
3.256 1 .071
.242 .121
2.829 1 .093
12
Pearson Chi-Square
Continuity Correction a
Likelihood Ratio
Fisher's Exact Test
Linear-by-Linear Association
N of Valid Cases
Value df
Asymp. Sig.
(2-sided)
Exact Sig.
(2-sided)
Exact Sig.
(1-sided)
Computed only for a 2x2 tablea.
4 cells (100.0%) have expected count less than 5. The minimumexpected count is 2.50.b.
Under the table it says that 100% of our cells have an Expected Count less than 5,
therefore we dont have enough subjects in our sample to use a chi-square. Therefore
we shall use the Fishers Exact Test. Our p-value is two-sided, so in this case, p=0.24.We have no evidence that smokers are more likely to develop the disease (although, this
is a lot to do with the sample size and power of the study)
3
One of the deciding factorsof which test to use
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
4/24
Qualitative variables: More than two groups
When we look at categorical variables by group, we are again forming a table of counts
and can analyse it using chi-square.
We use the exact same commands as we did for the two group example. In this case, we
have three samples of workers each from a different work place and we are measuring
the prevalence rate of a history of cough.
COUGH Total Yes No
WORK Workplace 1 Count 16 19 35 % within WORK 45.7% 54.3% 100.0% Workplace 2 Count 31 21 52
% within WORK59.6% 40.4% 100.0%
Workplace 3 Count 10 7 17 % within WORK 58.8% 41.2% 100.0%
Total Count 57 47 104 % within WORK 54.8% 45.2% 100.0%
Chi-Square T ests
1.764a 2 .414
1.762 2 .414
1.222 1 .269
104
Pearson Chi-Square
Likelihood Ratio
Linear-by-Linear Association
N of Valid Cases
Value df
Asymp. Sig.
(2-sided)
0 cells (.0%) have expected count less than 5. The minimumexpected count
is 7.68.
a.
We observe that 46% of Workplace 1 have a history of cough, 60% of Workplace 2 and
59% of Workplace 3. We can also see that 0% of the expected counts are less than 5.
Therefore, we would use the Pearsons Chi-Square p-value, which is equal to p=0.41.
There is no evidence of any difference in proportions, between the three groups.
4
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
5/24
Chi Square tests using summary data
Sometimes we just want to use SPSS to carry out a chi-square test on the
crosstabulation data without inputting all the raw data.
Inputting crosstabulation data directly into SPSSTo do this input 3 columns of data. The first column contains information about the
coding of your first variable (eg. if the variable has just two categories then the
codes would be 1 and 2). The second column contains information about the coding
of your second variable (eg. if the variable has three categories then the codes
would be 1, 2 and 3). The length of the columns (ie. the number of rows in the
datasheet) corresponds to the number of cells in your crosstabulation ie. the number
of different combinations of categories for your two variables (eg in the above
example there are 6 cells, (6 = 2 x 3). The values in these first two columns cover
the different combinations. The third column contains the frequencies, ie the
number of subjects corresponding to each combination of variables.
For example, for the workplace vs. cough data above, the spreadsheet will look like
this:
cough workplace freq1 1 16
2 1 19
1 2 31
2 2 21
1 3 102 3 7
The Freq column is now used to weigh the cases.
Click on the Data menu
Click on Weightcases
Tick the weight casesby box
Highlight the freq variable and click on the arrow to place it in the frequency
variable box
Click on OK
Then use the Crosstabs command as before on the cough and workplace variables
5
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
6/24
Qualitative variables: Two matched groups
In this scenario we would not use a chi-square test because our data are no longer
independent. To analyse whether a proportion changes at two points in time or whether
two pairwise matched groups differ, we would use a McNemars Test.
In this example, we wish to see if the rate of cough has changed from one year to the
year after. Since we are using the same sample at year 1 and year 2, this would be a
McNemars Test1
There are two ways of carrying out McNemars Test:
1. The McNemars Test is under the Crosstabs command that we have been using
for the Chi-Square commands.
Enter One Variable in theRow Box and One Variable in the Column Box
Click onStatistics and put a tick in theMcNemarbox.
Click on Continue, Now Click on Cells and click the Total Percentages box
1 If there were two different groups at year 1 and year 2, then this would be a chi-square test.
6
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
7/24
Click on Continue
Click on OK
In this example, we get the following table
YEAR1 * YEAR2 Crosstabulation
32 25 57
30.8% 24.0% 54.8%
25 22 47
24.0% 21.2% 45.2%
57 47 104
54.8% 45.2% 100.0%
Count
% of Total
Count
% of Total
Count
% of Total
Yes
No
YEAR1
Total
Yes No
YEAR2
Total
Chi-Square Tests
1.000a
104
McNemar Test
N of Valid Cases
Value
Exact Sig.
(2-sided)
Binomial distribu tion u sed.a.
The percentage of subjects coughing at year one is the total percentage for this row. It
is, in this example, 54.8%. In fact, the percentage of coughs in year 2 is also 54.8%. It is
no surprise, that the p-value for this 1.000 (Exact Sig. (2-sided)). There is no evidencethat the prevalence rate of cough is changing between year 1 and year 2.
Alternatively, McNemars test is under the Non-parametric test 2 related
samples option.
Test type = McNemars
Test pair = 2 matched variables
7
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
8/24
Quantitative data - Two independent groups
We describe continuous variables with a mean or a median to give a table such as.
Secondary Prevention of Coronary Heart DiseaseMean (SD)
Respondents
(n=1343)
Non-Respondents
(n=578)
Age (Years) 66.2 (8.2) 66.6 (8.7)
Time since MI (mths)* 10 (6,35) 15 (8,47)
Cholesterol (mmol/l) 6.5 (1.2) 6.6 (1.2)
[*Median (Range)]
The next question is Is one mean (or median) significantly greater than the other?
Or, in other words, Is the difference we observe big enough to suggest it hasnthappened by chance. To answer this we need a confidence interval or a p-value as our
tool of evidence. The method we use is dependent on whether the data are normal
(when we are allowed to use means) or not. We have the following choices:
If the data areNORMALLYdistributed, we can get a confidence interval for the
difference in means and perform an Independent samples t-testto get our p-
value. We can achieve ALL of this using the COMPARE MEANS option in
SPSS
If the data areLOG NORMALLYdistributed, we can get a confidence interval
for the ratio of means and perform an Independent samples t-testto get our p-value. We can achieve ALL of this using the COMPARE MEANS option in
SPSS.
If the data areNEITHER NORMALLY NOR LOG NORMALLYdistributed,
we can get a confidence interval for the median difference and perform a
Mann-Whitney U testto get our p-value. We can achieve SOME of this using
the NON-PARAMETRIC TESTS option in SPSS. SPSS will not give you a
confidence interval for the median difference.
Testing for Normality or Log Normality
The tests for normality have been given SPSS Basic Notes 1 (and Basic Statistics 1). It
is important to note that when we do group comparisons that the data must be normally
distributed within each group. The easiest way to do this is to split the file by the
group variable before doing your test of normality.
Log normal data has a positive skewness. It is very common in biochemistry where
there are more people with a normal, low value than people with a high value, which
often indicates an illness. To test for log normality, we simply do a normality test on the
variable after it has been log transformed. An example is given in these notes.
Independent Samples t-test
8
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
9/24
Independent Samples t-test
Appropriate for comparing the means between two groups of different subjects, (who
have not been matched in the sampling2.)
The Compare Means option allows you to test for the difference in means for a
continuous variable between two or more groups.
1) If the data are normally distributed
To open the t-test box: Go to the Analyse menu, select Compare Means and then
select Independent samples T test.
Highlight the continuous variable to be tested and click on the relevant arrow to
place it in the Test Variablebox
Highlight the variable that indicates the groups and click on the relevant arrow
to place in the Grouping Variablebox
Now click the Define Groupsbox and type in the values of the grouping
variable. So for instance if you wanted to compare men and women, and in your
data set men were coded as 1 and women coded as 2 then you would enter 1 and
2 into this box. Although you could argue that SPSS should be able to work thisout, what this box does allow you to do is to select two subgroups of a variable.
So, for instance if you had a variable coded 1=Yes, 2=No, 8=Dont Know, then
you could compare just the yes and the no group by entering 1 and 2 into the
box.
2
If the sample design includes matching then we have special methods for analysing. The IndependentSamples t-test is not appropriate as through the Sample Design, you have forced the groups to be morealike than they would have been if they had been randomly sampled
9
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
10/24
Now press Continuethen OK
An example of the output you should get is as follows: It tests for the difference in
average heights between men and women, by using independent samples.
Levenes t-test for equality of means
F Sig. t df sig MeanDiff
s.errorDiff
Lower Upper
Equal variances 0.005 0.942 11.019 112 0.000 15.52 1.408 12.728 18.310Not equal variances 11.053 62.74 0.000 15.52 1.404 12.713 18.325
There are two rows to this table. An assumption of the t-test is that our two groups (in
this example, men and women) have the same variance. If they dont, it is often a sign
of a violation of normality, but if we are sure that our data are normal but have different
variances then we use the information given on the bottom row of the table, but more
commonly, we use the top row. In order to test for equal variances between the two
groups, we use the Levene Test of Equal Variances. The p-value is in the second
column. If this p-value is below 0.05, we have evidence of a difference in variances and
we must use the bottom row for our p-value and confidence interval.
In our case we have observed that men are on average 15.52cm taller than women with
a confidence interval of (12.73cm,18.31cm). The p-value is given as 0.000, which we
should report as p
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
11/24
In our example the variable that we wish to transform is called Hdl and the new
variable we have created is called loghdl4. Loghdl will now be the transformed version
of HDL and it is this that we run the t-test on.
So to run the t-test, we repeat what we did in the example with the normally distributed
variable
Highlight the continuous variable to be tested and click on the relevant arrow to
place it in the Test Variablebox. This time the variable we put in isLOGHDL
Highlight the variable that indicates the groups and click on the relevant arrow
to place in the Grouping Variablebox
Now click the Define Groupsbox and type in the values of the grouping
variable.
Youll get a similar output. In our example, which represents HDL levels between two
groups, the first group in the treatment arm of a trial and the second group in the
placebo arm, we get:
Levenes t-test for equality of means
F Sig. T df sig Mean
Diff
s.error
Diff
Lower Upper
Equal variances 0.441 0.511 -0.120 39 0.905 -0.0097 0.08118 -0.17407 0.15462
Not equal variances -0.120 36.92 0.905 -0.0097 0.08118 -0.17422 0.15478
4
In statistics, Log is synonymous with Natural Logs as we hardly ever use Log, Base 10. Therefore, itis not unusual for our transformed variables to be called Log when Ln mayseem more appropriate.
11
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
12/24
Again we can assume equal variances (p=0.51). There is no evidence of any difference
in levels of HDL betweem the two groups (p=0.91). We observe a mean difference of
-0.0097, but this is between the log transformed outcomes. If we exponentiate the mean
difference in the table, then we get 0.99. This is the ratio of the means of the treatment
group and the placebo group, i.e. The average HDL reading of the treatment group is
0.99 times the average of the placebo group. If we exponentiate the limits of theconfidence interval, then we get a confidence interval of this ratio, which is (0.84,
1.16), that is the average HDL after the treatment group is somewhere between 0.84
times and 1.16 times the average HDL after a course of the placebo.
In order to exponentiate, we have to do it either with a calculator or a spreadsheet, using
the EXP function.
Mann Whitney U test
If our data are not normally distributed then using a t-test is prone to increasing ourchances of a Type I Error, i.e. giving us a significant p-value when there is no
difference in the population. In order to combat this, we use a non-parametric test. The
equivalent of the t-test is the Mann-Whitney U test. We may use medians to describe
non-normal data, but the Mann-Whitney U is a rank test, so does not directly compare
two medians. It compares two distributions.
The menu for running a Mann-Whitney U test is under theAnalyse mean, click on
Nonparametric Tests, then click on 2 Independent Samples
Highlight the variable to be tested and click on the relevant arrow to place it in
the Test Variablebox Highlight the variable defining the groups and click on the relevant arrow to
place in the Grouping Variablebox
12
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
13/24
Click on the Define Groupsbox and type in the values of the grouping
variable corresponding to the groups being compared. This is identical to the t-
test example.
Click on Continue and then OK
In this example, comparing weight between men and women, we get the following
output:
We can see from the p-value (reported in SPSS as 0.000, but we should report as
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
14/24
Quantitative variables matched data
When we analyse two matched continuous variables within a single group, there are
two possible scenarios.
We have measured the same variable twice, maybe at two different time points and weare interested in whether this measure has changed in the duration.
We have two separate groups but they have been pair-wise matched in some way
As with most analysis with continuous variables the actual method of analysis is
dependent on the assumption of normality. Let us consider our approach
If normal, we can get a confidence interval for the average decline over time
and a p-value from a paired-sample t-test.This is ALL available in the
COMPARE MEANS option.
If not-normal, we use the confidence interval for the median decline and a p-
value from a Wilcoxon Test. SOME of this is available in the NON-
PARAMETRIC TESTS option.
In this case the normality we are interested in is the normality of the paired
differences. In order to test for normality in our paired differences, we need to calculate
the difference between the two variables and test that for normality. Data that are
normally distributed at both time points often have normally distributed differences.
Also some data that are non-normal at both time points could have normal paired
differences. For example, hdl may be log-normal at time 1 and log-normal at time 2 but
the reductions in hdl could be normal. There is no hard and fast rule for the distributionof the paired differences, it will have to be checked. However normally distributed
paired differences are very common.
Paired t-test
This test is appropriate when we have a repeated measure on a single group of subjects
(or our groups have been matched in the design) and the paired difference between the
paired variables is normally distributed.
Select Compare Means
Select paired-sample t-test
Highlight the two variables to be tested and click on the relevant arrow to place
in the Paired Variablesbox (e.g. In this case we choose pre and post you
have to select them both before transferring them across)
14
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
15/24
Click on OK
Here is an example of some output: It demonstrates the difference in calories taken by a
sample of women, pre and post menstruation
Paired Differences
Mean SD s.error Lower Upper t df sig
Pair 1 1283.33 398.64 132.88 976.91 1589.75 9.658 8 0.000
Therefore, we have observed that that dietary intake on pre menstrual days is 1283
calories higher than dietary intake on post menstrual days with a confidence interval of
(977 calories,1590 calories). This is highly significant (p
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
16/24
Click on OK
We get the following output.:
The mean ranks are not appropriate summary statistics. Therefore, the figure we are
most interested in is the p-value in the table overleaf (Asymp. Sig.(2-tailed)). We can
conclude there is a significant difference in calorie intake between the premenstrual and
postmenstrual period (with a higher intake on premenstrual days as the mean negative
rank exceeds the mean positive rank). This time to get the median difference, calculate
the difference variable first and then Explore this new variable. To get the confidence
interval for it seek alternative help.
Quantitative variables Correlations
16
Ranks
9a 5.00 45.00
0b .00 .00
0c
9
Negative Ranks
Pos itive Ranks
Ties
Total
Dietary intake pos t
menstrual - Dietary
intake pre-menstrual
N
Mean
Rank
Sum of
Ranks
Dietary intake post menstrual < Dietary intake pre-menstruala.
Dietary intake post menstrual > Dietary intake pre-menstrualb.
Dietary intake pre-menstrual = Dietary intake post menstrualc.
Test Statisticsb
-2.666a
.008
Z
Asymp. Sig. (2-tailed)
Dietary
intake pos t
menstrual
- Dietary
intake
pre-menstr
ual
Based on positive ranks.a.
Wilcoxon Signed Ranks Testb.
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
17/24
Correlations allows us to assess the strength of the relationship between two continuous
variables.
If normal data, we use a Pearsons correlation coefficient If non-normal data, we use a Spearmans correlation coefficient
Some people would say you need BOTH variables to be normal to do a Pearsons. This
is true if you want the Confidence Interval. Without the confidence interval, you only
need one variable to be normal but as we are advocating Confidence Intervals in this
course, only use Pearsons if BOTH variables are normally distributed otherwise use
Spearmans. An alternative correlation coefficient for non-normal data is Kendalls
Tau-B but we will use Spearmans.
The Correlate menu is underAnalyse
Click on Bivariate
Highlight the relevant variables and click on the arrow to place them in the
Variablesbox
Select either Pearson or Spearman.
- We use Pearson when we have normally distributed data and believe we have
a linear relationship.
- We use Spearmans when we have non-normally distributed data and/or a non-
linear relationship is to be assessed.
(In this case, as we believe height and weight are normal, we shall click Pearson)
Click on OK
17
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
18/24
SPSS gives the following outcome which shows that Height and Weight are highly
correlated (correlation coefficient=0.747). SPSS does not give a confidence interval for
the correlation coefficient.
18
Correlations
1.000 .747**
. .000
114 114
.747** 1.000
.000 .
114 114
Pearson Correlation
Sig. (2-tailed)
N
Pearson Correlation
Sig. (2-tailed)
N
HEIGHT
WEIGHT
HEIGHT WEIGHT
Correlation is significant at the 0.01 level
(2-tailed).
**.
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
19/24
Quantitative variables: More than two groups
The p-value for a comparative test between more than two groups will provide evidence
for the hypothesis that all the groups, on average, are the same. Consider this example.In this dataset, three groups, defined by age, are given a task to reduce their stress
levels.The stress is measured on a scale of 0 to100 where 0=No stress to
100=Total Stress and is measured twice, once before the task and then afterwards. It
is theorised that age will be related to the efficacy of the task. Therefore we are
comparing three means, the mean decline in stress of those aged 16-25, the mean
decline for those aged 26-45 and the mean decline for those aged 45-65.
The way we answer the question Are the average stress declines the same?
depends on whether our continuous variable is normally distributed or not. Here, we
need to examine normality within each of our groups.6
If it is normal, then we can get a p-value from a One Way Analysis of
Variance.This is available in SPSS under the COMPARE MEANS option
If it is Log normal, then we can get a p-value from a One Way Analysis of
Variance after we have transformed our data. This is available in SPSS under
the COMPARE MEANS option [No Example given]
If it is not normal, then we can get a p-value from a Kruskal-Wallis Analysis
of Variance.This is available under the NON-PARAMETRIC TESTS
option.
One Way ANOVA
To run a one-way ANOVA, go to theAnalyse Menu, select Compare Means, then
select Oneway Anova
Highlight the variables to be tested and click on the arrow to add them to the
dependent list. Add the grouping variable, age, into the Factorbox.
6 We also assume equal variances in each group.
19
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
20/24
Click on Options and clickDescriptives
In this example, we get the following
D es c r ip tiv es
20 14.30 10.5 7 9 2.36 5 9.35 19.25 -3 33
20 9.45 8 .924 1 .995 5 .27 13.6 3 -17 21
20 14.40 12.47 5 2.7 8 9 8 .5 6 20.24 -1 43
6 0 12.7 2 10.8 27 1 .398 9.92 15 .5 1 -17 43
20 5 2.8 0 11.218 2 .5 09 47 .5 5 5 8 .05 35 7 2
20 33.40 15 .010 3.35 6 26 .38 40.42 11 6 1
20 35 .6 0 11.7 49 2.6 27 30.10 41.10 19 6 3
6 0 40.6 0 15 .298 1.97 5 36 .6 5 44.5 5 11 7 2
1 15 -25
2 26 -45
3 46 -6 5
T otal
1 15 -25
2 26 -45
3 46 -6 5
T otal
DECLIN E
S T RPRE
N M ean S td . De vi ati on S td . Erro r Low er Bou nd U pper Bou nd
95 % C onfidence Interval for
Mean
M i ni m u m M ax im u m
ANOVA
320.233 2 160.117 1.384 .259
6595.950 57 115.718
6916.183 59
4513.600 2 2256.800 13.840 .000
9294.800 57 163.067
13808.400 59
Between Groups
Within Groups
Total
Between Groups
Within Groups
Total
DECLINE
STRPRE
Sum of Squares df Mean Square F Sig.
The p-value for the mean decline is 0.26, whereas for the levels of stress before the task
(Variable name: strpre) it is
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
21/24
the levels of stress before the task were different. We can see from the descriptives that
the younger age group were more stressed with a mean score of 52.80 (95%
C.I.=(47.6,58.1)) compared with mean scores of 33.4 for the 26-45 age group and 35.6
for the 46-65 age group. The middle age group showed the smallest decline, average 9.5
(95% C.I.=(5.3,13,6)) but this was not significantly smaller.
Multiple Comparison Tests
Click onPost Hoc and put a tick in the box corresponding to one of the multiple
comparison tests (eg. Scheffe, Duncan, Tukey). Click on Continue.
Kruskal-Wallis
For example purposes, we are using the same stress data set but in this case we are
assuming it is not normally distributed. If this were the case, then by using a One-way
Analysis of Variance, we have a large chance of invoking a Type I error. Therefore, we
choose the non-parametric version, the Kruskal-Wallis One Way Analysis of
Variance.
Enter the variables that you want to test into the Test Variable List. Enter the
grouping variable, age, into the Grouping Variable box.
Click onDefine Range. Enter the range of categories that you want to test, in
this case we want to test from 1 (16-24) up to 3 (45-64). i.e we are choosing a
subset of the possible age groups.
Click on Continue
21
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
22/24
Click on OK
We get the following output:
Test Statisticsa,b
1.712 19.268
2 2
.425 .000
Chi-Square
df
Asymp. Sig.
DECLINE STRPRE
Kruskal Wallis Testa.
Grouping Variable: AGEb.
I have missed out the mean ranks from the output as, again, they are meaningless if
you wish to explore further where any differences lie use theExplore option. We see
there is little evidence of a difference between groups in the levels of stress decline
(p=0.43) but there is strong evidence of a difference in levels of stress before the task
(p
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
23/24
APPENDIX
Entering Data for Paired and Unpaired Tests
The golden rule for data entry is ONE ROW PER SUBJECT. No more and no less.
Therefore, when we are comparing independent groups, we would get a data sheet such
as.
i.e., we have a group variable, work, which tells us which workplace the subject is in
and an outcome variable, cough, which tells us whether the subject has a history of
cough.
It is not appropriate in this case to create three variables, one for each workplace. Wewould then have 3 subjects per row.
When we have paired data, we get a data set such as the set overleaf.
23
-
7/31/2019 SPSS2 Guide Basic Non-parametrics
24/24
This time year 1 is in one column and year 2 is in another column. We do not have a
year variable because that would mean that we would have two rows for one subject.
The consequence of all this is that the menus for the paired analysis are set up
differently for the menus of the unpaired analysis.
However, both menus are set up to accommodate:
ONE ROW PER SUBJECT and ONE SUBJECT PER ROW