pspp-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Box-cox transformation


From: ftr public
Subject: Box-cox transformation
Date: Mon, 15 Jan 2018 19:15:50 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

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 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 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]