setwd("C:/Users/user/Desktop/Paskaitos/3 kursas 2 semestras/Prognozavimas")
if (!require(readxl)) install.packages('readxl')
## Įkeliamas reikalingas paketas: readxl
d <- read_excel("Duomenys prognozavimui.xlsx")
if(!require('ggpubr')) install.packages('ggpubr')
## Įkeliamas reikalingas paketas: ggpubr
## Įkeliamas reikalingas paketas: ggplot2
library(ggpubr)
if(!require('forecast')) install.packages('forecast')
## Įkeliamas reikalingas paketas: forecast
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
##
## Pridedamas paketas: 'forecast'
## Šis objektas yra užmaskuotas nuo 'package:ggpubr':
##
## gghistogram
library(forecast)
if(!require('ggplot2')) install.packages('ggplot2')
library(ggplot2)
if(!require('moments')) install.packages('moments')
## Įkeliamas reikalingas paketas: moments
library(moments)
duomenys_centered <- scale(d, center = TRUE, scale = FALSE)
boxplot(duomenys_centered)

duom <- scale(duomenys_centered, center = FALSE, scale = TRUE)
boxplot(duom)

Latvija <- ts(d$Latvija, start = c(2016,01), end = (2022), frequency = 12)
train <- msts(d$Latvija[1:85], seasonal.periods = c(12), start = c(2016,01))
test <- msts(d$Latvija[85:100], seasonal.periods = c(12), start = c(2021,12))
prognoze_naive <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_meanf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_snaive <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_rwf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_croston <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_stlf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_ses <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_holt <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_hw <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_splinef <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_thetaf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_forecast <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
for (i in 1 : 15)
{
a <- 85 + i
x <- ts(d$Latvija[1:a], start = c(2014,01), frequency = 12)
prog_naive <- naive(x, h=1)
prog_meanf <-meanf(x, h=1)
prog_snaive <- snaive(x, h=1)
prog_rwf <- rwf(x,h=1, drift = TRUE)
prog_croston <- croston(x, h=1)
prog_stlf <- stlf(x, h=1)
prog_ses <- ses(x, h=1)
prog_holt <- holt(x, h=1)
prog_hw <- hw(x,h=1)
prog_splinef <- splinef(x, h=1)
prog_thetaf <- thetaf(x, h=1)
prog_forecast <- forecast(x, h=1)
prognoze_naive[i] <- prog_naive$mean
prognoze_meanf[i] <- prog_meanf$mean
prognoze_snaive[i] <- prog_snaive$mean
prognoze_rwf[i] <- prog_rwf$mean
prognoze_croston[i] <- prog_croston$mean
prognoze_stlf[i] <- prog_stlf$mean
prognoze_ses[i] <- prog_ses$mean
prognoze_holt[i] <- prog_holt$mean
prognoze_hw[i] <- prog_hw$mean
prognoze_splinef[i] <- prog_splinef$mean
prognoze_thetaf[i] <- prog_thetaf$mean
prognoze_forecast[i] <- prog_forecast$mean
}
print(prognoze_naive)
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 2021 0
## 2022 0 542 0 363 364 0 0 216 268 0 157 63
## 2023 0 45
autoplot(Latvija) +
autolayer(prognoze_meanf, series = "Pagal vidurkį (meanf())")+
autolayer(prognoze_naive, series = "Pagal paskutinę reikšmę (naive())") +
autolayer(prognoze_snaive, series = "Pagal sezonų reikšmes (snaive())") +
autolayer(prognoze_rwf, series = "rwf")+
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Latvijoje prognozavimas (meanf, naive, snaive, rwf)") +
guides(colour = guide_legend(title = "Prognozė"))

autoplot(Latvija) +
autolayer(prognoze_croston, series = "croston ()")+
autolayer(prognoze_stlf, series = "stlf ()")+
autolayer(prognoze_ses, series = "ses()") +
autolayer(prognoze_holt, series = "holt()") +
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Latvijoje prognozavimas (croston, stlf, ses, holt)") +
guides(colour = guide_legend(title = "Prognozė"))

autoplot(Latvija) +
autolayer(prognoze_hw, series = "hw ()")+
autolayer(prognoze_splinef, series = "splinef()") +
autolayer(prognoze_thetaf, series = "thetaf()") +
autolayer(prognoze_forecast, series = "forecast()") +
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Latvijoje prognozavimas (hw(), splinef(), thetaf(), forecast())") +
guides(colour = guide_legend(title = "Prognozė"))

