2015 SPSS Exercise
2015 SPSS Exercise
2015 SPSS Exercise
SPSS exercise
As part of Quantitative Research Methods
Wintersemester 2013/2014
Outline:
1 Everything you ever wanted to know about statistics
2 Parameter testing
When opening SPSS you can select if you want to type in new data or use an
existing data set. If you select cancel you will get to the main window that does
not contain any data.
SPSS uses 3 windows: data-, syntax and SPSS-viewer:
SPSS data-editor (appears when the programme is opened): shows the
data in the data view and the characteristics of the variables under variable
view (file ending .sav)
SPSS Viewer (opens automatically after an analysis): shows the results. The
SPSS viewer shows the results as a hierarchy. One analysis can result in
many tables. Clicking on the + or symbol aggregates or disaggregates the
results. Clicking on one object shows the respective table. (file ending: .spv)
SPSS Syntax-Editor (can be opened with Aufruf ber Men FILE NEW
SYNTAX): instructions are entered in this window. The instructions are
executed by clicking the
(file ending: .sps)
In the variable view you can enter important information for every variable
Every variable should have a unique name
o Each variable has to be named in column Name.
The default is VAR00001
The type of data is important as it determines what kind of analyses you can
do with the variable
Different variable types exist
o Numeric
Numbers (e.g. 7, 0, 120)
o String
Letters (e.g. Andy, Idiot)
o Currency
Currency (e.g. 20, $34, 56)
o Date
Dates (e.g. 21-06-1973, 06-21-73, 21-Jun-1973)
If you want to create a string variable:
When you work with several data sets or you work on several days on your
data set but you want to save your output within one output file only, saved it
the first time it opens. When you open SPSS again on another occasion, you
have to open this old output manually and close the new output viewer that
automatically opens. SPSS will then produce the output in the current SPSS
output viewer.
1.3.4 The Syntax Window
SELECT CASES
o It can be necessary to restrict the analysis to certain subgroups in the
data set, e.g. only females
o DATA / SELECT CASES: if condition is satisfied: select if gender = 2
continue; output: filter out unselected cases, copy selected cases to
a new data set, delete unselcted cases (ATTENTION, make sure to
have an original hard copy of the data set just in case) ok will
select cases. DATA / SELECT CASES/ RESET to reset the selection
o Note the new filter variable
o Alternative syntax:
compute air=0.
if (airplay le 10) air=1.
if (airplay ge 11 and airplay le 30) air=2.
if (airplay gt 30) air=3.
execute.
Import of an excel file into SPSS
Copy data Excel Sheet.xlsx from the student server to your personal server
Remember the range of data in Excel (A1:E31)
Check Read variable names from the first row of data
Enter Range
Ok
Save file as .sav file
Before conducting complex analyses, it is reasonable to get a general idea
about the structure and distribution of the data
Good introduction into the data with frequency tables.
Analyze Descriptive Statistics Frequencies Select variable(s); select
display frequency tables
Frequency tables, however, make only sense for variables with a manageable
amount of scores
11
In addition, there are descriptive measures which help getting an idea about
the data
Slides PART II
2 Parameter testing
2.1 Tables & Graphs, descriptive statistics
In order to get a first quick overview of your data and the distribution of a single
variable, it is advisable to produce a tables of descriptive statistics
12
13
14
25% Quartil: quality of life after surgery score, below which there are 25%
of all scores, 75% lie above this value (relatively unhappy people after
surgery)
50% Quartil: Median; quality of life after surgery score, below which there
are 50% of all scores, 50% lie above it
75% Quartil: quality of life score, under which there are 75% of all scpres,
25% lie above (relatively happy people after surgery)
Relatively unhappy people: score below 52.1; relatively happy after
surgery: score above 67
15
2.3 Graphs
2.3.1 The art of presenting data
Graphs should (Tufte, 2001):
show the data.
Induce the reader to think about the data being presented (rather than some
other aspect of the graph).
Avoid distorting the data.
Present many numbers with minimum ink.
Make large data sets (assuming you have one) coherent.
Encourage the reader to compare different pieces of data.
Reveal data.
Why is this graph bad?
The bars have a 3D effect, almost impossible to read
Bars have patterns: distract the eye from the data
Cylindrical bars: difficult to understand
Badly labelled y-axis: number of what
Why is this graph better?
16
18
Number of Obsessive
Thoughts/Actions per Day
16
Thoughts
Actions
14
12
10
8
6
4
2
0
CBT
BT
No Treatment
Therapy
17
19
20
The first thing that should leap out at you is that there appears to one case
that is very different to the others
All of the scores appear to be squashed up to one end of the distribution
because they are all less than 5, except for one which has a value of 20
This is an outlier: a score different to the rest
o Outliers bias the mean and inflate the standard deviation
The outlier in this diagram is particularly odd because it has a score of 20,
which is above the top of our scale (hygiene scale ranges from 0 to 4), and so
it must be a mistake
How can we detect the outlier? We can go through the 851 concert goers, or
do a boxplot
2.3.5 Boxplots
Boxplots are made up of a box and two whiskers.
The box shows:
o The median
o The upper and lower quartile
o The limits within which the middle 50% of scores lie.
The whiskers show
o The range of scores
o The limits within which the top and bottom 25% of scores lie
21
22
The outlier that we detected in the histogram is shown up as an asterisk (*) on the
boxplot and next to it is the number of the case (611) that causes this outlier
This is the boxplots for the hygiene scores on day 1 after the outlier has been
corrected
23
24
25
26
27
This graph displays the mean (and the confidence interval of those means) and
shows us that on average, people were more aroused by Memento than they were
by Bridget Jones Dairy
If we are interested in gender effects: clustered bar charts for independent means
28
Like the simple bar chart this graph tells us that arousal was overall higher for
Memento than Bridget Jones, but it also splits this information by gender
The mean arousal for Bridget Jones shows that males were actually more
aroused during this film than females
This indicates they enjoyed the film more than the women did
For memento, values are more comparable
But this contradicts the idea of a chick flick
o It actually seems that men enjoy chick flicks more than the chicks
TEST: Graph
Data Set: Heavy Metal.sav
Produce and error bar char for mean drug use for each of the different suicide
risks splitted by martial status.
29
Mean drug use (amounts of joints smoked per week) were overall higher for
suicidal individuals compared to non-suicidal individuals
For non-suicidal individuals, those living together had a lower drug use than
those living separated or divorced
For suicidal people however, mean drug use is slightly higher for those living
together than for those individuals that are separated or divorced
Significance testing
Testing the significance of Pearsons correlation coefficient
Testing the significance of b in regression.
Dependent t-test specifics
Data arrangement
Same individuals, reactions to different conditions (in different columns)
We will not practice the dependent t-test in class, have a look at Andy Field for an
example
Assumptions of the t-test
Both the independent t-test and the dependent t-test are parametric tests based on
the normal distribution.
Can e.g. be tested with a histogram displaying a nornmal curve
Data are measured at least at the interval level.
The independent t-test, because it is used to test different groups of people, also
assumes:
Variances in these populations are roughly equal (homogeneity of variance).
Will be checked with Levenes test within the SPSS procedure
Scores in different treatment conditions are independent (because they come from
different people).
31
p > 0,05: The H0 Variances are equal cannot be rejected, we can assume
that variance are sufficiently equal to assume variance homogeneity. We
interprete the first line in the output table (line: variances are equal
p < 0,05: The H0 variances are equal has to be rejected. In the ouput table
we interprete the line showing variances are not equal
REPORTING Levenes test: For these data, the Levenes test is
nonsignificant (because p=.357) which is greater than .05 and so we say
that the assumption of homogeneity of variances is met and we work with
the upper line of the t-test.
here: p>.05, i.e. the H0 is accepted and we look at the upper line
REPORTING: The descriptive table shows that means are different in our
sample. Mean arousal for males is 21.5 and for females it is 18.55. The
mean difference is 2.95. In order to test if the difference is significant, the
t-test is conducted
Definition of hypotheses
H0: Physical arousal during the movie does not differ between men and
women
H1: Physical arousal during the movie differs between men and women
If both means have the same size in the population, the t-value is 0
We get a value of 1.13
If there is no difference between the means in the population, the observed tvalue can result with a probability of X
The significance level is 26.6%, this means that when we reject the null
hypothesis we make a mistake of 26.6%
We cannot reject the null hypothesis, there is not significant difference in the
mean arousal
REPORTING: On average, men experienced greater physical arousal during
the film (M = 21.50, SE = 7.42), than do females (M = 18.55, SE = 9.02). This
difference was not significant t(38) = 1.13, p > .05; however, it did represent
a small effect r = .18.
Calculation of r: square root of (t^2/(t^2+df))
t2
t 2 df
=0.18
TEST: t-test
Data Set: Record.sav
Does the number of times a record is played on the radio differ dependeing on
whether the band is attractive or unattractive? Also check the t-test assumptions.
Generate a binary variable separating attractive from unattractive bands (attractive
band: attractiveness le 5; unattractive band: attractiveness gt 5)
33
compute attr=0.
if (attract le 5) attr=1.
if (attract gt 5) attr=2.
execute.
34
35
4 Correlation analysis
Theses: Relationship between the value of two variables
H0= there is no linear relationship between the variables
H1= there is a linear relationship between the variables
Measure of the strength and direction of this relationship is the correlation
coefficient
Identifies linear relationships
Expresses the strength of the relationship with a value between -1 and +1
Positive value: positive linear relationship
Negative value: negative linear relationship
Correlation coefficient becomes higher, the stronger the linear relationship
between the variables is
Correlation= 0 : no linear relationship
Orientation guidelines (absolute values)
Absolute value of the correlation Possible interpretation
coefficient
0
No correlation
Weak correlation
Medium correlation
Strong correlation
Perfect correlation
36
EXERCISE:
Data Set: 02_Record.sav
Is there a linear relationship between amount spent on advertising and record sales
(number of copies sold). Produce a scatterplot for the two variables.
Graphs Legacy dialog scatter simple scatter select variables for X- and
Y- axis, ok
37
We can see that there is a tendency towards a positive relationship, but we cannot
see how strong this relationship is
Analyze Correlate bivariate, select advertising budget and record sales; keep
default Pearsons correlation coefficient
As a default/ or standard setting, the Pearsons correlation coefficient is
calculated (variables need to have a ratio scale level)
Spearman and Kendall-Tau-B for ordinally scaled variables (variable values
are translated into ranks) rank correlation for ordinally scaled data
Select variables ok
38
Scatter plot is not very useful, seems to be a positive relation, but not very
clear
Based on the scatter plot we cannot determine whether the is a linear
relationship
Procedure: Analyze correlate bivariate
39
41
EXERCISE:
Data set: 04_CosmeticSurgery.sav
Is there an association between the reason to have cosmetic surgery and
gender?
Table contains the number of cases that fall into each combination of
categories
We can see that 98 of people (35.5% of total) had a cosmetic surgery due
to a physical reason and of these 82 were female (83.7% of the people
having a surgery for a physical reason) and 16 were male (16.3% of all
people with surgery due to a physical reason).
Further, 178 people (64.5% of total) had a cosmetic surgery in order to
change their appearance. Of those having a surgery to change
42
43
The table with the symmetric measures shows the strength of the
association. For Cramers Phi has a value of 0.401 indicating a medium effect
REPORTING: There was a significant association between gender and the
reason to have cosmetic surgery 2 (1) = 44.464, p< .001. The size of the
effect was medium.
This finding seems to represent the fact that based on the odds ratio, the
odds of having cosmetic surgery for a physical reason were 6.81 times
higher if the people were females comcpared to males
Standardized residuals show that for females the standardized residuals were
significant for both having cosmetic surgery for a physical reason or to
change appearance (both values are bigger than 1.96; z=3.5 and -2.6). The
plus or minus sign tells us that for females significantly more had cosmetic
surgery for a physical reason and significantly less had surgery to change
appearance. For males, significantly less had cosmetic surgery for physical
reason but more to change appearance (z=-4.0 and 3.0, resp.). All cells
contribute significantly to the overall Chi-square statistic
TEST CROSSTABS
Data Set: 08_Facebook.sav
Is there an association between RMiP Exam Result and whether or not
students looked at Facebook during lab classes?
44
Table contains the number of cases that fall into each combination of
categories
We can see that 168 of people (64,6% of total) passed the exam and of
these 44 looked at FB (26.2% of the students passing) and 124 did not
look at FB (73.8% of students passing).
Further, 92 people (35,4% of the total) did fail. Of those failing, 60 did
look at FB (65,2% of those failing) and 32 did not look at FB (34,8% of
those failing).
Of those looking at FB, 42,3% did pass and 57,7% did fail. Similarly, of
those not looking at FB, 79,5% passed and 20,5% did not
In summary, most students passing the exam did not look at FB during
class. Of those students failing the exam, the share of students looking
at FB is higher.
H0: the variables are independent (there is no association between exam
result and looking at FB during class)
H1: the variables are dependent (there is an association between exam
result and looking at FB during the exam)
45
The table with the symmetric measures shows the strength of the
association. For Cramers Phi has a value of -0.381 indicating a medium
effect
REPORTING: There was a significant association between looking at FB
during class and the exam result 2 (1) = 37.726, p< .001. The effect size is
medium.
This finding seems to represent the fact that based on the odds ratio, if the
studetns looked at FB during the class the odds of their failing the exam
was 5.23 times higher than if they had not looked
46
5 Regression analysis
5.1 ANOVA
Similar hypotheses to the t-Test:
Are the means of different subgroups of the same variables equal?
Different to the t-Test:
T-test compares 2 means, ANOVA compares more than 2 means
Differentiation between:
One-way ANOVA (1 independent variable) = ANOVA
Multivariate ANOVA
(> 1 independent variable)
One-dimensional ANOVA
(1 dependent variable)
EXERCISE:
Data Set: 06_Soya.sav
Run the following analysis excluding those males that ate only one soya meal
per week (filter cases).
Is there a difference in the mean number of sperms depending on the
frequency of soya consumption (no soya meals; four soya meals per week;
seven soya meals per week)?
Select cases
o Data select cases if condition is satisfied: Soya=1 | Soya=3 |
Soya=4 ok
Check if number of soya meals is normally distributed
Graph Legacy Dialogs Histogram, select display normal curve
48
49
50
51
52
Run one-way ANOVA, select posthoc and Welch and Brown-Forsythe (robust
tests of the equality of means when assumption of homogeneity of variances
is broken)
Table shows descriptive statistics, it shows that the mean beauty differs by
age category, especially the beauty of the youngsters is rated lower than that
of the two other categories.
REPORTING: The table shows the descriptive statistics of the dependent
variable, the attractiveness in %. It shows that means are different, with
the highest means for middle age category and the lowest for the youngest
53
statistic, we find that F(2, 137.78) = 10.061, p <.001. This indicates that there
is a significant difference in the mean attractiveness in % and the age
category.
First of all, the group of the youngest is compared to the group of the middle
aged supermodels and reveals a significant difference (Sig. is smaller than
.01), also when compared to the group of the oldest supermodels, there is a
significant difference (Sig is less than .05)
The group of the middle-aged supermodels is then compared to both the
youngest and the oldest group. The group means do not differ between the
middle-aged and the oldest group
The rest of the table reports the Games-Howell test. A quick inspection
reveals the same patterns of results: mean attractiveness in % differs
between the youngest and the middle-aged and the youngest and the oldest,
but not between the middle-aged and the oldest
REPORTING: A one-way ANOVA was used to test the attractivenenss
differences between three different age categories of supermodels. There
was a significant effect of the age category on attractiveness, F(2, 137.78) =
10.061, p <.001.
Post hoc analyses using the Tukey HSD and Games-Howell test indicated
that the mean attractiveness was lower in the group of the youngest
55
supermodels (M=72.87, SD=7.40) than in the other two conditions (middleaged: M=77.44, SD=5.99; oldest: M=77.16, SD=6.05), p<.05. The difference
between the middle-aged and the group of the oldest supermodels was not
significant.
5.2.1 Assumptions:
There must be causality
Variables need to have a metric scale
Introduction of independent nominally-scales variables as dummy variable
Linear relationship between dependent and independent variables
Model assumption (will not be verified in the course)
Normally distributed residuals
Linear relationship between the dependent variable and the independent variables
No multicollinearity
No heteroscedasticity
No autocorrelation
56
5.2.2 Model
Y = f(X)
Y = b0+b1*x
Drug use=f(normlessness)
Drug use=3.64+0.50*normlessness+e
57
betas are different from 0. Here, the F test statistic value is 32.24 and it is
highly significant (p<.001). This means that at least one coefficient in the
regression function is different from 0.
Coefficients table reports the test results for the single predictors in the model
60
EXERCISE II:
Data set: 03_HeavyMetal.sav
Test the hypothesis that drug use depends on normlessness and being
young. Discuss the quality of your analysis and report the regression function.
Generate a dummy variable for young using the variable age_group=1.
compute young=0.
if (age_group=1) young=1.
execute.
Why not simply use binary age_group variable? Because it is not a dummy
variable, needs to be 0/1 coded, data set description shows it is 1/2 coded
Dummy Variables:
By using dummies it is possible to also use qualitative normal scale variables. These
normal scaled variables are transferred into binary variables which can be handled
as metric variables. As however, the number of independent variables increases
considerably, this technique is only possible for the dependent variable (but logit
regression).
One of the dummies needs to be excluded and becomes the reference category!
61
REPORTING:
Regression
function:
Drug
Use=3.52+0.48*normlessness+0.45*young+e
The null hypothesis of the constant is: the constant is 0. The alternative
hypothesis is: the constant is not 0. The constant shows the height of drug
if normless and young are 0. The t-test statistic has a value of 5.26 and it is
highly significant (p<.001). It shows that baseline drug use is 3.52 joints
smoked per week (given that the model predictors are 0).
The null hypothesis for normlessness is: beta=0. The alternative hypothesis
is: beta is not 0. There is a linear relationship between drug use and
normlessness. The t-test statistic has a value of 5.37 and the value is highly
significant (p<.001) meaning that if normlessness increases about 1 unit,
drug use increases about 0.48 units.
The null hypothesis for young is: Drug use does not differ between young
and old. The alternative hypothesis is: drug use does differ between young
and old. The t-test statistic has a value of 0.846 and the value is not
significant (p>.05) indicating that there is no difference in drug use
between young and old. (If it would be significant: Young heavy metal
listeners have a drug use which is about 0.45 units higher than the drug
use of the old heavy metal listeners.)
Multiple regression analysis was used to test if normlessness and being
young significantly predicted drug use. The results of the multiple
regression indicated the predictors explained 21.8% of the variance
(F(2,118)=16.44, p<.001). It was found that normlessness significantly
predicted drug use (beta= .48, p<.001) and that being young not
significantly predicted drug use (beta=0.45; p>.05).
62
This means that the independent variables in the regression explain the
distribution of the dependent variable to 9.4%.
sperm count that is -.382 lower than that of those eating no soya meals per
week)
The null hypothesis for four is: Sperm count does not differ between those
eating no soya meal per week and those eating it four times a week. The
alternative hypothesis is: sperm count does differ between no and four.
The t-test statistic has a value of -0.671 and the value is not significant
(p>.05) indicating that there is no difference in sperm ocunt between no
and once. (If it would be significant: Those eating soya meals four times a
week have a sperm count that is -.671 lower than that of those eating no
soya meals per week)
The null hypothesis for seven is: Sperm count does not differ between
those eating no soya meal per week and those eating it seven times a
week. The alternative hypothesis is: sperm count does differ between no
and seven. The t-test statistic has a value of -2.55 and is significant (p<.05)
indicating that there is a difference in sperm count between no and seven.
Those eating soya meals seven times a week have a sperm count that is 2.55 lower than that of those eating no soya meals per week.
66
67
The first table produced by SPSS contains descriptive statistics (mean etc.)
The important table is that of the K-S test
This table includes the test statistic itself (D), the degrees of freedom (which should
equal the sample size) and the significance value of this test
A significant value (i.e. less than p<.05) indicates a deviation from normality
The K-S test for the sperm count is highly significant, indicating that the distribution
is not normal
SPSS also produces a normal Q-Q plot for any variables specified, it plots the value
you would expect to get if the distribution were normal (expected values) against the
values actually seen in the data set (observed values)
If the data are normally distributed, then the observed values (the dots) should fall
exactly along the straight line
REPORTING: The sperm count in million, D (40)=0.19, p<.05 is significantly
not normal.
Analyze whether the sperm count in millions is different for people eating no
soya meals per week compared to those eating one soya meal per week.
Data set description: p.559
Analyze Nonpar Legacy dialogs 2 independent samples sperm count
as test variable soya as grouping variable (define groups, group 1: 1 for no
soya meals; group 2:2 for one soya meal per week) test type Mann Whitney U
ok
Z
r
N
R=-0.243/Wurzel aus 40=-0.04
69