1.0 SPSS commands used in this unit
crosstabs  Crosstabulations 
ttest  ttests 
glm  General linear models 
regression  OLS regressions 
pplot  Normal probability plot 
logistic  Logistic regressions 
npar  Nonparametric 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_datahs1.sav". 
2.1 Chisquare
The chisquare test is used to determine if there is a relationship between two categorical variables.

* chisquare test. crosstabs /tables prgtype by ses /statistic = chisq. 
2.2 ttests
This is the onesample ttest, testing whether the sample of writing scores was drawn from a population with a mean of 50.

ttest /testval=50 /variables=write. 
This is the twosample independent ttest with separate (unequal) variances.

ttest groups=female(0 1) /variables=write. 
This is the paired ttest, testing whether or not the mean of write equals the mean of science.

ttest pairs= write with science (paired). 
2.2 ANOVA
In this example the glm command is used to perform a oneway analysis of variance (ANOVA).

glm write by prog /design = prog. 
In this example the glm command is used to perform a twoway analysis of variance (ANOVA). The plot subcommand 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 pairwise 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.

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 of the systematic variance has been explained by the model.

regression /dependent math /method=enter female write socst /scatterplot=(*zresid ,*zpred). * The reference lines are added * via the pointandclick * interface in the Chart Editor. 
The PP plots command produces a normal probability plot. It is a method of visualizing the residuals from the regression to determine if they are normally distributed.

*residual plots. pplot /variables=res_1 /type=pp /dist=normal. 
The QQ plots produces a normal quantile plot. It is another method of visualizing the residuals to determine if they 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.

pplot /variables=res_1 /type=qq /dist=normal. 
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). execute. * logistic regression. logistic regression var=honcomp /method=enter read socst. 
2.5 Nonparametric tests
The binomial test is the nonparametric analog of the singlesample twosided ttest.

* binomial test. npar test /binomial (.50)= write (50). 
The signrank test is the nonparametric analog of the paired ttest.

* sign test. npar test /sign= read with write (paired). 
The Mann Whitney U test is the nonparametric analog of the independent twosample ttest.

*signrank test. npar tests /mw= write by female(1 0). 
The Kruskal Wallis test is the nonparametric analog of the oneway ANOVA.

* kruskalwallis test. npar tests /kw=write by prog(1 3). 
3.0 Syntax version
get file "c:spss_datahs1.sav". * chisquare test. crosstabs /tables prgtype by ses /statistic = chisq.
* ttests. ttest /testval=50 /variables=write. ttest groups=female(0 1) /variables=write. ttest pairs= write with science (paired). * anova. glm write by prog /design = prog. glm write by prog ses /design = prog, ses, prog*ses /plot = profile(prog*ses). glm write by prog ses /design = prog, ses, prog*ses /posthoc = prog(tukey). * ancova. glm math with science write /design= science write. * regression. regression /dependent math /method=enter write science. regression /dependent math /method=enter socst write ses /scatterplot=(*zresid ,*zpred ). *residual plots. pplot /variables=res_1 /type=pp /dist=normal. pplot /variables=res_1 /type=qq /dist=normal. * creating a dichotomous variable. compute honcomp = (write > 60). execute. * logistic regression. logistic regression var=honcomp /method=enter read socst. * nonparametric tests. * binomial test. npar test /binomial (.50)= write (50). * sign test. npar test /sign= read with write (paired). *signrank test. npar tests /mw= write by female(1 0). * kruskalwallis test. npar tests /kw=write by prog(1 3).
4.0 For more information
 Choosing the Correct Statistical Test in SPSS Includes guidelines for choosing the correct nonparametric test
 SPSS Frequently Asked Questions Covers many different topics including: ANOVA, Generalized Linear Models (GLM) and linear regression
 SPSS Regression Webbook Includes such topics as diagnostics, categorical predictors, testing interactions and testing contrasts
 SPSS Data Analysis Examples Includes examples of common data analysis techniques
 SPSS Annotated Output
 Includes annotated output for descriptive statistics, correlation, regression and logistic regression
 SPSS LibraryTopics in ANOVA and other subjects