Post on 03-Jun-2018
transcript
8/12/2019 Computing Transformations in SPSS
1/32
Summary made by: Gernimo Maldonado-MartnezBiostatistician
Data Management & Statistical Research Support Unit
Universidad Central del Caribe
8/12/2019 Computing Transformations in SPSS
2/32
Transforming variablesTransformations for normalityTransformations for linearity
8/12/2019 Computing Transformations in SPSS
3/32
When a metric variable fails to satisfy theassumption of normality, homogeneity ofvariance, or linearity, we may be able to correctthe deficiency by using a transformation.
We will consider three transformations fornormality, homogeneity of variance, andlinearity:
the logarithmic transformation
the square root transformation the inverse transformation
plus a fourth that is useful for problems oflinearity:
the square transformation
8/12/2019 Computing Transformations in SPSS
4/32
SPSS functions are available for the logarithmic(LG10) and square root (SQRT) transformations. The multiplicative inverse transformation uses a
formula which divides one by the original value foreach case. (1/x)
Sometimes there may be data values which arenot mathematically permissible. For example:
the log of zero is not defined mathematically division by zero is not permitted square root of a negative number results in an
imaginary value. We will usually adjust the values passed to the
function to make certain that these illegaloperations do not occur.
8/12/2019 Computing Transformations in SPSS
5/32
There are two forms for each of thetransformations to induce normality, dependingon whether the distribution is skewednegatively to the left or skewed positively to theright.
Both forms use the same SPSS functions andformula to calculate the transformations.
The two forms differ in the value or argumentpassed to the functions and formula. The argument to the functions is an adjustment
to the original value of the variable to makecertain that all of the calculations aremathematically correct.
8/12/2019 Computing Transformations in SPSS
6/32
Symbolically, if we let stand for the argumentpasses to the function or formula, thecalculations for the transformations are:
Logarithmic transformation: compute log = LG10(x) Square root transformation: compute sqrt =
SQRT(x) Inverse transformation: compute inv = 1 / (x) Square transformation: compute s2 = x * x
For all transformations, the argument must begreater than zero to guarantee that thecalculations are mathematically legitimate .
8/12/2019 Computing Transformations in SPSS
7/32
For positively skewed variables: The argument is an adjustment to the original value based
on the minimum value for the variable .
If the minimum value for a variable is zero, the
adjustment requires that we add one to each value, (x +1).
If the minimum value for a variable is a negative number(e.g., -6)
The adjustment requires that we add the absolute value of
the minimum value (e.g. 6) plus one (e.g. x + 6 + 1, whichequals x +7)
Elongated tail @ the R.More data in the R tail
than would be expectedin a Gaussian distribution
8/12/2019 Computing Transformations in SPSS
8/32
Suppose our dataset contains the number ofbooks read (books) for 5 subjects: 1, 3, 0, 5,and 2, and the distribution is positivelyskewed.
The minimum value for the variable books is0. The adjustment for each case is books + 1.
The transformations would be calculated asfollows:
Compute logBooks = LG10(books + 1) Compute sqrBooks = SQRT(books + 1) Compute invBooks = 1 / (books + 1)
8/12/2019 Computing Transformations in SPSS
9/32
For negatively skewed variables: The adjustment of the values reverses, or reflects, thedistribution so that it becomes positively skewed.
The transformations are then computed on the values in thepositively skewed distribution.
Reflection is computed by subtracting all of the values fora variable from one plus the absolute value of maximumvalue for the variable.
This results in a positively skewed distribution with allvalues larger than zero.
Elongated tail @ the L.More data in the L tail
than would be expectedin a Gaussian distribution
8/12/2019 Computing Transformations in SPSS
10/32
Suppose our dataset contains the number ofbooks read (books) for 5 subjects: 1, 3, 0, 5,and 2, and the distribution is negativelyskewed.
The maximum value for the variable books is5. The adjustment for each case is 6 - books.
The transformations would be calculated asfollows:
Compute logBooks = LG10(6 - books) Compute sqrBooks = SQRT(6 - books) Compute invBooks = 1 / (6 - books)
8/12/2019 Computing Transformations in SPSS
11/32
The square transformation is computed bymultiplying the value for the variable byitself.
It does not matter whether the distribution ispositively or negatively skewed.
It does matter if the variable has negativevalues, since we would not be able todistinguish their squares from the square of a
comparable positive value (e.g. the square of-4 is equal to the square of +4). If the variable has negative values, we add the
absolute value of the minimum value to eachscore before squaring it.
8/12/2019 Computing Transformations in SPSS
12/32
Suppose our dataset contains change scores(chg) for 5 subjects that indicate thedifference between test scores at the end ofa semester and test scores at mid-term: -10,0, 10, 20, and 30.
The minimum score is -10. The absolutevalue of the minimum score is 10.
The transformation would be calculated asfollows: Compute squarChg = (chg + 10) * (chg + 10)
8/12/2019 Computing Transformations in SPSS
13/32
Normal Q-Q Plot of TOTAL TIME SPENT ON TH
Observed Value
120100806040200-20-40
3
2
1
0
-1
-2
-3
TOTAL TIME SPENT ON THE INTERNET
100.090.0
80.070.0
60.050.0
40.030.0
20.010.0
0.0
Histogram50
40
30
20
10
0
Std. Dev = 15.35
Mean = 10.7
N = 93.00
Both the histogram andthe normality plot for
Total Time Spent on theInternet (netime) indicate
that the variable is notnormally distributed.
8/12/2019 Computing Transformations in SPSS
14/32
Skewness, in the table of Descriptive Statistics,
indicates whether or not reflection (reversing thevalues) is required in the transformation.
If Skewness is positive, as it is in this problem,reflection is not required. If Skewness is negative,
reflection is required .
8/12/2019 Computing Transformations in SPSS
15/32
In this problem, the minimum value is 0, so 1will be added to each value in the formula, i.e.
the argument to the SPSS functions and formulafor the inverse will be: netime + 1.
8/12/2019 Computing Transformations in SPSS
16/32
To compute thetransformation, select theCompute command from
the Transform menu.
8/12/2019 Computing Transformations in SPSS
17/32
First , in the Target Variable
text box, type a name forthe log transformation
variable, e.g. lgnetime .
Second , scroll down the list of functions to findLG10, which calculates logarithmic values use a
base of 10. (The logarithmic values are thepower to which 10 is raised to produce the
original number.)
Third , click onthe up arrow
button tomove the
highlightedfunction to
the NumericExpressiontext box.
8/12/2019 Computing Transformations in SPSS
18/32
First , scroll down the list ofvariables to locate the
variable we want totransform. Click on its name
so that it is highlighted.
Second , click on the right arrowbutton. SPSS will replace the
highlighted text in the function(?) with the name of the variable.
8/12/2019 Computing Transformations in SPSS
19/32
Following the rules stated for determiningthe constant that needs to be included in the
function either to prevent mathematicalerrors, or to do reflection, we include theconstant in the function argument. In this
case, we add 1 to the netime variable.
Click on the OKbutton to
complete thecompute request.
8/12/2019 Computing Transformations in SPSS
20/32
The transformed variable whichwe requested SPSS compute isshown in the data editor in a
column to the right of theother variables in the dataset.
8/12/2019 Computing Transformations in SPSS
21/32
To compute thetransformation, select theCompute command from
the Transform menu.
8/12/2019 Computing Transformations in SPSS
22/32
First , in the TargetVariable text box, type a
name for the squareroot transformation
variable, e.g.sqnetime.
Second , scroll down thelist of functions to findSQRT, which calculates
the square root of avariable.
Third , click onthe up arrow
button to movethe highlightedfunction to the
Numeric
Expression textbox.
8/12/2019 Computing Transformations in SPSS
23/32
Second , click on theright arrow button.
SPSS will replace thehighlighted text in thefunction (?) with thename of the variable.
First , scroll down the listof variables to locate
the variable we want totransform. Click on its
name so that it ishighlighted.
8/12/2019 Computing Transformations in SPSS
24/32
Following the rules stated for determining the
constant that needs to be included in the functioneither to prevent mathematical errors, or to do
reflection, we include the constant in the functionargument. In this case, we add 1 to the netime
variable.
Click on theOK button tocomplete the
computerequest.
8/12/2019 Computing Transformations in SPSS
25/32
8/12/2019 Computing Transformations in SPSS
26/32
To compute thetransformation,
select theCompute
command fromthe Transform
menu.
8/12/2019 Computing Transformations in SPSS
27/32
First , in theTarget Variable text box, type a
name for theinverse
transformationvariable, e.g.innetime.
Second , there is not afunction for computing the
inverse, so we type theformula directly into the
Numeric Expression text box.
Third , click on
the OK buttonto completethe compute
request.
8/12/2019 Computing Transformations in SPSS
28/32
The transformed variable which werequested SPSS compute is shown in
the data editor in a column to theright of the other variables in the
dataset.
8/12/2019 Computing Transformations in SPSS
29/32
In this problem, the minimum value is 0,no adjustment is needed for computing
the square. If the minimum was a numberless than zero, we would add the absolutevalue of the minimum (dropping the sign)
as an adjustment to the variable.
It is mathematically correct to square a value of zero, so theadjustment to the argument for the square transformation is
different. What we need to avoid are negative numbers,since the square of a negative number produces the same
value as the square of a positive number.
8/12/2019 Computing Transformations in SPSS
30/32
To compute thetransformation, select
the Compute commandfrom the Transform
menu.
8/12/2019 Computing Transformations in SPSS
31/32
First , in the Target Variable text box, type a name for
the inverse transformationvariable, e.g. s2netime.
Second , there is not a functionfor computing the square, sowe type the formula directlyinto the Numeric Expression
text box.
Third , click onthe OK buttonto completethe compute
request.
8/12/2019 Computing Transformations in SPSS
32/32
The transformed variablewhich we requested SPSS
compute is shown in the dataeditor in a column to the rightof the other variables in the
dataset.