Siga Odev 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

IST 4002 – ZAMAN SERİLERİ ANALİZİ

ÖDEV 3

İSLİM NUR SIĞA – 200410049


SİNEM ÖKSÜZ – 200410075
AYŞE NUR ERTÜRK – 200410043
NECATİ CAN DEMİR - 200410040
SORU 1

install.packages("readxl")

library(readxl)

data <- read_excel("data.xlsx")

zaman_serisi <- ts(data$time, frequency = 12) # Frekansı verinin durumuna göre ayarlayın

fit <- stl(zaman_serisi, s.window = "periodic", t.window = 12)

plot(fit)

ÇIKTI 1

SORU 2-A

if (!requireNamespace("readxl", quietly = TRUE)) install.packages("readxl")

if (!requireNamespace("forecast", quietly = TRUE)) install.packages("forecast")

if (!requireNamespace("ggplot2", quietly = TRUE)) install.packages("ggplot2")


library(readxl)

library(forecast)

library(ggplot2)

data <- read_excel("data.xlsx")

time_series <- ts(data$time, frequency = 12)

hw_model <- HoltWinters(time_series, alpha = 0.2, beta = 0.2, gamma = 0.3)

original_series <- time_series

smoothed_series <- fitted(hw_model)

time_length <- length(time_series)

smoothed_length <- length(smoothed_series[, "xhat"])

df <- data.frame(

Time = time(time_series)[1:smoothed_length],

Original = as.numeric(original_series[1:smoothed_length]),

Smoothed = as.numeric(smoothed_series[, "xhat"])

ggplot(df, aes(x = Time)) +

geom_line(aes(y = Original, color = "Orijinal Seri"), size = 1) +

geom_line(aes(y = Smoothed, color = "Düzgünleştirilmiş Seri"), size = 1) +

scale_color_manual(values = c("Orijinal Seri" = "#FF4040", "Düzgünleştirilmiş Seri" =


"#A2CD5A")) +

labs(title = "Original vs Smoothed Time Series",

x = "Time",

y = "Value",

color = "Seri") +

theme_minimal()
ÇIKTI 2-A

SORU 2-B

if (!requireNamespace("readxl", quietly = TRUE)) install.packages("readxl")

if (!requireNamespace("forecast", quietly = TRUE)) install.packages("forecast")

if (!requireNamespace("ggplot2", quietly = TRUE)) install.packages("ggplot2")

library(readxl)

library(forecast)

library(ggplot2)

data <- read_excel("data.xlsx")

time_series <- ts(data$time, frequency = 12)

hw_model <- HoltWinters(time_series)

original_series <- time_series

smoothed_series <- fitted(hw_model)

time_length <- length(time_series)


smoothed_length <- length(smoothed_series[, "xhat"])

df <- data.frame(

Time = time(time_series)[1:smoothed_length],

Original = as.numeric(original_series[1:smoothed_length]),

Smoothed = as.numeric(smoothed_series[, "xhat"])

ggplot(df, aes(x = Time)) +

geom_line(aes(y = Original, color = "Orijinal Seri"), size = 1) +

geom_line(aes(y = Smoothed, color = "Düzgünleştirilmiş Seri"), size = 1) +

scale_color_manual(values = c("Orijinal Seri" = "#EE7600", "Düzgünleştirilmiş Seri" =


"#CD1076")) +

labs(title = "Holt-Winters Düzgünleştirme (Optimize Edilmiş Parametrelerle)",

x = "Zaman",

y = "Değer",

color = "Seri") +

theme_minimal()

ÇIKTI 2-B

You might also like