Forecasting a Linear model

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Brc
Posts: 18
Joined: Thu Jun 20, 2024 5:16 pm

Forecasting a Linear model

Unread post by Brc »

Hello, I want to forecast the following linear AR model:

DO I=0,20,1
*
LINREG(DEFINE=FOREQ,NOPRINT) Y 1998:1 2019:12+I
# constant Y{1 3 4 5 7 }
***
STEPS(NOPRINT) 1 1 2020:1+I
# FOREQ LF 2020:1+I LFE
*
SET SLFE = LFE**2
STATISTICS(noPRINT) SLFE
COMPUTE RMSE = SQRT(%MEAN)
DISPLAY 'MEAN' %MEAN 'RMSE' RMSE 'I' I
END DO I

*********

However, when I run this code, I got the error message. How can I correct this ?

## SX11. Identifier LF is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>># FOREQ LF <<<<
Is it possible you meant
%L
If the name isn't mistyped, it's possible that you have a poorly formatted instruction
Common errors are
* a space before the ( in an option field
* a missing space before = in a SET or FRML
* a missing $ at the end of a long line which continues to the next



Thank you for your help.
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: Forecasting a Linear model

Unread post by TomDoan »

You would need to do a DECLARE SERIES LF LFE before the loop. (Supplementary cards have to be parsed before their context is understood). However, I think you'll find it easier to use the UFORECAST instruction (which is designed specifically for doing forecasts on single linear equations):

https://estima.com/webhelp/topics/ufore ... ction.html

I'm a bit puzzled about what you're trying to do with the forecast errors. The first time through the loop, you're taking the RMSE of just one forecast error. Is that what you want?

Also:

SET SLFE = LFE**2
STATISTICS(noPRINT) SLFE
COMPUTE RMSE = SQRT(%MEAN)

can be replaced by the use of the SSTATS instruction:

https://estima.com/webhelp/topics/sstat ... ction.html

sstats(mean) / lfe^2>>mse
compute rmse=sqrt(rmse)
Brc
Posts: 18
Joined: Thu Jun 20, 2024 5:16 pm

Re: Forecasting a Linear model

Unread post by Brc »

Thank you for your helps.

I have working on one-step ahead forecast for univariate linear model estimation.

According to your instruction, I rewrite my code as follows:

Is this code correct?

DO I=0,64,1
*
LINREG(DEFINE=FOREQ,NOPRINT) Y 2008:1 2019:12+I
# constant Y{1 2 3 4 5}
***
UFORECAST(EQUATION=FOREQ,STATIC, stderrs=LFE) Linforecast 2020:1 2025:05
*
SET SLFE = LFE**2
STATISTICS(noPRINT) SLFE
COMPUTE RMSE = SQRT(%MEAN)
DISPLAY 'MEAN' %MEAN 'RMSE' RMSE 'I' I
END DO I
*
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: Forecasting a Linear model

Unread post by TomDoan »

You want the ERRORS option on the UFORECAST, not STDERRS.
Post Reply