UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SPSS Textbook Examples
Applied Longitudinal Data Analysis: Modeling Change and Event Occurrence
by Judith D. Singer and John B. Willett
Chapter 2: Exploring Longitudinal Data on Change


Figure 2.1, page 18

get file ="c:\alda\tolerance.sav".
list cases.

      ID    TOL11    TOL12    TOL13    TOL14    TOL15     MALE EXPOSURE
    9.00     2.23     1.79     1.90     2.12     2.66      .00     1.54
   45.00     1.12     1.45     1.45     1.45     1.99     1.00     1.16
  268.00     1.45     1.34     1.99     1.79     1.34     1.00      .90
  314.00     1.22     1.22     1.55     1.12     1.12      .00      .81
  442.00     1.45     1.99     1.45     1.67     1.90      .00     1.13
  514.00     1.34     1.67     2.23     2.12     2.44     1.00      .90
  569.00     1.79     1.90     1.90     1.99     1.99      .00     1.99
  624.00     1.12     1.12     1.22     1.12     1.22     1.00      .98
  723.00     1.22     1.34     1.12     1.00     1.12      .00      .81
  918.00     1.00     1.00     1.22     1.99     1.22      .00     1.21
  949.00     1.99     1.55     1.12     1.45     1.55     1.00      .93
  978.00     1.22     1.34     2.12     3.46     3.32     1.00     1.59
 1105.00     1.34     1.90     1.99     1.90     2.12     1.00     1.38
 1542.00     1.22     1.22     1.99     1.79     2.12      .00     1.44
 1552.00     1.00     1.12     2.23     1.55     1.55      .00     1.04
 1653.00     1.11     1.11     1.34     1.55     2.12      .00     1.25

Number of cases read:  16    Number of cases listed:  16

Creating a person-period data set from a balanced person-level data set and bottom part of Figure 2.1 with person-period data.

* reshaping data into person period data file.
varstocases  
 /make tol from tol11 tol12 tol13 tol14 tol15
 /index=measure(5)
 /keep=id exposure male.
compute age=measure+10.
compute time=age-11.
execute.

list cases /var=id age tol male exposure.
      ID      AGE      TOL     MALE EXPOSURE

    9.00    11.00     2.23      .00     1.54
    9.00    12.00     1.79      .00     1.54
    9.00    13.00     1.90      .00     1.54
    9.00    14.00     2.12      .00     1.54
    9.00    15.00     2.66      .00     1.54
   45.00    11.00     1.12     1.00     1.16
   45.00    12.00     1.45     1.00     1.16
   45.00    13.00     1.45     1.00     1.16
   45.00    14.00     1.45     1.00     1.16
   45.00    15.00     1.99     1.00     1.16
 ...........................................
 1653.00    11.00     1.11      .00     1.25
 1653.00    12.00     1.11      .00     1.25
 1653.00    13.00     1.34      .00     1.25
 1653.00    14.00     1.55      .00     1.25
 1653.00    15.00     2.12      .00     1.25

Number of cases read:  80    Number of cases listed:  80

Table 2.1 on page 20, estimated bivariate correlations among tolerance scores.

corr /var=tol11 to tol15.


Figure 2.2 , page 25

NOTE:  SPSS will only create a certain number of panels with a single igraph command; you may get an error message if you try to run this command on a large data set.  You may need to use a filter or the split file command to reduce the number of subjects to be used in each igraph command.

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /panel=var(id)
  /scalerange=var(tol) min=0 max=4
  /line(mode) key=off style=dot.


Figure 2.3, page 27

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /panel=var(id)
  /scalerange=var(tol) min=0 max=4
  /line(mode) key=off style=dotline interpolate=spline.


Table 2.2, page 30

Separate regressions for Table 2.2. The first table of Model Summary gives the R-square column. The second table of ANOVA gives the residual variance column which is the Mean Square column for residuals. The last table of Coefficients gives the columns for Initial status and for the rate of change. The last two columns of Table 2.2 can be obtained from the original data set.

sort cases by id.
split file by id.
regress /dep=tol /meth=enter time.
split file off.


Figure 2.4 on page 31, the top part. We can make use of the option from regression to save the parameter estimates to a data file and use this data set for the stem-and-leaf plots. The data set does not contain either R-square or the residual variance for the bottom part of Figure 2.4. So we skip the bottom part now.
GET FILE='D:\alda\atsdata\spss\tolerance_pp.sav'.
sort cases by id.
split file by id.

REGRESSION
  /DEPENDENT toleranc
  /METHOD=ENTER time
  /OUTFILE=COVB('D:\alda\spss\table2.2.sav') .
GET FILE='D:\alda\spss\table2.2.sav'.
USE ALL.
COMPUTE filter_$=(rowtype_ = "EST").
FILTER BY filter_$.
EXECUTE .
examine variables=const_ time/plot=stemleaf.

Constant

