DATA Step, Macro, Functions and more

inverse of log-ratio transformation

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

inverse of log-ratio transformation

simple issue driving me nuts!

 

I am trying to do a log-ratio transformation on a variable before regression. The variable is an index (so has values like 450, 560, 1200, etc.). i am doing this in the following way:

 

var1_T = log(var1/lag(var1))

I want to bring the transformed value to its original form. So wanted to do inverse log like:

 

var1_FCT_Orig = exp(var1_T);

Not working. Can anyone tell me where I am doing this wrong?


Accepted Solutions
Solution
‎11-28-2017 08:03 PM
Super User
Posts: 23,267

Re: inverse of log-ratio transformation

[ Edited ]

When answers don't meet your assumptions, check your assumption. 


EXP is the reverse of LOG. 

So it gives you: 

var1 / lag(var1)

 

If you want Var1 then you need to multiple by the lag of VAR1 as well. 

 

var1_t = log(var1 / lag(var1) );

var1_fct_orig = exp(var1_t) * lag(var1);

The question is, do you have the lagged value to work with as well...



eemrun wrote:

simple issue driving me nuts!

 

I am trying to do a log-ratio transformation on a variable before regression. The variable is an index (so has values like 450, 560, 1200, etc.). i am doing this in the following way:

 

var1_T = log(var1/lag(var1))

I want to bring the transformed value to its original form. So wanted to do inverse log like:

 

var1_FCT_Orig = exp(var1_T);

Not working. Can anyone tell me where I am doing this wrong?



View solution in original post


All Replies
Solution
‎11-28-2017 08:03 PM
Super User
Posts: 23,267

Re: inverse of log-ratio transformation

[ Edited ]

When answers don't meet your assumptions, check your assumption. 


EXP is the reverse of LOG. 

So it gives you: 

var1 / lag(var1)

 

If you want Var1 then you need to multiple by the lag of VAR1 as well. 

 

var1_t = log(var1 / lag(var1) );

var1_fct_orig = exp(var1_t) * lag(var1);

The question is, do you have the lagged value to work with as well...



eemrun wrote:

simple issue driving me nuts!

 

I am trying to do a log-ratio transformation on a variable before regression. The variable is an index (so has values like 450, 560, 1200, etc.). i am doing this in the following way:

 

var1_T = log(var1/lag(var1))

I want to bring the transformed value to its original form. So wanted to do inverse log like:

 

var1_FCT_Orig = exp(var1_T);

Not working. Can anyone tell me where I am doing this wrong?



Contributor
Posts: 31

Re: inverse of log-ratio transformation

thanks! that worked perfectly.
Esteemed Advisor
Posts: 5,479

Re: inverse of log-ratio transformation

You have everything you need in the transformed series, except the starting value, Example:

 

title 'Logistic Growth Curve Model of U.S. Population';
data uspop;
   input pop @@;
   retain year 1780;
   year=year+10;
   logPopRatio = log(pop/lag(pop));
   label pop='U.S. Population in Thousands';
   datalines;
3929  5308  7239   9638  12866  17069  23191  31443  39818 50155
62947 75994 91972 105710 122775 131669 151325 179323 203211
226542 248710
;

data usNewPop;
set uspop;
retain lagNewPop;
if _n_ = 1 
    then NewPop = 3929;
    else NewPop = exp(logPopRatio)*lagNewPop;
lagNewPop = NewPop;
drop lagNewPop;
run;

proc print; run;
PG
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 330 views
  • 3 likes
  • 3 in conversation