Computing bovee_bia6_inppt01Transformations
-
Upload
henry-duna -
Category
Documents
-
view
214 -
download
0
Transcript of Computing bovee_bia6_inppt01Transformations
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
1/31
SW388R7
Data Analysis &
Computers II
Slide 1
Computing Transformations
Transforming variales
Transformations for normality
Transformations for linearity
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
2/31
ters II
Slide 2Transforming variales to satisfy assumptions
W!en a metri" variale fails to satisfy t!eassumption of normality# !omogeneity of varian"e# or
linearity# $e may e ale to "orre"t t!e defi"ien"y
y using a transformation%
We $ill "onsider t!ree transformations for normality#
!omogeneity of varian"e# and linearity t!e logarit!mi" transformation
t!e s'uare root transformation# and t!e inverse transformation
plus a fourt! t!at is useful for prolems of linearity
t!e s'uare transformation
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
3/31
ters II
Slide 3Computing transformations in S(SS
In S(SS# transformations are otained y "omputing ane$ variale% S(SS fun"tions are availale for t!elogarit!mi" )*+1,- and s'uare root )S.RT-transformations% T!e inverse transformation uses aformula $!i"! divides one y t!e original value forea"! "ase%
/or ea"! of t!ese "al"ulations# t!ere may e datavalues $!i"! are not mat!emati"ally permissile%
/or e0ample# t!e log of ero is not definedmat!emati"ally# division y ero is not permitted#and t!e s'uare root of a negative numer results inan 2imaginary value% We $ill usually ad4ust t!evalues passed to t!e fun"tion to ma5e "ertain t!at
t!ese illegal operations do not o""ur%
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
4/31
ters II
Slide 4T$o forms for "omputing transformations
T!ere are t$o forms for ea"! of t!e transformationsto indu"e normality# depending on $!et!er t!e
distriution is s5e$ed negatively to t!e left or
s5e$ed positively to t!e rig!t%
6ot! forms use t!e same S(SS fun"tions and formula
to "al"ulate t!e transformations%
T!e t$o forms differ in t!e value or argument passed
to t!e fun"tions and formula% T!e argument to t!e
fun"tions is an ad4ustment to t!e original value of
t!e variale to ma5e "ertain t!at all of t!e
"al"ulations are mat!emati"ally "orre"t%
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
5/31
ters II
Slide 5/un"tions and formulas for transformations
Symoli"ally# if $e let 0 stand for t!e argumentpasses to t!e fun"tion or formula# t!e "al"ulations for
t!e transformations are
*ogarit!mi" transformation "ompute log *+1,)0-
S'uare root transformation "ompute s'rt
S.RT)0-
Inverse transformation "ompute inv 1 )0-
S'uare transformation "ompute s9 0 : 0
/or all transformations# t!e argument must e greater
t!an ero to guarantee t!at t!e "al"ulations are
mat!emati"ally legitimate%
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
6/31
ters II
Slide 6Transformation of positively s5e$ed variales
/or positively s5e$ed variales# t!e argument is anad4ustment to t!e original value ased on t!e
minimum value for t!e variale%
If t!e minimum value for a variale is ero# t!ead4ustment re'uires t!at $e add one to ea"! value#
e%g% 0 ; 1%
If t!e minimum value for a variale is a negative
numer )e%g%#
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
7/31
ters II
Slide 7>0ample of positively s5e$ed variale
Suppose our dataset "ontains t!e numer of oo5s
read )oo5s- for ? su4e"ts 1# 3# ,# ?# and 9# and t!e
distriution is positively s5e$ed%
T!e minimum value for t!e variale oo5s is ,% T!e
ad4ustment for ea"! "ase is oo5s ; 1%
T!e transformations $ould e "al"ulated as follo$s Compute log6oo5s *+1,)oo5s ; 1-
Compute s'r6oo5s S.RT)oo5s ; 1-
Compute inv6oo5s 1 )oo5s ; 1-
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
8/31
ters II
Slide 8Transformation of negatively s5e$ed variales
If t!e distriution of a variale is negatively s5e$ed#
t!e ad4ustment of t!e values reverses# or refle"ts#
t!e distriution so t!at it e"omes positively s5e$ed%
T!e transformations are t!en "omputed on t!e
values in t!e positively s5e$ed distriution%
Refle"tion is "omputed y sutra"ting all of t!e
values for a variale from one plus t!e asolute
value of ma0imum value for t!e variale% T!is resultsin a positively s5e$ed distriution $it! all values
larger t!an ero%
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
9/31
ters II
Slide 9>0ample of negatively s5e$ed variale
Suppose our dataset "ontains t!e numer of oo5s
read )oo5s- for ? su4e"ts 1# 3# ,# ?# and 9# and t!e
distriution is negatively s5e$ed%
T!e ma0imum value for t!e variale oo5s is ?% T!e
ad4ustment for ea"! "ase is = @ oo5s%
T!e transformations $ould e "al"ulated as follo$s Compute log6oo5s *+1,)= @ oo5s-
Compute s'r6oo5s S.RT)= @ oo5s-
Compute inv6oo5s 1 )= @ oo5s-
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
10/31
Slide
!T!e S'uare Transformation for *inearity
T!e s'uare transformation is "omputed ymultiplying t!e value for t!e variale y itself%
It does not matter $!et!er t!e distriution ispositively or negatively s5e$ed%
It does matter if t!e variale !as negative values#sin"e $e $ould not e ale to distinguis! t!eir
s'uares from t!e s'uare of a "omparale positivevalue )e%g% t!e s'uare of @ is e'ual to t!e s'uare of;-% If t!e variale !as negative values# $e add t!easolute value of t!e minimum value to ea"! s"oreefore s'uaring it%
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
11/31
Slide
>0ample of t!e s'uare transformation
Suppose our dataset "ontains "!ange s"ores )"!g- for
? su4e"ts t!at indi"ate t!e differen"e et$een test
s"ores at t!e end of a semester and test s"ores at
mid@term @1,# ,# 1,# 9,# and 3,%
T!e minimum s"ore is @1,% T!e asolute value of t!e
minimum s"ore is 1,%
T!e transformation $ould e "al"ulated as follo$s
Compute s'uarC!g )"!g ; 1,- : )"!g ; 1,-
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
12/31
Slide
2
Normal Q-Q Plot of TOTAL TIME SPENT ON TH
Observed Value
121!"#2-2-#
E$%e&tedNormal
'
2
1
-1
-2
-'
Transformations for normality
TOTAL TIME SPENT ON THE INTERNET
1(
)(
!(
*(
"(
+(
#(
'(
2(
1(
(
H,sto-ram
.re/ue0&1
+
#
'
2
1
Std( ev 3 1+('+
Mea0 3 1(*
N 3 )'(
Both the histogram and the normality plot for TotalTime Spent on the Internet(netime) indicate that thevariable is not normally distributed.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
13/31
Slide
3
Descriptives
1(*' 1(+)
*(+*
1'(!)
!(2)
+(+
2'+("++1+('+
12
12
1(2
'(+'2 (2+
1+("1# (#)+
Mea0
Lo4er 5ou0d
6%%er 5ou0d
)+7 8o0f,de0&e
I0terval for Mea0
+7 Tr,mmed Mea0
Med,a0
Var,a0&eStd( ev,at,o0
M,0,mum
Ma$,mum
Ra0e
I0ter/uart,le Ra0e
S9e40ess
:urtos,s
TOTAL TIME SPENT
ON THE INTERNET
Stat,st,& Std( Error
Determine $!et!er refle"tion is re'uired
Skewness, in the table of Descriptive Statistics,indicates whether or not reflection (reversing thevalues) is required in the transformation.
f Skewness is positive, as it is in this problem,reflection is not required. f Skewness is negative,reflection is required.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
14/31
Slide
4
Descriptives
1(*' 1(+)
*(+*
1'(!)
!(2)
+(+
2'+("++1+('+
12
12
1(2
'(+'2 (2+
1+("1# (#)+
Mea0
Lo4er 5ou0d
6%%er 5ou0d
)+7 8o0f,de0&e
I0terval for Mea0
+7 Tr,mmed Mea0
Med,a0
Var,a0&e
Std( ev,at,o0
M,0,mum
Ma$,mum
Ra0e
I0ter/uart,le Ra0e
S9e40ess
:urtos,s
TOTAL TIME SPENT
ON THE INTERNET
Stat,st,& Std( Error
Compute t!e ad4ustment to t!e argument
n this problem, the minimum value is !, so " will beadded to each value in the formula, i.e. the argumentto the S#SS functions and formula for the inverse willbe$
netime + 1.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
15/31
Slide
5Computing t!e logarit!mi" transformation
%o compute the transformation,select the Compute& commandfrom the Transformmenu.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
16/31
Slide
6
Spe"ifying t!e transform variale name andfun"tion
First, in the Target Variablete't bo', type aname for the log transformation variable, e.g.lgnetime.
Second, scroll down the list of functions tofind *"!, which calculates logarithmicvalues use a base of "!. (%he logarithmicvalues are the power to which "! is raisedto produce the original number.)
Third, clickon the up
arrow buttonto move thehighlightedfunction tothe +umeric'pressionte't bo'.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
17/31
Slide
7Adding t!e variale name to t!e fun"tion
First, scroll down the list ofvariables to locate thevariable we want totransform. -lick on its nameso that it is highlighted.
Second, click on the right arrowbutton. S#SS will replace thehighlighted te't in the function
() with the name of the variable.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
18/31
Slide
8Adding t!e "onstant to t!e fun"tion
/ollowing the rules stated for determining the constantthat needs to be included in the function either toprevent mathematical errors, or to do reflection, weinclude the constant in the function argument. n thiscase, we add " to the netime variable.
-lick on the 01button to completethe computerequest.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
19/31
Slide
9T!e transformed variale
%he transformed variable which we
requested S#SS compute is shown in thedata editor in a column to the right of theother variables in the dataset.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
20/31
Slide
2!Computing t!e s'uare root transformation
%o compute the transformation,select the Compute& commandfrom the Transformmenu.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
21/31
Slide
2
Spe"ifying t!e transform variale name andfun"tion
First, in the Target Variablete't bo', type aname for the square root transformationvariable, e.g. sqnetime.
Second, scroll down the list of functions tofind S23%, which calculates the square rootof a variable.
Third, clickon the uparrow button
to move thehighlightedfunction tothe +umeric'pressionte't bo'.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
22/31
Slide
22Adding t!e variale name to t!e fun"tion
Second, click on the right arrowbutton. S#SS will replace the
highlighted te't in the function() with the name of the variable.
First, scroll down the list ofvariables to locate thevariable we want totransform. -lick on its nameso that it is highlighted.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
23/31
Slide
23Adding t!e "onstant to t!e fun"tion
/ollowing the rules stated for determining the constantthat needs to be included in the function either toprevent mathematical errors, or to do reflection, weinclude the constant in the function argument. n thiscase, we add " to the netime variable.
-lick on the 01button to completethe computerequest.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
24/31
Slide
24T!e transformed variale
%he transformed variable which werequested S#SS compute is shown in thedata editor in a column to the right of theother variables in the dataset.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
25/31
Slide
25Computing t!e inverse transformation
%o compute the transformation,select the Compute& commandfrom the Transformmenu.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
26/31
Slide
26
Spe"ifying t!e transform variale name andformula
First, in the TargetVariablete't bo', type aname for the inversetransformation variable,e.g. innetime.
Second, there is not a function forcomputing the inverse, so we typethe formula directly into theNumeric Expressionte't bo'.
Third, click on theOKbutton tocomplete thecompute request.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
27/31
Slide
27T!e transformed variale
%he transformed variable which we
requested S#SS compute is shown in thedata editor in a column to the right of theother variables in the dataset.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
28/31
Slide
28
Descriptives
1(*' 1(+)
*(+*
1'(!)
!(2)
+(+
2'+("++
1+('+
12
12
1(2
'(+'2 (2+
1+("1# (#)+
Mea0
Lo4er 5ou0d
6%%er 5ou0d
)+7 8o0f,de0&e
I0terval for Mea0
+7 Tr,mmed Mea0
Med,a0
Var,a0&e
Std( ev,at,o0
M,0,mum
Ma$,mum
Ra0e
I0ter/uart,le Ra0e
S9e40ess
:urtos,s
TOTAL TIME SPENTON THE INTERNET
Stat ,st,& Std( Error
Ad4ustment to t!e argument for t!e s'uaretransformation
n this problem, the minimum value is !, no ad4ustmentis needed for computing the square. f the minimumwas a number less than 5ero, we would add theabsolute value of the minimum (dropping the sign) asan ad4ustment to the variable.
t is mathematically correct to square a value of 5ero, so thead4ustment to the argument for the square transformation isdifferent. 6hat we need to avoid are negative numbers,since the square of a negative number produces the samevalue as the square of a positive number.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
29/31
Slide
29Computing t!e s'uare transformation
%o compute the transformation,
select the Compute& commandfrom the Transformmenu.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
30/31
Slide
3!
Spe"ifying t!e transform variale name andformula
First, in the TargetVariablete't bo', type aname for the inversetransformation variable,e.g. s7netime.
Second, there is not a function forcomputing the square, so we typethe formula directly into theNumeric Expressionte't bo'.
Third, click on theOKbutton tocomplete thecompute request.
-
7/26/2019 Computing bovee_bia6_inppt01Transformations
31/31
Slide
3T!e transformed variale
%he transformed variable which werequested S#SS compute is shown in thedata editor in a column to the right of theother variables in the dataset.