BookmarkSubscribeRSS Feed
geo_23
Calcite | Level 5

Hi! I've also posted this message to the SAS EG section but I thought that it could be also posted in this section.

I'm new at this, so this may be something really easy that I haven't thought of.

I use the EG Linear regression function to forecast a variable which is actually the Difference of the natural logarithm of Y (let's call this Diff_Ln_Y).

So the output of the regression looks something like this.

Time           Forecast  (Diff_Ln_Y)   

Q1 16          0.056

Q2 16          0.057

...                 ...

...                 ...

...                 ...

Q3 18         0.0598

Q4 18         0.0605

Given that i have the actual (Historic) Y value (and consequently Ln_Y) in Q4 15, what i really need is to find a way that I can automatically obtain forecasted Y as my final output as per the following logic:

Time           Forecast  (Diff_Ln_Y)         Ln_Y                                                 Y  

Q4 15                                                       1.56

Q1 16          0.056                                    1.616 ( 0.056 + 1.56)                       exp(1.616)

Q2 16          0.057                                    1.673 ( 0.057 + 1.616)                     exp(1.673)

...                 ...

...                 ...

...                 ...

Q3 18         0.0598

Q4 18         0.0605

Then same reasoning needs to be repeated up to Q4 18.

Thanks!!

4 REPLIES 4
udo_sas
SAS Employee

Hello -

If you were to use a proper time series technique, such as exponential smoothing, instead of linear regression you don't have to worry about back transforming.

SAS offers the ESM procedure for example (http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#esm_toc.htm), which applies the following logic: "After the time series is transformed, the model parameters are estimated by using the transformed series. The forecasts of the transformed series are then computed, and finally the transformed series forecasts are inverse transformed."

Not sure if this is what you are looking for - but it's worth a try.

Unfortunately EG does not offer a ESM task, but we have added new and more modern forecasting tasks to SAS Studio 3.4, see: http://support.sas.com/documentation/cdl/en/webeditorug/68254/HTML/default/viewer.htm#n0zupbjif1khpg...

Good news is that these forecasting tasks are also available in the SAS University Edition (free SAS software that can be used for teaching and learning statistics and quantitative methods) - see: https://www.sas.com/content/dam/SAS/en_us/doc/factsheet/sas-university-edition-107140.pdf

Thanks,

Udo

geo_23
Calcite | Level 5

Hi udo,

Thanks for your quick response! I will have these alternatives in mind for future use, but I have currently built a logic in EG, so this is why I need a sort of programming code to back transform my depedent variable.

Thanks again!

Ksharp
Super User

I don't understand. Does the following make some sense ?

retain sum 1.56;

sum+Diff_ln_Y;

Y=exp(sum);

geo_23
Calcite | Level 5

Hi Xia Thanks for the reply!

Sorry, maybe i did not explain the whole process from the beginning.

My original Y variable has been transformed, first by taking the natural logarithm of Y and then by first differencing; that is taking the first difference between Ln_Yt and Ln_Yt-1 which comes to the dependent variable I actually forecast in my case (i.e. Diff_Ln_Y), using a simple regression. (The reason I'm doing this is to bring my variables to a stationary state so as to meet some of the requirements of OLS).

Once I perform the forecasts for the period Q1 16 to Q4 18, I need to back trasform this figure to the original Y value.

So for example, for Q1 16 I predict Diff_Ln_Y = 0.056. What I need now is Ln_Y_Q1_16 so as to back transform this to Y using its exponent.

Given that     Diff_Ln_Y_Q1 16 = Ln Y_Q1_16 - Ln Y_Q4_15

=>                 Ln Y_Q1_16 = Diff_Ln_Y_Q1 16 + Ln Y_Q4_15

                     Ln Y_Q1_16 = 0.056 + 1.56 = 1.616

The same procedure needs to be applied for Q2 16 and so on. That is,

Ln Y_Q2_16 = Diff_Ln_Y_Q2 16 + Ln Y_Q1_16 (this is the figure already calculated above)

Ln Y_Q2_16 = 0.057 + 1.616 = 1.673

I hope that this cleared things up a bit more.

Thanks!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1203 views
  • 0 likes
  • 3 in conversation