Discussion:
Box-cox transformation
(too old to reply)
ftr public
2018-01-15 16:18:06 UTC
Permalink
Hello,
I did not find a function that produces a Box-Cox transformation in
PSPP. On Raynald's SPSS macro pages a SPSS macro with syntax
<http://www.spsstools.net/en/syntax/syntax-index/compute/box-cox-transformation/>
has been published is published that does the job.
* Box-Cox transformation for all 31 values of lambda between -2 to 1
(increments of .1). * Raynald Levesque 2003/11/08. GET FILE='c:\\program
files\\spss\\employee data.sav'. COMPUTE var1=salary. VECTOR lam(31)
/xl(31). LOOP idx=1 TO 31. - COMPUTE lam(idx)=-2.1 + idx * .1. - DO IF
lam(idx)=0. - COMPUTE xl(idx)=LN(var1). - ELSE. - COMPUTE
xl(idx)=(var1**lam(idx) - 1)/lam(idx). - END IF. END LOOP. EXECUTE.

I used the Box-Cox transformation macro
<http://www.spsstools.net/en/syntax/syntax-index/compute/box-cox-transformation/>which
produces a series of values for the variable to be transformed called xl
for values of lambda above -2.1.
The original variables in the test data set, salary, shows a skew of
2.12 and a kurtosis of above 5.

After having run the macro I don't see how to continue. How to decide
which is the best lambda value and thus, the best  transformation?


I  did a frequency of all transformed xl variables to find the
transformed , i.e. xl, variable with the skew and kurtosis the closest
to 0. I also tried to visually find the best transformation.
FREQUENCIES xl1 to xl31
    /FORMAT= NOTABLE
    /STATISTICS=SKEWNESS KURTOSIS.
EXAMINE
VARIABLES= xl1 to xl31
/PLOT= NPPLOT.

Are these the appropriate ways ?
In my view the results show that xl10 and xl11 show a good combination
of skew and kurtosis and are together close to 0.

My questions:
1/ Are there other ways in PSPP to run a box-cox transformation ?
2/ Which is the best way to find the best transformation ?


If not what do you recommend how to decide about the appropriate
transformed variable ?


Thanks in advance,

ftr
ftr public
2018-01-15 18:15:50 UTC
Permalink
Sorry for the mangled page lay-out. I try again to make the macro readable.
-ftr

Hello,
I did not find a function that produces a Box-Cox transformation in
PSPP. On Raynald's SPSS macro pages a SPSS macro with syntax
<http://www.spsstools.net/en/syntax/syntax-index/compute/box-cox-transformation/>
has been published is published that does the job.

* Box-Cox transformation for all 31 values of lambda between -2 to 1
(increments of .1).
* Raynald Levesque 2003/11/08.

GET FILE='c:\\program files\\spss\\employee data.sav'.
 COMPUTE var1=salary.
VECTOR lam(31) /xl(31).
LOOP idx=1 TO 31.
- COMPUTE lam(idx)=-2.1 + idx * .1.
- DO IF lam(idx)=0.
-     COMPUTE xl(idx)=LN(var1).
- ELSE.
-     COMPUTE xl(idx)=(var1**lam(idx) - 1)/lam(idx).
- END IF.
END LOOP.
EXECUTE.

I used this Box-Cox transformation macro
<http://www.spsstools.net/en/syntax/syntax-index/compute/box-cox-transformation/>which
produces a series of values for the variable to be transformed called xl
for values of lambda above -2.1.
The original variable in the test data set, salary, shows a skew of 2.12
and a kurtosis of above 5.

After having run the macro I don't see how to continue. How to decide
which is the best lambda value and thus, the best transformation?

I  then did a frequency of all transformed xl variables to find the
transformed , i.e. xl, variable with the skew and kurtosis the closest
to 0. I also tried to visually find the best transformation.
FREQUENCIES xl1 to xl31
    /FORMAT= NOTABLE
    /STATISTICS=SKEWNESS KURTOSIS.
EXAMINE
VARIABLES= xl1 to xl31
/PLOT= NPPLOT.

I then graphed the skew for each lambda value in a spreadsheet and got
skewness values of close to 0 for lambda around -1.

Are these the appropriate ways ?
In my view the results show that xl10 and xl11 show a good combination
of skew and kurtosis and are together close to 0.

My questions:
1/ Are there other ways in PSPP to run a box-cox transformation ?
2/ Which is the best way to find the best transformation ?


If not what do you recommend how to decide about the appropriate
transformed variable ?


Thanks in advance,

ftr

Continue reading on narkive:
Loading...