Lat <- array()
Lat$naive <- accuracy(prognoze_naive, test)
## Warning in Lat$naive <- accuracy(prognoze_naive, test): LHS vertimas į sąrašą
Lat$meanf <- accuracy(prognoze_meanf, test)
Lat$snaive <- accuracy(prognoze_snaive, test)
Lat$croston <- accuracy(prognoze_croston, test)
Lat$forecast <- accuracy(prognoze_forecast, test)
Lat$holt <- accuracy(prognoze_holt, test)
Lat$hw <- accuracy(prognoze_hw, test)
Lat$rwf <- accuracy(prognoze_rwf, test)
Lat$ses <- accuracy(prognoze_ses, test)
Lat$spinef <- accuracy(prognoze_splinef, test)
Lat$stlf <- accuracy(prognoze_stlf, test)
Lat$thetaf <- accuracy(prognoze_thetaf, test)
boxplot(Lat[2:13], main='Latvijos susirgimų skaičiaus paklaidų vizualizacija', par(las=2))
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 1
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 2
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 3
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 4
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 5
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 6
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingas duomuo (Inf) stačiakampėje diagramoje 7 yra
## nenupieštas
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingas duomuo (Inf) stačiakampėje diagramoje 8 yra
## nenupieštas
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 9
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 10
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 11
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 12
## nėra nupiešti

Lat
## [[1]]
## [1] NA
##
## $naive
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -3 259.8021 180.4667 -Inf Inf -0.5403133 0
##
## $meanf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -337.4417 378.4639 345.5151 -Inf Inf -0.188453 0
##
## $snaive
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -142.5333 331.6579 271.4667 -Inf Inf 0.08588517 0
##
## $croston
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -157.3839 236.671 202.5572 -Inf Inf -0.1054623 0
##
## $forecast
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -89.28014 207.041 181.6757 -Inf Inf -0.1278955 0
##
## $holt
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -72.58352 189.134 165.9072 -Inf Inf -0.2861013 0
##
## $hw
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -7.432266 273.6731 217.7068 NaN Inf -0.5693293 NaN
##
## $rwf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -4.484405 261.2789 181.8645 NaN Inf -0.5404228 NaN
##
## $ses
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -129.6312 214.9048 186.6442 -Inf Inf -0.2101255 0
##
## $spinef
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -73.77533 186.6568 163.6145 -Inf Inf -0.2092863 0
##
## $stlf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -92.70308 197.2625 164.9968 -Inf Inf -0.2208698 0
##
## $thetaf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -88.20354 192.5367 167.866 -Inf Inf -0.2134085 0
Lietuva <- ts(d$Lietuva, start = c(2016,01), end = (2022), frequency = 12)
train <- msts(d$Lietuva[1:85], seasonal.periods = c(12), start = c(2016,01))
test <- msts(d$Lietuva[85:100], seasonal.periods = c(12), start = c(2021,12))
prognoze_naive <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_meanf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_snaive <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_rwf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_croston <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_stlf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_ses <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_holt <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_hw <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_splinef <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_thetaf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_forecast <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
for (i in 1 : 15)
{
a <- 85 + i
x <- ts(d$Lietuva[1:a], start = c(2014,01), frequency = 12)
prog_naive <- naive(x, h=1)
prog_meanf <-meanf(x, h=1)
prog_snaive <- snaive(x, h=1)
prog_rwf <- rwf(x,h=1, drift = TRUE)
prog_croston <- croston(x, h=1)
prog_stlf <- stlf(x, h=1)
prog_ses <- ses(x, h=1)
prog_holt <- holt(x, h=1)
prog_hw <- hw(x,h=1)
prog_splinef <- splinef(x, h=1)
prog_thetaf <- thetaf(x, h=1)
prog_forecast <- forecast(x, h=1)
prognoze_naive[i] <- prog_naive$mean
prognoze_meanf[i] <- prog_meanf$mean
prognoze_snaive[i] <- prog_snaive$mean
prognoze_rwf[i] <- prog_rwf$mean
prognoze_croston[i] <- prog_croston$mean
prognoze_stlf[i] <- prog_stlf$mean
prognoze_ses[i] <- prog_ses$mean
prognoze_holt[i] <- prog_holt$mean
prognoze_hw[i] <- prog_hw$mean
prognoze_splinef[i] <- prog_splinef$mean
prognoze_thetaf[i] <- prog_thetaf$mean
prognoze_forecast[i] <- prog_forecast$mean
}
print(prognoze_naive)
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 2021 48
## 2022 59 0 691 471 479 497 64 43 774 512 485 335
## 2023 301 31
autoplot(Lietuva) +
autolayer(prognoze_meanf, series = "Pagal vidurkį (meanf())")+
autolayer(prognoze_naive, series = "Pagal paskutinę reikšmę (naive())") +
autolayer(prognoze_snaive, series = "Pagal sezonų reikšmes (snaive())") +
autolayer(prognoze_rwf, series = "rwf")+
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Lietuvoje prognozavimas (meanf, naive, snaive, rwf)") +
guides(colour = guide_legend(title = "Prognozė"))

