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

LAB8_report

This study analyzes the LH time series dataset using ARMA and Holt’s Exponential Smoothing to assess stationarity and model accuracy. The Augmented Dickey-Fuller test indicates the series is borderline stationary, and the auto.arma() function selects an arma(0,0,2) model, which outperforms Holt’s method in terms of RMSE and MAPE. The conclusion emphasizes the importance of model selection based on data characteristics for reliable forecasting.

Uploaded by

dion.ajit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

LAB8_report

This study analyzes the LH time series dataset using ARMA and Holt’s Exponential Smoothing to assess stationarity and model accuracy. The Augmented Dickey-Fuller test indicates the series is borderline stationary, and the auto.arma() function selects an arma(0,0,2) model, which outperforms Holt’s method in terms of RMSE and MAPE. The conclusion emphasizes the importance of model selection based on data characteristics for reliable forecasting.

Uploaded by

dion.ajit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

LAB – 8

ARMA Models

STA - 631

JEREMY MATHEW JOSE


2240217
Introduction
This study focuses on analyzing the LH (Luteinizing Hormone) time series dataset
using statistical techniques in R. The objective is to determine whether the series is
stationary and to model it using ARMA (AutoRegressive Integrated Moving Average)
and Holt’s Exponential Smoothing. The Augmented Dickey-Fuller (ADF) test is
applied to check stationarity, and differencing is used to achieve stationarity if needed.
Model selection is performed using auto.arma(), and forecasting is compared between
ARMA and Holt’s method to evaluate their accuracy.

Objectives:

1. Assess the stationarity of the LH dataset using the ADF test.


2. Apply differencing if necessary to achieve stationarity.
3. Fit an arma model to the time series data using auto.arma().
4. Compare the performance of arma with Holt’s Exponential Smoothing.
5. Evaluate accuracy metrics (such as RMSE, MAE, and MAPE) to
determine the best forecasting model.

CODE:

library(astsa)
library(tseries)

## Registered S3 method overwritten by 'quantmod':


## method from
## as.zoo.data.frame zoo

library(forecast)

##
## Attaching package: 'forecast'

## The following object is masked from 'package:astsa':


##
## gas

data("lh")
ts_data <- lh
plot(ts_data, main="Time Series Plot of LH Data",
ylab="Hormone Level", xlab="Time", col="blue", type="o")
# Stationarity Analysis Using ADF Test
adf_test_result <- adf.test(ts_data)
print(adf_test_result)

##
## Augmented Dickey-Fuller Test
##
## data: ts_data
## Dickey-Fuller = -3.558, Lag order = 3, p-
value = 0.04624 ## alternative hypothesis:
stationary
#INFERENCE:

## Since the p-value is slightly below 0.05, the null hypothesis of


non-stationarity is rejected at the 5% level, but the series is
borderline stationary.
diff_ts <- diff(ts_data)
adf_diff_test <- adf.test(diff_ts)
## Warning in adf.test(diff_ts): p-value smaller than

printed p-value print(adf_diff_test)

##
## Augmented Dickey-Fuller Test
##
## data: diff_ts
## Dickey-Fuller = -4.6042, Lag order = 3, p-
value = 0.01 ## alternative hypothesis:
stationary
#INFERENCE:

## Differencing confirms strong stationarity, meaning the


original series exhibits some trend or seasonality.

