SPSS Class Notes
Analyzing Data

1.0  SPSS commands used in this unit

crosstabs Crosstabulations
t-test t-tests
glm General linear models
regression OLS regressions
pplot Normal probability plot
logistic Logistic regressions
npar Non-parametric tests

2.0 Demonstration and explanation

For this section we will be using the hs1.sav data set that we worked with in previous sections.

get file "c:\spss_data\hs1.sav".

2.1  Chi-square

The chi-square test is used to determine if there is a relationship between two categorical variables.

* chi-square test.
  /tables prgtype by ses
  /statistic = chisq.

2.2  t-tests

This is the one-sample t-test, testing whether the sample of writing scores was drawn from a population with a mean of 50.


This is the two-sample independent t-test with separate (unequal) variances.

  groups=female(0 1)

This is the paired t-test, testing whether or not the mean of write equals the mean of science.

  pairs= write with science (paired).

2.2  ANOVA

In this example the glm command is used to perform a one-way analysis of variance (ANOVA).

  write  by prog
  /design = prog.

In this example the glm command is used to perform a two-way analysis of variance (ANOVA).  The plot option creates plots of the means, which can be a great visual aid to understanding the data.

glm write by prog ses
 /design = prog, ses, prog*ses
 /plot = profile(prog*ses).

The Tukey test is used to test all the pair-wise comparisons of the levels of prog.

glm write  by prog ses
 /design = prog, ses, prog*ses
 /posthoc = prog(tukey).

Here the glm command performs an analysis of covariance (ANCOVA). Note that the results are exactly the same as in the regression where write and science are regressed on math.

glm math with science write
 /design= science write.

2.3  Regression

This is plain old OLS regression.

 /dependent math
 /method=enter write science.

It is often very useful to look at the standardized residual versus standardized predicted plot in order to look for outliers and to check for homogeneity of variance.  The ideal situation is to see no observations beyond the reference lines, which means that there are no outliers.  Also, we would like the points on the plot to be distributed randomly, which means that all the systematic variance has been explained by the model.

 /dependent math
 /method=enter socst write ses
 /save residual (res_1)
 /scatterplot=(*zresid ,*zpred).
* The reference lines are added via the point-and-click interface in the Chart Editor.

The P-P plots command produces a normal probability plot.  It is a method of testing if the residuals from the regression are normally distributed.

*residual plots.

The Q-Q plots produces a normal quantile plot. It is another method for testing if the residuals are normally distributed. The normal quantile plot is more sensitive to deviances from normality in the tails of the distribution, whereas the normal probability plot is more sensitive to deviances near the mean of the distribution.


2.4  Logistic regression

Logistic regression requires a dependent variable that is dichotomous (i.e., has only two values).  As we do not have such a variable in our data set, we will create one called honcomp (honors composition). This is purely for illustrative purposes only!

* creating a dichotomous variable.
compute honcomp = (write > 60).

* logistic regression.
logistic regression var=honcomp
 /method=enter read socst.

2.5  Non-parametric tests

The binomial test is the nonparametric analog of the single-sample two-sided t-test.

* binomial test.
npar test
 /binomial (.50)= write (50).

The signrank test is the nonparametric analog of the paired t-test.

* sign test.
npar test
 /sign= read with write (paired).

The Mann Whitney U test is the nonparametric analog of the independent two-sample t-test.

*signrank test.
npar tests
 /m-w= write by female(1 0).

The Kruskal Wallis test is the nonparametric analog of the one-way ANOVA.

* kruskal-wallis test.
npar tests
 /k-w=write by prog(1 3).

3.0 For more information

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.