0% found this document useful (0 votes)
9 views

CODE INTERPRETATION AND RESULTS

The document outlines a comprehensive process for loading, analyzing, and forecasting time series data using Exponential Smoothing and ARIMA models. It includes steps for data preparation, plotting, model fitting, residual analysis, outlier detection, and generating forecasts with confidence intervals. The methodology is applied to retail sales data, with visualizations provided at various stages of the analysis.

Uploaded by

Anh Khoa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CODE INTERPRETATION AND RESULTS

The document outlines a comprehensive process for loading, analyzing, and forecasting time series data using Exponential Smoothing and ARIMA models. It includes steps for data preparation, plotting, model fitting, residual analysis, outlier detection, and generating forecasts with confidence intervals. The methodology is applied to retail sales data, with visualizations provided at various stages of the analysis.

Uploaded by

Anh Khoa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CODE INTERPRETATION AND RESULTS

1. Loading and Preparing Data:

 OPEN DATA "C:\Users\mantr\MRTSSM4482USN.xls": This command opens the Excel


file containing the time series data.
 CALENDAR(M) 1992:1: Defines a monthly calendar starting from January 1992.
 DATA(FORMAT=XLS,NOLABELS,ORG=COLUMNS,TOP=13) 1992:01 2024:09
MRTSSM4482USN<<"1992:01:01" MRTSSM4482USN: Loads the data from the Excel file,
starting from row 13 and assuming no labels in the data.

2. Plotting Data:

 GRAPH(STYLE=LINE) 1 # Z: This line creates a line plot of the data Z.


 compute startdate = 2014:1 and compute enddate = 2024:09: Sets the range of
the data to analyze, from January 2014 to September 2024.
 GRAPH 1 # Z startdate enddate: Plots the data between the defined start and end
date.

Results:

3. Exponential Smoothing (ES):


 ESMOOTH(TREND=SELECT,SEASONAL=SELECT,CONSTRAIN,INITIAL=START,SMOOTHED=SM
O1,FITTED=FIT1,RESIDS=RES1,FACTORS=SEAS1,$ FORECAST=ESFOR1,STEPS=4) Z
2014:01 enddate: This applies the Holt-Winters Exponential Smoothing method to
forecast the next 4 periods, with selected trend and seasonal components.
 ESMOOTH(TREND=SELECT,SEASONAL=SELECT,CONSTRAIN,INITIAL=START,FORECAST=F1
,STEPS=4) Z 2014:01 2020:02: Generates forecasts from January 2014 to February
2020.
 GRAPH(STYLE=LINE) 1 # F1: Plots the forecasted data from the previous step.

Results:

4. Updating Data with Forecasts:

 set z 2020:03 2020:06 = F1: Updates the data from March 2020 to June 2020 with
the forecasted values.

Results:
5. Forecasting with Exponential Smoothing:
 ESMOOTH(TREND=SELECT,SEASONAL=SELECT,CONSTRAIN,INITIAL=START,FORECAST=ES
FORECAST,STEPS=24) Z: Performs Exponential Smoothing forecasting for 24 future
steps.
 GRAPH(STYLE=LINE,HEADER="Retail Sales: Retail Trade and Food
Services",VLABEL="Sales",HLABEL="Time",KEY=ABOVE) # Z s e # ESFORECAST:
Plots the forecasted retail sales data with appropriate axis labels.

Results:

6. Differencing the Data:

 @bjdiff(sdifss=1,diff=1) Z: Seasonal differencing to remove seasonality.


 diff(DIFFS=0,SDIFFS=1) Z / DDSZ: Performs differencing on the data and stores the
results in DDSZ.
 GRAPH 1 # DDSZ startdate enddate: Plots the differenced data.

Results:

7. Model Fitting and Diagnostics:


 @gmautofit(NOCONST,regular=2,seasonal=2,diff=0,sdiffs=1,full,report) Z
startdate enddate: Automatically fits a model to the data using the Generalized
Method of Moments (GMM), with seasonal components, no constant, and a seasonal
differencing step.
 boxjenk(diffs=0,sdiffs=1,noconst,$ ar=1,sar=0,ma=1,sma=1,$
trace,define=eqsarima1) z startdate enddate: Performs the Box-Jenkins
procedure to identify an ARIMA or SARIMA model, defining the model equation as
eqsarima1.

Results:

8. Residual Analysis:

 @regcrits: Likely checks the regression criteria for model diagnostics.


 @bjident %resids startdate enddate: Identifies the residuals from the model.
 @adtest %resids startdate enddate: Conducts the Augmented Dickey-Fuller test on
the residuals to check for stationarity.
Results:

9. Standardized Residuals:

 set stresids startdate enddate = %resids/sqrt(%seesq): Computes the


standardized residuals from the fitted model.
 set upper startdate enddate = 3 and set lower startdate enddate = -3: Sets
the upper and lower bounds for the standardized residuals (typically 3 and -3 for 99%
confidence intervals).
 graph(header="standardized residuals",number=0) 3 # upper startdate
enddate # lower startdate enddate # stresids startdate enddate: Plots the
standardized residuals, including the upper and lower bounds.

Results:

10. Outlier Detection:


 boxjenk(OUTLIERS=STANDARD,diffs=0,sdiffs=1,noconst,$
ar=1,sar=0,ma=1,sma=1,$ trace,define=eqsarima1) z startdate enddate:
Runs the Box-Jenkins procedure again, now specifically for outlier detection.

Results:

11. Final Forecasting and Confidence Intervals:

 compute h = 24: Sets the forecast horizon to 24 periods ahead.


 UFORECAST(FROM=enddate+1, STEPS=h, EQUATION=EQSARIMA1, STDERRS=SE1,
WINDOW="OOS forecasts") FOR1: Uses the fitted SARIMA model (eqsarima1) to
forecast the next 24 periods.
 set up enddate+1 enddate+h = FOR1 + 1.96 * SE1 and set low enddate+1
enddate+h = FOR1 - 1.96 * SE1: Calculates the upper and lower bounds of the
forecast with 95% confidence intervals.
 GRAPH(STYLE=LINE) 4 # Z startdate enddate # FOR1 # UP # LOW: Plots the
original data along with the forecasted values and the confidence intervals.

Results:

You might also like