autoplot(Lietuva) +
autolayer(prognoze_croston, series = "croston ()")+
autolayer(prognoze_stlf, series = "stlf ()")+
autolayer(prognoze_ses, series = "ses()") +
autolayer(prognoze_holt, series = "holt()") +
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Lietuvoje prognozavimas (croston, stlf, ses, holt)") +
guides(colour = guide_legend(title = "Prognozė"))

autoplot(Lietuva) +
autolayer(prognoze_hw, series = "hw ()")+
autolayer(prognoze_splinef, series = "splinef()") +
autolayer(prognoze_thetaf, series = "thetaf()") +
autolayer(prognoze_forecast, series = "forecast()") +
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Lietuvoje prognozavimas (hw(), splinef(), thetaf(), forecast())") +
guides(colour = guide_legend(title = "Prognozė"))

Liet <- array()
Liet$naive <- accuracy(prognoze_naive, test)
## Warning in Liet$naive <- accuracy(prognoze_naive, test): LHS vertimas į sąrašą
Liet$meanf <- accuracy(prognoze_meanf, test)
Liet$snaive <- accuracy(prognoze_snaive, test)
Liet$croston <- accuracy(prognoze_croston, test)
Liet$forecast <- accuracy(prognoze_forecast, test)
Liet$holt <- accuracy(prognoze_holt, test)
Liet$hw <- accuracy(prognoze_hw, test)
Liet$rwf <- accuracy(prognoze_rwf, test)
Liet$ses <- accuracy(prognoze_ses, test)
Liet$spinef <- accuracy(prognoze_splinef, test)
Liet$stlf <- accuracy(prognoze_stlf, test)
Liet$thetaf <- accuracy(prognoze_thetaf, test)
boxplot(Liet[2:13], main='Susirgimų skaičiaus Lietuvoje paklaidų vizualizacija', par(las=2))
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 1
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 2
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 3
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 4
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 5
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 6
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 7
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 8
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 9
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 10
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 11
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 12
## nėra nupiešti

Liet
## [[1]]
## [1] NA
##
## $naive
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 55.4 372.4412 249.9333 -Inf Inf -0.1834375 0
##
## $meanf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -37.86433 274.8201 232.2977 -Inf Inf -0.004279202 0
##
## $snaive
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -45.4 475.2044 415 -Inf Inf 0.2213669 0
##
## $croston
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 4.740062 263.5966 225.8905 -Inf Inf -0.02770909 0
##
## $forecast
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 87.30862 285.8909 258.2388 -Inf Inf 0.08072491 0
##
## $holt
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 86.45535 286.3701 259.056 -Inf Inf 0.08139772 0
##
## $hw
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 82.73568 276.3112 247.7933 -Inf Inf 0.1026019 0
##
## $rwf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 63.39249 375.5948 253.8617 -Inf Inf -0.1826449 0
##
## $ses
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 2.6448 260.1107 222.2627 -Inf Inf -0.05196834 0
##
## $spinef
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -23.77756 259.2447 217.712 -Inf Inf -0.05645139 0
##
## $stlf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 75.60465 259.9784 232.6785 -Inf Inf 0.1404768 0
##
## $thetaf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 21.11445 260.3647 222.9686 -Inf Inf -0.05605989 0
Lenkija<- ts(d$Lenkija, start = c(2016,01), end = (2022), frequency = 12)
train <- msts(d$Lenkija[1:85], seasonal.periods = c(12), start = c(2016,01))
test <- msts(d$Lenkija[85:100], seasonal.periods = c(12), start = c(2021,12))
prognoze_naive <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_meanf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_snaive <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_rwf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_croston <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_stlf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_ses <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_holt <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_hw <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_splinef <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_thetaf <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
prognoze_forecast <- msts(numeric(15), seasonal.periods = c(12), start = c(2021,12))
for (i in 1 : 15)
{
a <- 85 + i
x <- ts(d$Lenkija[1:a], start = c(2014,01), frequency = 12)
prog_naive <- naive(x, h=1)
prog_meanf <-meanf(x, h=1)
prog_snaive <- snaive(x, h=1)
prog_rwf <- rwf(x,h=1, drift = TRUE)
prog_croston <- croston(x, h=1)
prog_stlf <- stlf(x, h=1)
prog_ses <- ses(x, h=1)
prog_holt <- holt(x, h=1)
prog_hw <- hw(x,h=1)
prog_splinef <- splinef(x, h=1)
prog_thetaf <- thetaf(x, h=1)
prog_forecast <- forecast(x, h=1)
prognoze_naive[i] <- prog_naive$mean
prognoze_meanf[i] <- prog_meanf$mean
prognoze_snaive[i] <- prog_snaive$mean
prognoze_rwf[i] <- prog_rwf$mean
prognoze_croston[i] <- prog_croston$mean
prognoze_stlf[i] <- prog_stlf$mean
prognoze_ses[i] <- prog_ses$mean
prognoze_holt[i] <- prog_holt$mean
prognoze_hw[i] <- prog_hw$mean
prognoze_splinef[i] <- prog_splinef$mean
prognoze_thetaf[i] <- prog_thetaf$mean
prognoze_forecast[i] <- prog_forecast$mean
}
print(prognoze_naive)
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 2021 119
## 2022 162 181 803 600 634 623 153 117 693 566 525 463
## 2023 120 143
autoplot(Lenkija) +
autolayer(prognoze_meanf, series = "Pagal vidurkį (meanf())")+
autolayer(prognoze_naive, series = "Pagal paskutinę reikšmę (naive())") +
autolayer(prognoze_snaive, series = "Pagal sezonų reikšmes (snaive())") +
autolayer(prognoze_rwf, series = "rwf")+
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Lenkijoje prognozavimas (meanf, naive, snaive, rwf)") +
guides(colour = guide_legend(title = "Prognozė"))

