## How do I do a Box-Cox Transformation?

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.
JohnYork
Posts: 5
Joined: Wed Oct 03, 2012 6:29 am

### How do I do a Box-Cox Transformation?

I am using E-Views 7.

I wish to compare the results for Linear and Non-Linear Equations (the latter having different dependent variables due to the use of logs).

I've been told I need to do a 'Box-Cox' transformation of my data but can only find one reference to Box-Cox transformations in the User Manual (in Data Graphing).

How then do I apply a Box-Cox transformation to my data in E-Views so that I can get comparable r-squareds etc.

Thanks
John

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11298
Joined: Tue Sep 16, 2008 5:38 pm

### Re: How do I do a Box-Cox Transformation?

Code: Select all

`series y_boxcox = (y^a-1)/a`

Where Y is the series you're transforming, and a is the Box-Cox parameter.

EViews Glenn
EViews Developer
Posts: 2531
Joined: Wed Oct 15, 2008 9:17 am

### Re: How do I do a Box-Cox Transformation?

...and of course

Code: Select all

`series y=log(y) `

if a=0 (Gareth only handles the difficult cases )

If you are not sure whether a is zero at the onset of the command and don't want to have to test and then switch between the two formulations, you could use @recode.

Code: Select all

`series y_boxcox=@recode(a=0, log(y), (y^a-1)/a)`

CherifEViews
Posts: 2
Joined: Wed Jun 21, 2017 3:33 pm

### Re: How do I do a Box-Cox Transformation?

Hello,
It's possible to estimate the best value of lamda Box-Cox transformation with "use Spitzer(1982) algorithm diriving from L(lamda)".
First, compute the geometric mean of Y(t), with Y(t)<>0.

Code: Select all

`series gm=@gmean(Y)`

Second, scale Yt by its geometric mean:

Code: Select all

`series z=y/gm`

third, the “trick” simplifies L(λ) considerably. Ignoring constant terms, L(lamda)...
my question is: How can estimate the best lamda value with Spitzer(1982) algorithm or via simple program, honestly i have a difficulty to interpret the third step by LogL.
Could someone help me.
Best Cherif.
Attachments
Box-Cox_step 2 & 3.png (53.33 KiB) Viewed 443 times
Box-Cox_step 1.png (50.12 KiB) Viewed 443 times