turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- inverse of log-ratio transformation

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-23-2017 07:45 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eemrun

11-23-2017 07:54 PM - edited 11-23-2017 07:54 PM

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?

All Replies

Solution

11-28-2017
08:03 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eemrun

11-23-2017 07:54 PM - edited 11-23-2017 07:54 PM

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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

11-28-2017 08:03 PM

thanks! that worked perfectly.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eemrun

11-23-2017 11:46 PM

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