autoplot(Lenkija) +
autolayer(prognoze_croston, series = "croston ()")+
autolayer(prognoze_stlf, series = "stlf ()")+
autolayer(prognoze_ses, series = "ses()") +
autolayer(prognoze_holt, series = "holt()") +
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Lenkijoje prognozavimas (croston, stlf, ses, holt)") +
guides(colour = guide_legend(title = "Prognozė"))

autoplot(Lenkija) +
autolayer(prognoze_hw, series = "hw ()")+
autolayer(prognoze_splinef, series = "splinef()") +
autolayer(prognoze_thetaf, series = "thetaf()") +
autolayer(prognoze_forecast, series = "forecast()") +
xlab("Mėnesiai") + ylab("Susirgimai") +
ggtitle("Susirgimų skaičiaus Lenkijoje prognozavimas (hw(), splinef(), thetaf(), forecast())") +
guides(colour = guide_legend(title = "Prognozė"))

Lenk <- array()
Lenk$naive <- accuracy(prognoze_naive, test)
## Warning in Lenk$naive <- accuracy(prognoze_naive, test): LHS vertimas į sąrašą
Lenk$meanf <- accuracy(prognoze_meanf, test)
Lenk$snaive <- accuracy(prognoze_snaive, test)
Lenk$croston <- accuracy(prognoze_croston, test)
Lenk$forecast <- accuracy(prognoze_forecast, test)
Lenk$holt <- accuracy(prognoze_holt, test)
Lenk$hw <- accuracy(prognoze_hw, test)
Lenk$rwf <- accuracy(prognoze_rwf, test)
Lenk$ses <- accuracy(prognoze_ses, test)
Lenk$spinef <- accuracy(prognoze_splinef, test)
Lenk$stlf <- accuracy(prognoze_stlf, test)
Lenk$thetaf <- accuracy(prognoze_thetaf, test)
boxplot(Liet[2:13], main='Susirgimų skaičiaus Lenkijoje paklaidų vizualizacija', par(las=2))
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 1
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 2
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 3
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 4
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 5
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 6
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 7
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 8
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 9
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 10
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 11
## nėra nupiešti
## Warning in bplt(at[i], wid = width[i], stats = z$stats[, i], out =
## z$out[z$group == : Klaidingi duomenys (-Inf, Inf) stačiakampėje diagramoje 12
## nėra nupiešti

Lenk
## [[1]]
## [1] NA
##
## $naive
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 33.73333 306.1899 209.3333 -39.30257 81.8508 -0.1407077 0.9212796
##
## $meanf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -379.6408 450.6632 379.6408 -213.9612 213.9612 0.1496955 1.375339
##
## $snaive
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -95.2 445.1648 399.8667 -139.3071 189.7426 0.283338 1.181953
##
## $croston
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -52.98984 233.0083 201.7109 -82.18165 104.4978 0.09726307 0.7606325
##
## $forecast
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -35.05188 250.1404 225.5831 -79.44533 109.2378 0.2509914 0.8147292
##
## $holt
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 20.15093 256.2828 242.6105 -60.18624 102.2923 0.24284 0.8413983
##
## $hw
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -28.86457 290.1494 248.244 -80.41127 114.8247 0.008403242 0.8415898
##
## $rwf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 68.28356 313.5658 220.4068 -25.67172 80.41111 -0.1406919 0.8983224
##
## $ses
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set -38.5491 216.8165 190.4401 -72.45583 95.50754 0.04457736 0.714943
##
## $spinef
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 69.03625 574.3794 381.9714 -64.27854 152.8473 -0.05556397 1.705318
##
## $stlf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 17.7101 213.8252 194.3383 -47.61054 81.87811 0.03328851 0.6170628
##
## $thetaf
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 10.58246 213.0642 199.358 -53.18362 85.78404 0.0366997 0.6879053