plot(diff_ts, main="Differenced LH Data", ylab="Differenced


Hormone Level", xlab="Time", col="red", type="o")

# Model Selection Using auto.arma()


auto_fit <- auto.arma(ts_data, seasonal=FALSE,
approximation=FALSE, stepwise=FALSE)
summary(auto_fit)

## Series: ts_data
## arma(0,0,2) with non-zero mean
##
## Coefficients:
## ma1 ma2 mean
## 0.6732 0.3753 2.4016
## s.e. 0.1326 0.1291 0.1244
##
## sigma^2 = 0.1943: log likelihood = -27.53
## AIC=63.06 AICc=63.99 BIC=70.55
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ## Training set 2.994756e-05
0.426814 0.3267262 -3.358918 14.29451 0.9086468 ## ACF1
## Training set 0.02045045

#INFERENCE:
## The auto.arma() function selected an arma(0,0,2) model:
## - 0 AR terms (no autoregressive component).
## - 0 differencing (model was fitted on original series without differencing).
## - 2 MA terms (relying on past error terms for forecasting).
## Estimated Parameters:
## - MA(1) coefficient = 0.6732 (SE = 0.1326)
## - MA(2) coefficient = 0.3753 (SE = 0.1291)
## - Mean = 2.4016 (SE = 0.1244)
## - AIC = 63.06, BIC = 70.55, indicating a good fit with low complexity.

checkresiduals(auto_fit)
##
## Ljung-Box test
##
## data: Residuals from arma(0,0,2) with non-
zero mean ## Q* = 4.0871, df = 8, p-value =
0.8492
##
## Model df: 2. Total lags used: 10

#INFERENCE:
## Ljung-Box test result:
## - Q-statistic = 4.0871, p-value = 0.8492
## - Residuals do not show significant autocorrelation, confirming that the model captures the
variability adequately.
holt_fit <- holt(ts_data, h=3)
summary(holt_fit)

##
## Forecast method: Holt's method
##
## Model Information:
## Holt's method
##
## Call:
## holt(y = ts_data, h = 3)
##
## Smoothing parameters:
## alpha = 0.9443
## beta = 1e-04
##
## Initial states:
## l = 2.3886
## b = 0.0108
##
## sigma: 0.5192
##
## AIC AICc BIC
## 128.7075 130.1361 138.0635
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ## Training set 7.997787e-05
0.4970503 0.3637899 -2.294006 15.15648 1.011724 ## ACF1
## Training set 0.007337923
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 49 2.917989 2.252669 3.583310 1.900470 3.935509
## 50 2.928745 2.013646 3.843844 1.529221 4.328269
## 51 2.939501 1.829435 4.049567 1.241801 4.637200

#INFERENCE:
## Holt’s smoothing parameters:
## - Alpha (level smoothing) = 0.9443 → Suggests strong responsiveness to recent observations.
## - Beta (trend smoothing) = 0.0001 → Indicates a very weak trend component.
## - Initial Level = 2.3886, Initial Slope = 0.0108
## - AIC = 128.71, significantly higher than arma’s AIC (63.06), meaning it is a worse fit to the
data.
plot(holt_fit, main="Holt's Exponential Smoothing

Forecast")

accuracy_arma <- accuracy(auto_fit)


accuracy_holt <- accuracy(holt_fit)

print("arma Model Accuracy:")

## [1] "arma Model Accuracy:"


print(accuracy_arma)

## ME RMSE MAE MPE MAPE MASE ## Training set 2.994756e-05


0.426814 0.3267262 -3.358918 14.29451 0.9086468 ## ACF1
## Training set 0.02045045

print("Holt's Method Accuracy:")

## [1] "Holt's Method Accuracy:"

print(accuracy_holt)
## ME RMSE MAE MPE MAPE MASE ## Training set 7.997787e-05
0.4970503 0.3637899 -2.294006 15.15648 1.011724 ## ACF1
## Training set 0.007337923

#INFERENCE:

## RMSE and MAE Comparison:


## Model | RMSE | MAE | MAPE (%)
## arma(0,0,2) | 0.4268 | 0.3267 | 14.29
## Holt’s Method | 0.4970 | 0.3638 | 15.16
## - The arma model has a lower RMSE (0.4268 vs. 0.4970), indicating better precision.
## - MAPE for arma (14.29%) is lower than Holt’s (15.16%), confirming arma’s superiority.
## - Holt’s method performs relatively well but struggles with capturing short-term fluctuations.

Conclusion:

Time series analysis is essential for identifying patterns and making reliable forecasts in
various fields. Ensuring stationarity is a key step, often achieved through differencing and
statistical tests like the ADF test. Forecasting models such as arma and Exponential
Smoothing are widely used,
with arma capturing autocorrelation structures and smoothing methods emphasizing
recent trends. Model performance is evaluated using metrics like RMSE and MAPE,
while residual diagnostics ensure proper model fit. Ultimately, selecting the right
model depends on the data's characteristics, ensuring accurate and meaningful
predictions for informed decision-making.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy