R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

``` # 1 install.packages(“seastests”) install.packages(“readxl”) library(seastests) library(readxl) library(forecast)

Load data

data <- read_excel(“C:/Users/Rafael A.M.Marpaung/Downloads/forecast.xlsx”) head(data)

time_series <- ts(data$rate, start = c(2020, 1), frequency = 144) plot(time_series, main = “Time Series Data”, xlab = “Time”, ylab = “Rate”) time_series <- isSeasonal(time_series) time_series

2

install.packages(“forecast”) install.packages(“tseries”) install.packages(“nortest”) install.packages(“dgof”)

library(forecast) library(tseries) library(nortest) library(dgof)

Earyl modeling with ARIMA

box_test <- Box.test(fit$residuals, lag = 144, type = “Ljung-Box”) print(box_test)

shapiro_test <- shapiro.test(fit$residuals) print(shapiro_test)

ad_test <- ad.test(fit$residuals) print(ad_test)

Residual Diagnostic

residuals <- residuals(fit)

White noise assumption

Box.test(residuals, lag = 10, type = “Ljung-Box”)

Residual normality

ks.test(residuals, “pnorm”, mean = mean(residuals), sd = sd(residuals)) ad.test(residuals) shapiro.test(residuals)

#3 sarima_model <- arima(time_series, order = c(2, 1, 1), seasonal = list(order = c(1, 0, 1), period = 144)) # Fit ARIMA model fit <- auto.arima(data$rate, seasonal = TRUE) summary(sarima_model)

Forecast with the new model

forecast_new <- forecast(fit, h = 144) print(forecast_new)

Result comparison with the previous model

accuracy(forecast_new) print(forecast_new) plot(forecast_new)