UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SPSS Textbook Examples
Regression Analysis by Example, Third Edition
Chapter 6:  Transformation of Variables

Table 6.2, page 157. Number of surviving bacteria (units of 100)

get file 'D:\p157.sav'.
list.
       t      n_t

       1      355
       2      211
       3      197
       4      166
       5      142
       6      106
       7      104
       8       60
       9       56
      10       38
      11       36
      12       32
      13       21
      14       19
      15       15

Number of cases read:  15    Number of cases listed:  15

Table 6.3 and Figure 6.5-6.6, page 159

regression
/dependent = n_t
/method enter = t
/scatter (n_t, t) (*sresid, t).

Table 6.4 and Figure 6.7-6.8, page 160-161

compute lnn_t = ln(n_t).
exe.
regression
/dependent = lnn_t
/method enter = t
/scatter (lnn_t, t) (*sresid, t).

Table 6.6, page 164. Number of Injury Incidents Y and Proportion of Total Flights N

data list list
/y n.
begin data.
11 .095
7 .192
7 .075
19 .2078
9 .1382
4. .054
3 .1292
1 .0503
3 .0629
end data.
list. 
       y        n

   11.00      .10
    7.00      .19
    7.00      .08
   19.00      .21
    9.00      .14
    4.00      .05
    3.00      .13
    1.00      .05
    3.00      .06

Number of cases read:  9    Number of cases listed:  9

Table 6.7 and Figure 6.10-6.11, page 164-165

regression
/dependent = y
/method enter = n
/scatter (y, n) (*sresid, n).

Table 6.8 and Figure 6.12, page 165-166. Transforming y to sqrt(y)

compute sqrty = sqrt(y).
exe.
regression
/dependent = sqrty
/method enter = n
/scatter (*sresid, n).

Table 6.9, page 167. Number of Supervised Workers and Supervisors in 27 Industrial Establishments

get file 'D:\p167.sav'.
list.
       x        y

     294       30
     247       32
     267       37
     358       44
     423       47
     311       49
     450       56
     534       62
     438       68
     697       78
     688       80
     630       84
     709       88
     627       97
     615      100
     999      109
    1022      114
    1015      117
     700      106
     850      128
     980      130
    1025      160
    1021       97
    1200      180
    1250      112
    1500      210
    1650      135

Number of cases read:  27    Number of cases listed:  27

Table 6.10 and Figure 6.13-6.14, page 167-168

regression
/dependent = y
/method enter = x
/scatter (y, x) (*sresid, x).

Table 6.11 and Figure 6.15, page 169. Removal of heteroscedasticity by transforming y by y/x and x by 1/x.  This transformation eliminates the linear relation.

NOTE: The R^2 does not match the book and the extra graph of y/x versus 1/x reveals this phenomena.

compute yx = y/x.
compute x1 = 1/x.
exe.
regression
/dependent = yx
/method enter = x1
/scatter (*sresid, x1) (yx, x1).

Table 6.12 and Figure 6.16-6.17, page 171

compute lny = ln(y).
exe.
regression
/dependent = lny
/method enter = x
/scatter (lny, x) (*sresid, x).

Table 6.13 and Figure 6.18-6.20, page 172-173. LnY is regressed on X and X^2

compute x2 = x**2.
exe.
regression
/dependent = lny
/method enter = x x2
/scatter (*sresid, *pred) (*sresid, x) (*sresid, x2).

Figure 6.21, page 175. The brain data: Scatter plots of Brain Weight versus Body Weight

get file 'D:\p176.sav'.
graph
 /scatter = bodyweig with brainwei.

Power transformations, page 175

compute y1 = brainwei**.5. 
compute y2 = ln(brainwei). 
compute y3 = brainwei**-.5. 
compute y4 = brainwei**-1. 
compute x1 = bodyweig**.5.
compute x2 = ln(bodyweig).
compute x3 = bodyweig**-.5.
compute x4 = bodyweig**-1.
exe.

Figure 6.21, page 175

graph
 /scatterplot = x1 with y1.

graph
 /scatterplot = x2 with y2.

graph
 /scatterplot = x3 with y3.

graph
 /scatterplot = x4 with y4.


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