Constant Stem-and-Leaf Plot
 Frequency    Stem &  Leaf
     1.00        0 .  9
     9.00        1 .  001111234
     6.00        1 .  555789
 Stem width:      1.00
 Each leaf:       1 case(s)

TIME

TIME Stem-and-Leaf Plot
 Frequency    Stem &  Leaf
     2.00       -0 .  59
     1.00       -0 .  3
     3.00        0 .  224
     1.00        0 .  5
     2.00        1 .  14
     3.00        1 .  557
     2.00        2 .  34
     1.00        2 .  6
     1.00 Extremes    (>=.63)
 Stem width:       .10
 Each leaf:       1 case(s)

Figure 2.5, page 32. 

To make the graph look like the text, you need to do the following additional steps via "point and click". 

To remove the regression equations, double click on the graph and click on the chart manager icon.  Then click on the Regression item and click on Edit and then click Options and then uncheck Show Mean Line Label and uncheck Show R-Squared Label.

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /panel= var(id)
  /fitline method=regression linear line=total spike=off
  /scalerange=var(tol) min=0 max=4
  /scatter.



Figure 2.6, page 34, left-hand panel

This graph does not contain the curve for the overall effect.  We omitted the legend at the right by click on the legend and choosing hide legend

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /style=var(id)
  /scalerange=var(tol) min=0 max=4
  /line(mode) key=off style=line interpolate=spline.

Figure 2.6, page 34, right-hand panel

To make the graph look like the text, you need to do the following additional steps via "point and click". 

To remove the regression equations, double click on the graph and click on the chart manager icon.  Then click on the Regression item and click on Edit and then click Options and then uncheck Show Mean Line Label and uncheck Show R-Squared Label.

We omitted the legend at the right by click on the legend and choosing hide legend

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /style= var(id)
  /fitline method=regression linear line=total meffect spike=off
  /scalerange=var(tol) min=0 max=4.


Table 2.3 on page 37. We have created a data set for Figure 2.4 and we can use it here.

GET FILE='D:\alda\spss\table2.2.sav'.
USE ALL.
COMPUTE filter_$=(rowtype_ = "EST").
FILTER BY filter_$.
EXECUTE .
CORRELATIONS
  /VARIABLES=const_ time
  /PRINT=TWOTAIL NOSIG
  /STATISTICS DESCRIPTIVES.

Correlations


Figure 2.7, page 38, upper portion of graph.

To make the graph look like the text, you need to do the following additional steps via "point and click". 

To remove the regression equations, double click on the graph and click on the chart manager icon.  Then click on the Regression item and click on Edit and then click Options and then uncheck Show Mean Line Label and uncheck Show R-Squared Label.

We omitted the legend at the right by click on the legend and choosing hide legend

We double clicked on the title of the graph (the 0.00) and clicked on the titles tab and chose Variable Names in Titles to show the variable names in the titles.

compute hiexp = 0.
if (exposure >= 1.145) hiexp = 1 .
execute.

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /style= var(id)
  /panel=var(male)
  /fitline method=regression linear line=total meffect spike=off
  /scalerange=var(tol) min=0 max=4.

Figure 2.7, page 38, lower portion of graph.

To make the graph look like the text, you need to do the following additional steps via "point and click". 

To remove the regression equations, double click on the graph and click on the chart manager icon.  Then click on the Regression item and click on Edit and then click Options and then uncheck Show Mean Line Label and uncheck Show R-Squared Label.

We omitted the legend at the right by click on the legend and choosing hide legend

We double clicked on the title of the graph (the 0.00) and clicked on the titles tab and chose Variable Names in Titles to show the variable names in the titles.

igraph
  /x1=var(age) type=scale
  /y=var(tol) type=scale
  /style= var(id)
  /panel=var(hiexp)
  /fitline method=regression linear line=total meffect spike=off
  /scalerange=var(tol) min=0 max=4.

Figure 2.8 on page 40 can be created based on the data set we created for Figure 2.4. The data set is table2.2.sav. We will have to merge it back with the original data set to have all the variables in one data set.

GET
  FILE='D:\alda\spss\table2.2.sav'.

FILTER OFF.
USE ALL.
SELECT IF(rowtype_ = "EST").
EXECUTE .

MATCH FILES /FILE=*
 /RENAME (depvar_ rowtype_ varname_ = d0 d1 d2)
 /FILE='D:\alda\spss\tolerance.sav'
 /RENAME (tol11 tol12 tol13 tol14 tol15 = d3 d4 d5 d6 d7)
 /BY id
 /DROP= d0 d1 d2 d3 d4 d5 d6 d7.
EXECUTE.
CORRELATIONS
  /VARIABLES=const_ time male exposure.

GRAPH
  /SCATTERPLOT(BIVAR)=male WITH const_.

GRAPH
  /SCATTERPLOT(BIVAR)=exposure WITH const_.

GRAPH
  /SCATTERPLOT(BIVAR)=male WITH time.

GRAPH
  /SCATTERPLOT(BIVAR)=exposure WITH time.


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


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.