import data from SPP 2015
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.6.1
## -- Attaching packages ------------------------------------------------- tidyverse 1.3.0 --
## <U+2713> ggplot2 3.2.1 <U+2713> purrr 0.3.3
## <U+2713> tibble 2.1.3 <U+2713> dplyr 0.8.3
## <U+2713> tidyr 1.0.0 <U+2713> stringr 1.4.0
## <U+2713> readr 1.3.1 <U+2713> forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.6.1
## Warning: package 'tidyr' was built under R version 3.6.1
## Warning: package 'purrr' was built under R version 3.6.1
## Warning: package 'dplyr' was built under R version 3.6.1
## -- Conflicts ---------------------------------------------------- tidyverse_conflicts() --
## x lubridate::as.difftime() masks base::as.difftime()
## x lubridate::date() masks base::date()
## x dplyr::filter() masks stats::filter()
## x lubridate::intersect() masks base::intersect()
## x dplyr::lag() masks stats::lag()
## x lubridate::setdiff() masks base::setdiff()
## x lubridate::union() masks base::union()
jan2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201501.csv")
feb2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201502.csv")
mar2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201503.csv")
apr2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201504.csv")
may2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201505.csv")
jun2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201506.csv")
jul2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201507.csv")
aug2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201508.csv")
sep2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201509.csv")
oct2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201510.csv")
nov2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201511.csv")
dec2015 <- read.csv("C:/Users/Owner/Downloads/2015/2015/HOURLY_LOAD-201512.csv")
#another year of data
jan2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201601.csv")
feb2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201602.csv")
mar2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201603.csv")
apr2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201604.csv")
may2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201605.csv")
jun2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201606.csv")
jul2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201607.csv")
aug2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201608.csv")
sep2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201609.csv")
oct2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201610.csv")
nov2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201611.csv")
dec2016 <- read.csv("C:/Users/Owner/Downloads/2016/2016/HOURLY_LOAD-201612.csv")
#one more year holdout period to check accuracy
jan2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201701.csv")
feb2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201702.csv")
mar2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201703.csv")
apr2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201704.csv")
may2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201705.csv")
jun2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201706.csv")
jul2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201707.csv")
aug2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201708.csv")
sep2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201709.csv")
oct2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201710.csv")
nov2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201711.csv")
dec2017 <- read.csv("C:/Users/Owner/Downloads/2017/2017/HOURLY_LOAD-201712.csv")
check the data to make sure it looks right
typeof(jan2015)
## [1] "list"
head(jan2015)
## MarketHour CSWS EDE GRDA INDN KACY KCPL LES
## 1 1/1/2015 7:00 5414.429 690.3534 601.3288 118.0098 276.2816 2024.032 408.0981
## 2 1/1/2015 8:00 5302.293 680.9007 597.8342 114.6098 271.8046 1994.646 397.7420
## 3 1/1/2015 9:00 5216.567 673.7481 593.3138 112.2294 268.6326 1976.253 391.5342
## 4 1/1/2015 10:00 5194.792 671.1187 587.5187 111.3522 267.1147 1961.418 389.2468
## 5 1/1/2015 11:00 5228.730 676.4434 589.5427 111.6190 265.7899 1965.443 390.4449
## 6 1/1/2015 12:00 5333.310 690.4988 597.5163 114.2844 268.8763 2004.644 397.2468
## MPS NPPD OKGE OPPD SECI SPRM SPS WFEC
## 1 1123.671 2032.944 3718.808 1360.805 640.9721 348.9844 3652.834 1278.617
## 2 1103.481 2003.726 3632.980 1333.814 632.3099 341.5408 3611.853 1254.873
## 3 1089.127 1994.740 3568.703 1312.000 625.9764 337.4763 3576.350 1243.953
## 4 1081.688 1979.506 3543.309 1299.054 616.8410 336.4804 3555.746 1239.468
## 5 1084.774 1962.926 3544.052 1300.290 616.8140 339.9563 3551.316 1247.402
## 6 1101.270 2014.254 3578.582 1320.082 620.8659 349.3648 3567.584 1259.264
## WR
## 1 3485.146
## 2 3407.071
## 3 3356.186
## 4 3330.178
## 5 3331.899
## 6 3375.732
make it time plotable data
jan2015 <- as.data.frame(jan2015)
feb2015 <- as.data.frame(feb2015)
mar2015 <- as.data.frame(mar2015)
apr2015 <- as.data.frame(apr2015)
may2015 <- as.data.frame(may2015)
jun2015 <- as.data.frame(jun2015)
jul2015 <- as.data.frame(jul2015)
aug2015 <- as.data.frame(aug2015)
sep2015 <- as.data.frame(sep2015)
oct2015 <- as.data.frame(oct2015)
nov2015 <- as.data.frame(nov2015)
dec2015 <- as.data.frame(dec2015)
#next year
jan2016 <- as.data.frame(jan2016)
feb2016 <- as.data.frame(feb2016)
mar2016 <- as.data.frame(mar2016)
apr2016 <- as.data.frame(apr2016)
may2016 <- as.data.frame(may2016)
jun2016 <- as.data.frame(jun2016)
jul2016 <- as.data.frame(jul2016)
aug2016 <- as.data.frame(aug2016)
sep2016 <- as.data.frame(sep2016)
oct2016 <- as.data.frame(oct2016)
nov2016 <- as.data.frame(nov2016)
dec2016 <- as.data.frame(dec2016)
#data check year
jan2017 <- as.data.frame(jan2017)
feb2017 <- as.data.frame(feb2017)
mar2017 <- as.data.frame(mar2017)
apr2017 <- as.data.frame(apr2017)
may2017 <- as.data.frame(may2017)
jun2017 <- as.data.frame(jun2017)
jul2017 <- as.data.frame(jul2017)
aug2017 <- as.data.frame(aug2017)
sep2017 <- as.data.frame(sep2017)
oct2017 <- as.data.frame(oct2017)
nov2017 <- as.data.frame(nov2017)
dec2017 <- as.data.frame(dec2017)
#make the date recognized
jan2015$MarketHour <- as.Date(jan2015$MarketHour, "%m/%d/%Y")
feb2015$MarketHour <- as.Date(feb2015$MarketHour, "%m/%d/%Y")
mar2015$MarketHour <- as.Date(mar2015$MarketHour, "%m/%d/%Y")
apr2015$MarketHour <- as.Date(apr2015$MarketHour, "%m/%d/%Y")
may2015$MarketHour <- as.Date(may2015$MarketHour, "%m/%d/%Y")
jun2015$MarketHour <- as.Date(jun2015$MarketHour, "%m/%d/%Y")
jul2015$MarketHour <- as.Date(jul2015$MarketHour, "%m/%d/%Y")
aug2015$MarketHour <- as.Date(aug2015$MarketHour, "%m/%d/%Y")
sep2015$MarketHour <- as.Date(sep2015$MarketHour, "%m/%d/%Y")
oct2015$MarketHour <- as.Date(oct2015$MarketHour, "%m/%d/%Y")
nov2015$MarketHour <- as.Date(nov2015$MarketHour, "%m/%d/%Y")
dec2015$MarketHour <- as.Date(dec2015$MarketHour, "%m/%d/%Y")
#next year
jan2016$MarketHour <- as.Date(jan2016$MarketHour, "%m/%d/%Y")
feb2016$MarketHour <- as.Date(feb2016$MarketHour, "%m/%d/%Y")
mar2016$MarketHour <- as.Date(mar2016$MarketHour, "%m/%d/%Y")
apr2016$MarketHour <- as.Date(apr2016$MarketHour, "%m/%d/%Y")
may2016$MarketHour <- as.Date(may2016$MarketHour, "%m/%d/%Y")
jun2016$MarketHour <- as.Date(jun2016$MarketHour, "%m/%d/%Y")
jul2016$MarketHour <- as.Date(jul2016$MarketHour, "%m/%d/%Y")
aug2016$MarketHour <- as.Date(aug2016$MarketHour, "%m/%d/%Y")
sep2016$MarketHour <- as.Date(sep2016$MarketHour, "%m/%d/%Y")
oct2016$MarketHour <- as.Date(oct2016$MarketHour, "%m/%d/%Y")
nov2016$MarketHour <- as.Date(nov2016$MarketHour, "%m/%d/%Y")
dec2016$MarketHour <- as.Date(dec2016$MarketHour, "%m/%d/%Y")
#data check year
jan2017$MarketHour <- as.Date(jan2017$MarketHour, "%m/%d/%Y")
feb2017$MarketHour <- as.Date(feb2017$MarketHour, "%m/%d/%Y")
mar2017$MarketHour <- as.Date(mar2017$MarketHour, "%m/%d/%Y")
apr2017$MarketHour <- as.Date(apr2017$MarketHour, "%m/%d/%Y")
may2017$MarketHour <- as.Date(may2017$MarketHour, "%m/%d/%Y")
jun2017$MarketHour <- as.Date(jun2017$MarketHour, "%m/%d/%Y")
jul2017$MarketHour <- as.Date(jul2017$MarketHour, "%m/%d/%Y")
aug2017$MarketHour <- as.Date(aug2017$MarketHour, "%m/%d/%Y")
sep2017$MarketHour <- as.Date(sep2017$MarketHour, "%m/%d/%Y")
oct2017$MarketHour <- as.Date(oct2017$MarketHour, "%m/%d/%Y")
nov2017$MarketHour <- as.Date(nov2017$MarketHour, "%m/%d/%Y")
dec2017$MarketHour <- as.Date(dec2017$MarketHour, "%m/%d/%Y")
plot the data
plot(jan2015$OKGE ~ jan2015$MarketHour, main = "OKGE HOURLY LOAD DATA JANUARY 2015", xlab = "Date", ylab = "Load (MW)")
check it out again
head(jan2015)
## MarketHour CSWS EDE GRDA INDN KACY KCPL LES
## 1 2015-01-01 5414.429 690.3534 601.3288 118.0098 276.2816 2024.032 408.0981
## 2 2015-01-01 5302.293 680.9007 597.8342 114.6098 271.8046 1994.646 397.7420
## 3 2015-01-01 5216.567 673.7481 593.3138 112.2294 268.6326 1976.253 391.5342
## 4 2015-01-01 5194.792 671.1187 587.5187 111.3522 267.1147 1961.418 389.2468
## 5 2015-01-01 5228.730 676.4434 589.5427 111.6190 265.7899 1965.443 390.4449
## 6 2015-01-01 5333.310 690.4988 597.5163 114.2844 268.8763 2004.644 397.2468
## MPS NPPD OKGE OPPD SECI SPRM SPS WFEC
## 1 1123.671 2032.944 3718.808 1360.805 640.9721 348.9844 3652.834 1278.617
## 2 1103.481 2003.726 3632.980 1333.814 632.3099 341.5408 3611.853 1254.873
## 3 1089.127 1994.740 3568.703 1312.000 625.9764 337.4763 3576.350 1243.953
## 4 1081.688 1979.506 3543.309 1299.054 616.8410 336.4804 3555.746 1239.468
## 5 1084.774 1962.926 3544.052 1300.290 616.8140 339.9563 3551.316 1247.402
## 6 1101.270 2014.254 3578.582 1320.082 620.8659 349.3648 3567.584 1259.264
## WR
## 1 3485.146
## 2 3407.071
## 3 3356.186
## 4 3330.178
## 5 3331.899
## 6 3375.732
put the datasets together
library(dplyr)
Data2015 <- rbind(jan2015, feb2015, mar2015, apr2015, may2015, jun2015, jul2015, aug2015, sep2015)
#another generator joined in the last quarter of the year and messed up my clean join.
Data2015_2 <- rbind(oct2015, nov2015, dec2015)
#put together the next year
Data2016 <- rbind(jan2016, feb2016, mar2016, apr2016, may2016, jun2016, jul2016, aug2016, sep2016, oct2016, nov2016, dec2016)
#put together the data check year
Data2017 <- rbind(jan2017, feb2017, mar2017, apr2017, may2017, jun2017, jul2017, aug2017, sep2017, oct2017, nov2017, dec2017)
join my mismatched datasets, replacing the new generators early year non-existance with NA
yearlyLoad2015 <- full_join(Data2015, Data2015_2)
## Joining, by = c("MarketHour", "CSWS", "EDE", "GRDA", "INDN", "KACY", "KCPL",
## "LES", "MPS", "NPPD", "OKGE", "OPPD", "SECI", "SPRM", "SPS", "WFEC", "WR")
twoYearLoadData <- full_join(yearlyLoad2015, Data2016)
## Joining, by = c("MarketHour", "CSWS", "EDE", "GRDA", "INDN", "KACY", "KCPL",
## "LES", "MPS", "NPPD", "OKGE", "OPPD", "SECI", "SPRM", "SPS", "WFEC", "WR",
## "WAUE")
library(WriteXLS)
write_excel_csv(yearlyLoad2015, path = "C:/Users/Owner/Documents/yearlyLoad2015.csv")
plot the total dataset
plot(yearlyLoad2015$OKGE ~ yearlyLoad2015$MarketHour, xlab = "Date", ylab = "Load (MW)", main = "Hourly Load Data OKGE 2015", col = "red", type = "l")
plot both years data
plot(twoYearLoadData$OKGE ~ twoYearLoadData$MarketHour, xlab = "Date", ylab = "Load (MW)", main = "Hourly Load Data OKGE 2015 & 2016", col = "red", type = "l")
Now I want a time series of OG&E data. First I need to consolidate the data on a daily basis.
library(dplyr)
avgDailyLoadTwoYear <- twoYearLoadData %>%
group_by(MarketHour) %>%
summarise(dailyAvgTwoYear = mean(OKGE))
#consolidate check year data
avgDailyLoad2017 <- Data2017 %>%
group_by(MarketHour) %>%
summarise(dailyAvg2017 = mean(OKGE))
View(avgDailyLoadTwoYear)
library(WriteXLS)
write_excel_csv(avgDailyLoadTwoYear, path = "C:/Users/Owner/Documents/AvgDailyLoadDataTwoYear.csv")
plot the daily averages
plot(avgDailyLoadTwoYear$dailyAvgTwoYear ~ avgDailyLoadTwoYear$MarketHour, xlab = "Date", ylab = "Load (MW)", main = "Average Daily Load OKGE 2015 & 2016", type = "l", col = "blue")
looks like a good enough reflection of the total data.
now to put the consolidated data into a daily time series.
LoadTimeSeries2015_2016 <- as.vector(avgDailyLoadTwoYear$dailyAvgTwoYear)
LoadTimeSeries2015_2016 <- ts(LoadTimeSeries2015_2016, start = c(2015, 1), frequency = 365)
loadTimeSeries2017 <- as.vector(avgDailyLoad2017$dailyAvg2017)
loadTimeSeries2017 <- ts(loadTimeSeries2017, start = c(2017, 1), frequency = 365)
plot.ts(LoadTimeSeries2015_2016)
now to make an arima model.
library(forecast)
## Warning: package 'forecast' was built under R version 3.6.1
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Registered S3 methods overwritten by 'forecast':
## method from
## fitted.fracdiff fracdiff
## residuals.fracdiff fracdiff
arimaModel2015_2016 <- auto.arima(LoadTimeSeries2015_2016)
## Warning: The chosen seasonal unit root test encountered an error when testing for the second difference.
## From stl(): series is not periodic or has less than two periods
## 1 seasonal differences will be used. Consider using a different unit root test.
future <- forecast(arimaModel2015_2016, h = 365)
plot(future, xlab = "Date as Decimal", ylab = "Load (MW)", col = "red", fcol = "blue")
#+lines(loadTimeSeries2017, col = "green")
summary(future)
##
## Forecast method: ARIMA(1,1,2)(0,1,0)[365]
##
## Model Information:
## Series: LoadTimeSeries2015_2016
## ARIMA(1,1,2)(0,1,0)[365]
##
## Coefficients:
## ar1 ma1 ma2
## 0.5204 -0.4773 -0.4952
## s.e. 0.0575 0.0565 0.0529
##
## sigma^2 estimated as 93093: log likelihood=-2616.11
## AIC=5240.22 AICc=5240.33 BIC=5255.83
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 7.72166 214.86 115.8786 0.09344343 3.198896 0.306106 0.009375046
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2017.0055 3606.646 3041.611 4171.682 2742.499 4470.794
## 2017.0082 3845.291 3237.827 4452.755 2916.256 4774.327
## 2017.0110 3727.556 3106.991 4348.120 2778.484 4676.627
## 2017.0137 3688.531 3063.235 4313.826 2732.224 4644.837
## 2017.0164 3639.016 3011.667 4266.364 2679.569 4598.463
## 2017.0192 3794.739 3166.291 4423.187 2833.611 4755.867
## 2017.0219 4014.009 3384.841 4643.177 3051.780 4976.239
## 2017.0247 4073.256 3443.533 4702.978 3110.178 5036.333
## 2017.0274 3863.881 3233.682 4494.081 2900.074 4827.689
## 2017.0301 3739.699 3109.061 4370.338 2775.221 4704.178
## 2017.0329 3561.030 2929.973 4192.088 2595.911 4526.150
## 2017.0356 3428.511 2797.045 4059.978 2462.766 4394.257
## 2017.0384 3521.420 2889.549 4153.291 2555.057 4487.783
## 2017.0411 3733.491 3101.219 4365.762 2766.514 4700.467
## 2017.0438 4122.073 3489.401 4754.744 3154.485 5089.660
## 2017.0466 4164.227 3531.157 4797.297 3196.030 5132.424
## 2017.0493 4115.511 3482.043 4748.979 3146.705 5084.316
## 2017.0521 4040.185 3406.319 4674.050 3070.771 5009.598
## 2017.0548 4186.855 3552.592 4821.117 3216.834 5156.875
## 2017.0575 3883.625 3248.965 4518.284 2912.997 4854.252
## 2017.0603 3539.407 2904.352 4174.463 2568.173 4510.642
## 2017.0630 3469.878 2834.425 4105.330 2498.037 4441.718
## 2017.0658 3757.833 3121.985 4393.681 2785.387 4730.279
## 2017.0685 3836.537 3200.293 4472.781 2863.486 4809.588
## 2017.0712 3611.068 2974.429 4247.708 2637.412 4584.724
## 2017.0740 3428.620 2791.585 4065.655 2454.359 4402.881
## 2017.0767 3077.906 2440.476 3715.336 2103.041 4052.771
## 2017.0795 2910.251 2272.426 3548.076 1934.782 3885.720
## 2017.0822 3278.171 2639.952 3916.390 2302.099 4254.243
## 2017.0849 3285.433 2646.819 3924.047 2308.758 4262.108
## 2017.0877 3726.555 3087.548 4365.563 2749.277 4703.833
## 2017.0904 3815.780 3176.379 4455.182 2837.900 4793.660
## 2017.0932 3698.396 3058.601 4338.191 2719.914 4676.879
## 2017.0959 3303.799 2663.611 3943.988 2324.716 4282.883
## 2017.0986 3298.174 2657.593 3938.756 2318.489 4277.859
## 2017.1014 3572.417 2931.443 4213.392 2592.132 4552.703
## 2017.1041 3791.699 3150.332 4433.066 2810.813 4772.585
## 2017.1068 3707.182 3065.422 4348.941 2725.695 4688.668
## 2017.1096 3321.464 2679.312 3963.615 2339.378 4303.550
## 2017.1123 3409.748 2767.205 4052.291 2427.063 4392.433
## 2017.1151 3301.639 2658.704 3944.574 2318.355 4284.923
## 2017.1178 3167.531 2524.204 3810.857 2183.648 4151.414
## 2017.1205 3242.304 2598.586 3886.021 2257.822 4226.785
## 2017.1233 3317.163 2673.055 3961.272 2332.084 4302.242
## 2017.1260 3405.878 2761.378 4050.377 2420.201 4391.554
## 2017.1288 3228.070 2583.180 3872.960 2241.796 4214.344
## 2017.1315 3108.707 2463.427 3753.987 2121.836 4095.578
## 2017.1342 2944.312 2298.642 3589.982 1956.845 3931.779
## 2017.1370 2808.421 2162.361 3454.481 1820.358 3796.484
## 2017.1397 3105.383 2458.933 3751.832 2116.724 4094.042
## 2017.1425 3405.853 2759.015 4052.692 2416.599 4395.108
## 2017.1452 3662.312 3015.084 4309.540 2672.463 4652.161
## 2017.1479 3506.070 2858.453 4153.686 2515.626 4496.514
## 2017.1507 3586.654 2938.649 4234.660 2595.616 4577.693
## 2017.1534 3171.218 2522.825 3819.612 2179.586 4162.851
## 2017.1562 2893.803 2245.021 3542.584 1901.577 3886.029
## 2017.1589 3132.943 2483.773 3782.112 2140.123 4125.762
## 2017.1616 3091.576 2442.018 3741.133 2098.164 4084.988
## 2017.1644 3301.178 2651.233 3951.122 2307.173 4295.182
## 2017.1671 3148.679 2498.347 3799.011 2154.082 4143.276
## 2017.1699 3213.336 2562.617 3864.055 2218.147 4208.525
## 2017.1726 2910.410 2259.305 3561.516 1914.630 3906.190
## 2017.1753 2808.365 2156.873 3459.858 1811.994 3804.737
## 2017.1781 3056.182 2404.304 3708.061 2059.220 4053.144
## 2017.1808 3141.952 2489.688 3794.217 2144.400 4139.504
## 2017.1836 3150.454 2497.803 3803.104 2152.311 4148.596
## 2017.1863 3105.615 2452.579 3758.651 2106.883 4104.347
## 2017.1890 3091.940 2438.519 3745.362 2092.619 4091.262
## 2017.1918 2901.565 2247.759 3555.372 1901.655 3901.476
## 2017.1945 2762.858 2108.666 3417.049 1762.358 3763.357
## 2017.1973 3000.673 2346.097 3655.249 1999.586 4001.761
## 2017.2000 3007.886 2352.926 3662.847 2006.210 4009.562
## 2017.2027 3043.416 2388.071 3698.761 2041.153 4045.679
## 2017.2055 3028.616 2372.887 3684.344 2025.765 4031.466
## 2017.2082 3016.072 2359.959 3672.184 2012.634 4019.509
## 2017.2110 3068.133 2411.637 3724.629 2064.109 4072.158
## 2017.2137 3044.662 2387.783 3701.542 2040.052 4049.273
## 2017.2164 3321.981 2664.718 3979.243 2316.784 4327.177
## 2017.2192 3211.211 2553.565 3868.856 2205.429 4216.993
## 2017.2219 3195.821 2537.793 3853.849 2189.454 4202.188
## 2017.2247 3190.374 2531.963 3848.784 2183.421 4197.326
## 2017.2274 3157.727 2498.935 3816.520 2150.191 4165.264
## 2017.2301 2902.753 2243.578 3561.927 1894.632 3910.874
## 2017.2329 2894.196 2234.639 3553.753 1885.491 3902.901
## 2017.2356 3215.356 2555.418 3875.295 2206.068 4224.645
## 2017.2384 3235.141 2574.822 3895.461 2225.270 4245.013
## 2017.2411 3253.413 2592.712 3914.113 2242.958 4263.867
## 2017.2438 3184.993 2523.912 3846.075 2173.956 4196.030
## 2017.2466 3096.762 2435.300 3758.225 2085.143 4108.382
## 2017.2493 2954.298 2292.455 3616.141 1942.097 3966.499
## 2017.2521 2836.304 2174.081 3498.527 1823.522 3849.087
## 2017.2548 3108.986 2446.383 3771.589 2095.622 4122.350
## 2017.2575 3397.128 2734.145 4060.111 2383.183 4411.073
## 2017.2603 3340.388 2677.026 4003.751 2325.863 4354.914
## 2017.2630 3218.815 2555.074 3882.557 2203.710 4233.921
## 2017.2658 3163.544 2499.423 3827.665 2147.859 4179.230
## 2017.2685 2974.186 2309.686 3638.686 1957.921 3990.451
## 2017.2712 2956.337 2291.458 3621.215 1939.492 3973.181
## 2017.2740 3147.811 2482.554 3813.069 2130.388 4165.234
## 2017.2767 3126.222 2460.587 3791.858 2108.221 4144.224
## 2017.2795 3114.548 2448.534 3780.561 2095.968 4133.128
## 2017.2822 3111.889 2445.497 3778.280 2092.731 4131.047
## 2017.2849 3192.424 2525.655 3859.193 2172.689 4212.160
## 2017.2877 3014.891 2347.744 3682.037 1994.578 4035.203
## 2017.2904 2862.732 2195.208 3530.256 1841.843 3883.622
## 2017.2932 3076.723 2408.823 3744.624 2055.257 4098.189
## 2017.2959 3135.083 2466.806 3803.361 2113.041 4157.126
## 2017.2986 3123.849 2455.195 3792.503 2101.231 4146.467
## 2017.3014 3118.301 2449.271 3787.332 2095.107 4141.495
## 2017.3041 3135.499 2466.093 3804.906 2111.730 4159.269
## 2017.3068 3124.147 2454.364 3793.929 2099.803 4148.491
## 2017.3096 3087.739 2417.581 3757.898 2062.820 4112.658
## 2017.3123 3426.512 2755.978 4097.046 2401.019 4452.005
## 2017.3151 3741.717 3070.808 4412.626 2715.650 4767.784
## 2017.3178 3312.740 2641.456 3984.024 2286.099 4339.381
## 2017.3205 3216.181 2544.521 3887.840 2188.966 4243.395
## 2017.3233 3192.047 2520.013 3864.081 2164.260 4219.834
## 2017.3260 2932.483 2260.074 3604.891 1904.123 3960.843
## 2017.3288 2802.721 2129.938 3475.504 1773.789 3831.654
## 2017.3315 2979.024 2305.867 3652.181 1949.519 4008.528
## 2017.3342 3103.591 2430.060 3777.121 2073.514 4133.667
## 2017.3370 3167.644 2493.739 3841.548 2136.996 4198.291
## 2017.3397 3221.011 2546.733 3895.289 2189.792 4252.230
## 2017.3425 3325.571 2650.920 4000.222 2293.781 4357.360
## 2017.3452 3235.875 2560.851 3910.899 2203.515 4268.235
## 2017.3479 3060.589 2385.192 3735.986 2027.659 4093.520
## 2017.3507 3335.476 2659.707 4011.246 2301.976 4368.976
## 2017.3534 3521.390 2845.248 4197.532 2487.320 4555.460
## 2017.3562 4003.441 3326.927 4679.955 2968.802 5038.080
## 2017.3589 3730.069 3053.183 4406.955 2694.861 4765.277
## 2017.3616 3520.659 2843.401 4197.917 2484.882 4556.436
## 2017.3644 3084.626 2406.997 3762.256 2048.281 4120.971
## 2017.3671 2756.663 2078.662 3434.664 1719.750 3793.576
## 2017.3699 3071.143 2392.771 3749.515 2033.662 4108.624
## 2017.3726 3172.336 2493.592 3851.079 2134.287 4210.384
## 2017.3753 3093.255 2414.141 3772.369 2054.640 4131.870
## 2017.3781 3084.416 2404.932 3763.901 2045.234 4123.598
## 2017.3808 3109.787 2429.932 3789.642 2070.038 4149.535
## 2017.3836 3179.455 2499.230 3859.680 2139.140 4219.769
## 2017.3863 3394.270 2713.674 4074.865 2353.389 4435.150
## 2017.3890 3552.943 2871.978 4233.908 2511.497 4594.389
## 2017.3918 3859.089 3177.754 4540.423 2817.078 4901.100
## 2017.3945 4150.610 3468.906 4832.314 3108.034 5193.186
## 2017.3973 4324.860 3642.787 5006.933 3281.720 5368.001
## 2017.4000 3763.745 3081.303 4446.187 2720.040 4807.449
## 2017.4027 3398.522 2715.711 4081.333 2354.253 4442.791
## 2017.4055 3612.156 2928.977 4295.336 2567.324 4656.989
## 2017.4082 3445.018 2761.471 4128.566 2399.622 4490.414
## 2017.4110 3699.963 3016.047 4383.878 2654.003 4745.922
## 2017.4137 3553.186 2868.902 4237.470 2506.664 4599.708
## 2017.4164 3535.979 2851.327 4220.631 2488.895 4583.063
## 2017.4192 3552.932 2867.913 4237.951 2505.285 4600.578
## 2017.4219 3663.724 2978.337 4349.110 2615.515 4711.932
## 2017.4247 3505.886 2820.132 4191.640 2457.116 4554.656
## 2017.4274 3799.802 3113.681 4485.922 2750.470 4849.133
## 2017.4301 4073.824 3387.337 4760.312 3023.932 5123.716
## 2017.4329 4295.572 3608.717 4982.426 3245.119 5346.025
## 2017.4356 4400.551 3713.331 5087.772 3349.538 5451.565
## 2017.4384 4469.726 3782.139 5157.313 3418.153 5521.300
## 2017.4411 4341.814 3653.861 5029.767 3289.681 5393.947
## 2017.4438 3945.363 3257.045 4633.682 2892.671 4998.056
## 2017.4466 3978.665 3289.981 4667.349 2925.413 5031.917
## 2017.4493 4302.103 3613.053 4991.153 3248.292 5355.914
## 2017.4521 4960.519 4271.104 5649.934 3906.150 6014.888
## 2017.4548 5078.827 4389.047 5768.608 4023.900 6133.755
## 2017.4575 5133.073 4442.928 5823.218 4077.587 6188.558
## 2017.4603 4728.525 4038.015 5419.034 3672.482 5784.568
## 2017.4630 4260.882 3570.008 4951.756 3204.282 5317.483
## 2017.4658 4707.179 4015.940 5398.417 3650.021 5764.337
## 2017.4685 4860.745 4169.143 5552.348 3803.031 5918.460
## 2017.4712 5060.826 4368.859 5752.792 4002.555 6119.097
## 2017.4740 5131.918 4439.588 5824.248 4073.090 6190.745
## 2017.4767 4955.057 4262.363 5647.750 3895.674 6014.440
## 2017.4795 4647.333 3954.276 5340.390 3587.394 5707.272
## 2017.4822 4657.472 3964.052 5350.892 3596.978 5717.967
## 2017.4849 4422.713 3728.930 5116.496 3361.663 5483.762
## 2017.4877 4822.644 4128.498 5516.790 3761.040 5884.248
## 2017.4904 4578.652 3884.144 5273.160 3516.493 5640.811
## 2017.4932 4635.440 3940.570 5330.311 3572.727 5698.153
## 2017.4959 4479.087 3783.854 5174.320 3415.820 5542.354
## 2017.4986 4332.566 3636.971 5028.161 3268.746 5396.387
## 2017.5014 4351.780 3655.824 5047.737 3287.406 5416.154
## 2017.5041 4164.353 3468.035 4860.671 3099.426 5229.280
## 2017.5068 4749.665 4052.985 5446.344 3684.185 5815.144
## 2017.5096 5098.895 4401.854 5795.935 4032.862 6164.927
## 2017.5123 5189.198 4491.796 5886.600 4122.613 6255.782
## 2017.5151 4820.997 4123.234 5518.760 3753.861 5888.133
## 2017.5178 4200.279 3502.156 4898.403 3132.591 5267.967
## 2017.5205 4299.105 3600.621 4997.589 3230.866 5367.344
## 2017.5233 4829.600 4130.756 5528.445 3760.810 5898.390
## 2017.5260 4946.273 4247.069 5645.478 3876.932 6015.614
## 2017.5288 5104.214 4404.649 5803.778 4034.322 6174.105
## 2017.5315 4700.125 4000.201 5400.049 3629.684 5770.567
## 2017.5342 4050.756 3350.472 4751.039 2979.764 5121.747
## 2017.5370 4297.631 3596.988 4998.274 3226.090 5369.172
## 2017.5397 4603.779 3902.776 5304.781 3531.688 5675.869
## 2017.5425 4864.097 4162.736 5565.459 3791.458 5936.737
## 2017.5452 4993.928 4292.208 5695.649 3920.740 6067.117
## 2017.5479 5103.180 4401.101 5805.259 4029.443 6176.917
## 2017.5507 5220.645 4518.208 5923.082 4146.360 6294.930
## 2017.5534 5233.496 4530.700 5936.291 4158.663 6308.329
## 2017.5562 5026.438 4323.284 5729.592 3951.057 6101.819
## 2017.5589 4994.742 4291.231 5698.254 3918.814 6070.670
## 2017.5616 5152.746 4448.877 5856.615 4076.271 6229.221
## 2017.5644 4780.687 4076.460 5484.914 3703.665 5857.709
## 2017.5671 4772.940 4068.356 5477.525 3695.372 5850.509
## 2017.5699 4791.521 4086.579 5496.462 3713.406 5869.636
## 2017.5726 4478.655 3773.356 5183.953 3399.994 5557.315
## 2017.5753 4214.457 3508.801 4920.112 3135.250 5293.663
## 2017.5781 4525.950 3819.938 5231.962 3446.198 5605.702
## 2017.5808 5065.699 4359.330 5772.067 3985.401 6145.996
## 2017.5836 5153.832 4447.108 5860.557 4072.990 6234.675
## 2017.5863 5160.372 4453.291 5867.453 4078.985 6241.759
## 2017.5890 5219.761 4512.325 5927.198 4137.830 6301.693
## 2017.5918 5092.129 4384.336 5799.921 4009.653 6174.604
## 2017.5945 4744.044 4035.896 5452.192 3661.025 5827.063
## 2017.5973 4676.665 3968.161 5385.168 3593.102 5760.227
## 2017.6000 4869.197 4160.338 5578.056 3785.091 5953.303
## 2017.6027 4899.089 4189.875 5608.303 3814.440 5983.738
## 2017.6055 5035.578 4326.009 5745.147 3950.386 6120.770
## 2017.6082 5276.528 4566.605 5986.451 4190.794 6362.262
## 2017.6110 5171.149 4460.871 5881.427 4084.873 6257.425
## 2017.6137 4444.488 3733.856 5155.121 3357.670 5531.306
## 2017.6164 3979.175 3268.189 4690.162 2891.816 5066.535
## 2017.6192 4163.599 3452.258 4874.939 3075.698 5251.500
## 2017.6219 4331.044 3619.350 5042.739 3242.602 5419.487
## 2017.6247 4501.473 3789.425 5213.520 3412.489 5590.456
## 2017.6274 4536.971 3824.570 5249.372 3447.448 5626.495
## 2017.6301 4455.202 3742.447 5167.956 3365.138 5545.266
## 2017.6329 3847.988 3134.881 4561.096 2757.385 4938.592
## 2017.6356 3592.053 2878.592 4305.513 2500.909 4683.197
## 2017.6384 3960.601 3246.788 4674.415 2868.918 5052.285
## 2017.6411 4495.452 3781.286 5209.617 3403.229 5587.674
## 2017.6438 4818.486 4103.968 5533.004 3725.724 5911.247
## 2017.6466 4847.541 4132.671 5562.412 3754.241 5940.841
## 2017.6493 4499.255 3784.033 5214.478 3405.417 5593.094
## 2017.6521 4112.925 3397.351 4828.499 3018.548 5207.302
## 2017.6548 4252.164 3536.238 4968.090 3157.249 5347.078
## 2017.6575 4492.027 3775.749 5208.305 3396.575 5587.479
## 2017.6603 4542.117 3825.488 5258.746 3446.127 5638.106
## 2017.6630 4601.063 3884.082 5318.043 3504.536 5697.589
## 2017.6658 4107.656 3390.325 4824.988 3010.593 5204.720
## 2017.6685 3955.578 3237.895 4673.260 2857.977 5053.178
## 2017.6712 3667.568 2949.535 4385.601 2569.432 4765.705
## 2017.6740 3820.592 3102.209 4538.975 2721.920 4919.265
## 2017.6767 4246.298 3527.565 4965.032 3147.090 5345.507
## 2017.6795 4734.565 4015.481 5453.648 3634.821 5834.308
## 2017.6822 4799.600 4080.167 5519.034 3699.321 5899.879
## 2017.6849 4951.031 4231.247 5670.815 3850.217 6051.845
## 2017.6877 4906.658 4186.525 5626.791 3805.309 6008.007
## 2017.6904 3935.137 3214.655 4655.620 2833.254 5037.021
## 2017.6932 3330.866 2610.034 4051.698 2228.449 4433.284
## 2017.6959 3988.991 3267.810 4710.172 2886.039 5091.942
## 2017.6986 4339.635 3618.104 5061.165 3236.149 5443.120
## 2017.7014 4054.392 3332.513 4776.271 2950.373 5158.411
## 2017.7041 4007.334 3285.106 4729.562 2902.782 5111.886
## 2017.7068 3918.101 3195.524 4640.677 2813.016 5023.185
## 2017.7096 3737.942 3015.017 4460.866 2632.324 4843.559
## 2017.7123 3606.455 2883.183 4329.728 2500.305 4712.605
## 2017.7151 4419.976 3696.355 5143.596 3313.294 5526.658
## 2017.7178 4766.721 4042.753 5490.689 3659.507 5873.935
## 2017.7205 4667.091 3942.775 5391.407 3559.345 5774.836
## 2017.7233 4436.870 3712.207 5161.534 3328.593 5545.147
## 2017.7260 4320.354 3595.343 5045.365 3211.546 5429.162
## 2017.7288 4247.735 3522.377 4973.093 3138.395 5357.074
## 2017.7315 3605.465 2879.760 4331.170 2495.595 4715.335
## 2017.7342 3360.324 2634.272 4086.375 2249.923 4470.724
## 2017.7370 3337.324 2610.926 4063.723 2226.394 4448.255
## 2017.7397 3579.476 2852.731 4306.221 2468.016 4690.936
## 2017.7425 3404.444 2677.353 4131.535 2292.454 4516.434
## 2017.7452 3274.944 2547.507 4002.381 2162.425 4387.463
## 2017.7479 3103.096 2375.312 3830.879 1990.047 4216.144
## 2017.7507 3180.964 2452.835 3909.093 2067.387 4294.541
## 2017.7534 3604.637 2876.162 4333.112 2490.531 4718.743
## 2017.7562 3803.377 3074.557 4532.197 2688.743 4918.011
## 2017.7589 3919.282 3190.116 4648.447 2804.119 5034.444
## 2017.7616 4255.578 3526.067 4985.088 3139.887 5371.268
## 2017.7644 3445.160 2715.304 4175.015 2328.942 4561.377
## 2017.7671 2884.797 2154.596 3614.997 1768.052 4001.542
## 2017.7699 2829.383 2098.838 3559.928 1712.111 3946.656
## 2017.7726 3230.395 2499.505 3961.284 2112.595 4348.194
## 2017.7753 3477.261 2746.027 4208.495 2358.935 4595.587
## 2017.7781 3556.219 2824.641 4287.797 2437.367 4675.071
## 2017.7808 3146.966 2415.044 3878.888 2027.588 4266.344
## 2017.7836 3164.177 2431.911 3896.443 2044.273 4284.081
## 2017.7863 3302.565 2569.955 4035.175 2182.135 4422.995
## 2017.7890 3571.200 2838.247 4304.154 2450.245 4692.156
## 2017.7918 4074.023 3340.726 4807.320 2952.543 5195.504
## 2017.7945 3935.678 3202.038 4669.318 2813.672 5057.683
## 2017.7973 3686.603 2952.620 4420.586 2564.073 4809.133
## 2017.8000 3450.494 2716.168 4184.820 2327.440 4573.549
## 2017.8027 3088.189 2353.520 3822.858 1964.610 4211.768
## 2017.8055 2929.409 2194.397 3664.420 1805.306 4053.511
## 2017.8082 2861.672 2126.318 3597.025 1737.045 3986.298
## 2017.8110 3251.825 2516.129 3987.521 2126.676 4376.975
## 2017.8137 3523.768 2787.730 4259.806 2398.095 4649.441
## 2017.8164 3493.869 2757.489 4230.249 2367.673 4620.065
## 2017.8192 3453.892 2717.170 4190.613 2327.173 4580.610
## 2017.8219 3594.876 2857.813 4331.940 2467.635 4722.117
## 2017.8247 3371.833 2634.428 4109.238 2244.070 4499.596
## 2017.8274 3049.127 2311.381 3786.873 1920.841 4177.412
## 2017.8301 3307.596 2569.509 4045.683 2178.789 4436.403
## 2017.8329 3599.046 2860.617 4337.474 2469.717 4728.374
## 2017.8356 3803.645 3064.876 4542.414 2673.796 4933.495
## 2017.8384 3494.751 2755.641 4233.860 2364.380 4625.122
## 2017.8411 3244.074 2504.624 3983.525 2113.183 4374.966
## 2017.8438 2933.262 2193.472 3673.053 1801.850 4064.674
## 2017.8466 2779.162 2039.032 3519.293 1647.230 3911.095
## 2017.8493 3071.749 2331.278 3812.220 1939.297 4204.201
## 2017.8521 3116.386 2375.575 3857.196 1983.413 4249.358
## 2017.8548 3127.439 2386.289 3868.589 1993.947 4260.931
## 2017.8575 3054.226 2312.736 3795.716 1920.215 4188.237
## 2017.8603 3081.455 2339.626 3823.285 1946.925 4215.985
## 2017.8630 2883.823 2141.654 3625.991 1748.773 4018.872
## 2017.8658 2771.852 2029.344 3514.359 1636.284 3907.419
## 2017.8685 3052.491 2309.644 3795.337 1916.404 4188.577
## 2017.8712 3148.879 2405.693 3892.065 2012.275 4285.483
## 2017.8740 3171.490 2427.966 3915.014 2034.368 4308.612
## 2017.8767 3266.221 2522.358 4010.083 2128.581 4403.861
## 2017.8795 3171.964 2427.763 3916.165 2033.807 4310.121
## 2017.8822 3170.669 2426.129 3915.208 2031.994 4309.343
## 2017.8849 3082.073 2337.196 3826.950 1942.882 4221.265
## 2017.8877 3225.543 2480.328 3970.758 2085.835 4365.251
## 2017.8904 3161.958 2416.405 3907.511 2021.733 4302.183
## 2017.8932 3123.526 2377.635 3869.416 1982.785 4264.267
## 2017.8959 2988.276 2242.048 3734.504 1847.019 4129.533
## 2017.8986 2859.629 2113.064 3606.194 1717.856 4001.402
## 2017.9014 3050.203 2303.301 3797.106 1907.915 4192.492
## 2017.9041 2994.761 2247.522 3742.001 1851.958 4137.565
## 2017.9068 3179.450 2431.874 3927.026 2036.131 4322.769
## 2017.9096 3335.698 2587.785 4083.610 2191.864 4479.532
## 2017.9123 3481.572 2733.323 4229.822 2337.224 4625.921
## 2017.9151 3580.194 2831.608 4328.780 2435.331 4725.057
## 2017.9178 3456.748 2707.827 4205.670 2311.371 4602.126
## 2017.9205 3282.769 2533.511 4032.027 2136.878 4428.660
## 2017.9233 3191.733 2442.139 3941.326 2045.328 4338.137
## 2017.9260 3578.018 2828.088 4327.947 2431.100 4724.936
## 2017.9288 3626.937 2876.671 4377.202 2479.505 4774.368
## 2017.9315 3827.147 3076.547 4577.748 2679.203 4975.092
## 2017.9342 4163.415 3412.479 4914.351 3014.957 5311.872
## 2017.9370 4212.129 3460.858 4963.400 3063.159 5361.099
## 2017.9397 3790.885 3039.279 4542.491 2641.402 4940.367
## 2017.9425 3367.898 2615.957 4119.839 2217.904 4517.893
## 2017.9452 3639.058 2886.782 4391.333 2488.551 4789.564
## 2017.9479 3792.705 3040.095 4545.315 2641.687 4943.723
## 2017.9507 4074.419 3321.475 4827.364 2922.890 5225.949
## 2017.9534 4141.925 3388.646 4895.204 2989.885 5293.966
## 2017.9562 3946.058 3192.445 4699.671 2793.506 5098.609
## 2017.9589 3689.254 2935.307 4443.201 2536.192 4842.316
## 2017.9616 4540.292 3786.011 5294.573 3386.719 5693.865
## 2017.9644 4608.648 3854.033 5363.262 3454.564 5762.731
## 2017.9671 4306.842 3551.894 5061.790 3152.249 5461.435
## 2017.9699 3878.007 3122.725 4633.288 2722.903 5033.110
## 2017.9726 3819.204 3063.590 4574.819 2663.591 4974.817
## 2017.9753 3749.214 2993.267 4505.162 2593.092 4905.337
## 2017.9781 3300.504 2544.224 4056.785 2143.873 4457.136
## 2017.9808 2889.002 2132.389 3645.615 1731.862 4046.142
## 2017.9836 2809.903 2052.957 3566.849 1652.254 3967.552
## 2017.9863 3234.003 2476.724 3991.281 2075.845 4392.160
## 2017.9890 3265.974 2508.364 4023.585 2107.309 4424.640
## 2017.9918 3356.621 2598.678 4114.564 2197.447 4515.795
## 2017.9945 3533.750 2775.475 4292.025 2374.068 4693.432
## 2017.9973 3227.560 2468.953 3986.167 2067.371 4387.750
## 2018.0000 3191.712 2432.773 3950.651 2031.015 4352.409
## 2018.0027 3313.118 2448.865 4177.370 1991.358 4634.878
the ARIMA forecast appears realistic when compared against the actual out of sample data (Green over blue forecast, red being within sample data) (will be input as jpeg, R will do it but it throws a warning and wont self-publish it).
check the residuals:
checkresiduals(arimaModel2015_2016)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(1,1,2)(0,1,0)[365]
## Q* = 770.27, df = 144, p-value < 2.2e-16
##
## Model df: 3. Total lags used: 147
arimaModel2015_2016
## Series: LoadTimeSeries2015_2016
## ARIMA(1,1,2)(0,1,0)[365]
##
## Coefficients:
## ar1 ma1 ma2
## 0.5204 -0.4773 -0.4952
## s.e. 0.0575 0.0565 0.0529
##
## sigma^2 estimated as 93093: log likelihood=-2616.11
## AIC=5240.22 AICc=5240.33 BIC=5255.83
#not useful but looks pretty cool
plot(forecast(arimaModel2015_2016, h = 7, level = 95), showgap = T,PI = T, col = "red", fcol = "blue", shaded = T, ylim = c(0,6000) )
now for the multpile regression data. I will import temperature data from a weather station at Will Rogers World Airport in Oklahoma City.
tempData <- read.csv("C:/Users/Owner/Downloads/1970977.csv")
head(tempData)
## STATION NAME DATE TAVG
## 1 USW00013967 OKLAHOMA CITY WILL ROGERS WORLD AIRPORT, OK US 2015-01-01 27
## 2 USW00013967 OKLAHOMA CITY WILL ROGERS WORLD AIRPORT, OK US 2015-01-02 33
## 3 USW00013967 OKLAHOMA CITY WILL ROGERS WORLD AIRPORT, OK US 2015-01-03 37
## 4 USW00013967 OKLAHOMA CITY WILL ROGERS WORLD AIRPORT, OK US 2015-01-04 28
## 5 USW00013967 OKLAHOMA CITY WILL ROGERS WORLD AIRPORT, OK US 2015-01-05 26
## 6 USW00013967 OKLAHOMA CITY WILL ROGERS WORLD AIRPORT, OK US 2015-01-06 36
## TMAX TMIN
## 1 34 24
## 2 37 31
## 3 42 35
## 4 34 18
## 5 44 16
## 6 48 28
#recognize the date:
tempData$DATE <- as.Date(tempData$DATE, "%Y-%m-%d")
View(tempData)
the data for matching daily average, minumum, and maximum temperatures is in.
Now I will plot Load as a function of Temperature:
twoyearTempData <- as.data.frame(tempData$TAVG[1:731])
twoyearTempData$var2 <- as.double(twoYearLoadData$OKGE[1:731])
plot(twoyearTempData$var2 ~ twoyearTempData$`tempData$TAVG[1:731]`, xlab = "Daily Average Temperature in Fahrenheit", ylab = "Daily Average Load (MW)", main = "Load as a Function of Temperature", col = "red")
It appears a linear model based on daily average temperature would not be realistic due to the problem of heteroskedasticity. The shotgun pattern in the data show an increase in variance at higher temperatures.
I need to combine two models for the project. I will try a few different modeling methods.
?forecast
## starting httpd help server ... done
etsForecast <- ets(LoadTimeSeries2015_2016, opt.crit = "mse")
## Warning in ets(LoadTimeSeries2015_2016, opt.crit = "mse"): Missing values
## encountered. Using longest contiguous portion of time series
## Warning in ets(LoadTimeSeries2015_2016, opt.crit = "mse"): I can't handle data
## with frequency greater than 24. Seasonality will be ignored. Try stlf() if you
## need seasonal forecasts.
plot(forecast(etsForecast, h = 365, level = 95), showgap = T,PI = T, col = "red", fcol = "blue", shaded = T)
the ets model appears to perform worse.
tbatsForecast <- tbats(LoadTimeSeries2015_2016)
## Warning in tbats(LoadTimeSeries2015_2016): Missing values encountered. Using
## longest contiguous portion of time series
plot(forecast(tbatsForecast, h = 365, level = 95), showgap = T,PI = T, col = "red", fcol = "blue", shaded = T)
interesting, this model doesnt look too bad and its quick.
nnetarForecast <- nnetar(LoadTimeSeries2015_2016[1:732])
plot(forecast(nnetarForecast, h = 365, level = 95), showgap = T,PI = T, col = "red", fcol = "blue", shaded = T)
This one looks interesting but it does not appear realistic.
The forecasting methods that appear to most accuratly reflect the real-world out of sample data are the ARIMA model, and the TBATS model.
I will now measure their out of sample forecast accuracy with the RMSE. I will begin with extracting the forecasted points from the ARIMA model, then match them with the actual data points. finally calculate the RMSE.
plot(future$mean)
arimaForecastPoints <- as.data.frame(future$mean)
arimaForecastPoints$var2 <- (avgDailyLoad2017$dailyAvg2017[1:365])
head(arimaForecastPoints)
## x var2
## 1 3606.646 2862.665
## 2 3845.291 2866.679
## 3 3727.556 3388.192
## 4 3688.531 4102.988
## 5 3639.016 4165.095
## 6 3794.739 4578.311
errorArima <- (arimaForecastPoints$x - arimaForecastPoints$var2)
errorArima
## Time Series:
## Start = c(2017, 3)
## End = c(2018, 2)
## Frequency = 365
## [1] 743.9815346 978.6126582 339.3635663 -414.4574003 -526.0791150
## [6] -783.5715934 -450.1927911 32.3980288 11.3733347 356.8230756
## [11] 302.2260342 25.1004499 -383.9713521 -101.7451882 456.0911963
## [16] 635.5393835 549.6377405 579.8820743 832.8881954 601.6949838
## [21] 451.5341173 569.0205435 456.0404885 579.2905666 314.5938772
## [26] -351.7774462 -695.0916911 -544.4301468 191.1301880 -7.0421447
## [31] 479.6841057 612.9651476 4.5377727 -449.3719356 -349.8758106
## [36] 364.8804394 632.0734395 561.1263978 16.9829811 -309.3046855
## [41] -240.4251439 207.3052728 313.4450228 68.1750228 -183.7055189
## [46] -379.0239772 -367.6931022 -345.3702272 -159.0098522 277.8583978
## [51] 394.7517728 527.6177311 330.2678978 446.3344811 -96.5216439
## [56] -477.1078522 -22.8241855 -133.8868522 106.0550228 -67.0316022
## [61] -143.2074772 -394.9626439 -276.2788939 111.7523145 -28.0314355
## [66] -7.5525189 -175.4700189 -73.5683939 -254.0056022 -237.6876439
## [71] -217.4875189 -310.1161022 -428.6875605 -462.4142272 -312.1247689
## [76] -79.0391855 118.2446895 274.7226478 -271.7261855 -361.4014355
## [81] -14.0243105 -94.0270605 -395.8314355 11.1896895 453.9273978
## [86] 246.0950228 184.8433978 36.4351895 -139.4152689 -180.0338105
## [91] -97.8790605 348.0181478 333.1683978 179.0071895 3.3054811
## [96] 34.1685228 -157.8279772 -57.0463939 65.9003145 -186.8409772
## [101] 10.0131061 -117.4924772 -29.6065605 -223.5287689 -299.0618105
## [106] 126.5544811 76.6132311 -168.2223522 -358.9546855 -332.0595189
## [111] 107.0469811 219.1230228 698.9730228 701.8881895 84.9726061
## [116] 7.2864395 123.1646895 -197.9425189 -234.7049772 121.1098145
## [121] -37.0964772 36.4969395 33.4568561 222.5385645 171.8931478
## [126] 57.1905645 137.4573561 -44.6613105 352.5401895 121.2962311
## [131] 99.8264811 -121.0143522 -262.1900605 -101.7968105 -608.2169355
## [136] -673.7113105 -459.8169355 -639.5061439 -120.5722689 392.4499811
## [141] 760.6329811 771.4224395 1045.8175645 1304.0645228 481.4062311
## [146] -494.7625605 -399.7921022 -148.1290605 345.8129395 -165.4973522
## [151] -442.4329355 -407.5923939 46.3242311 168.0221895 495.0923978
## [156] 333.2910645 229.1661061 431.7556478 652.1830228 425.9678145
## [161] -50.6912272 -119.8264355 -134.7710189 315.3651061 373.8668978
## [166] 370.0078561 32.3030228 -389.6071022 715.8483145 1009.9434395
## [171] 735.4100645 615.3626061 492.2316895 -48.5355605 873.2079811
## [176] 720.1623978 823.3256895 250.5505645 44.9868561 -135.7804772
## [181] -176.3241855 442.4600228 118.0161478 841.9313145 1321.5456478
## [186] 1142.9243978 328.5151061 -558.8871439 -95.5784355 768.5384395
## [191] 304.2980228 168.6343561 -365.1839355 -947.2888939 -648.7287689
## [196] -73.2894772 504.3542728 174.4300228 133.2675645 37.8917311
## [201] -42.7038522 -325.7450189 -158.1086022 203.4422728 71.8553561
## [206] -338.6948522 -469.7296439 -600.5139772 -631.1654772 -38.7110189
## [211] 956.6291895 918.6880228 1267.0458145 1266.7576895 714.8497728
## [216] 379.1478561 366.8725645 679.4043978 846.8856895 892.8488978
## [221] 960.2828978 723.4584395 201.0060645 189.2958145 654.0909395
## [226] 206.9861061 149.3545228 161.7467311 93.5369811 -664.7060189
## [231] -1059.5399355 -704.3496855 -312.5069355 0.6692728 520.2878561
## [236] 391.1334811 144.5502311 541.0403145 613.1462311 349.2741895
## [241] 629.8645228 199.0607311 1.0203978 -284.8126439 -25.6926439
## [246] 280.7161895 531.3382728 709.7517311 1475.8980645 1364.2212728
## [251] 283.9107311 -217.7266855 508.9741478 659.1388145 463.2686895
## [256] 406.8135645 -2.7495189 -571.0671022 -547.2592272 516.4219811
## [261] 944.7298978 291.8258145 -260.2148522 -486.0259772 -384.8471022
## [266] -577.5360189 -633.0331022 -728.1533522 -168.0808522 16.8140228
## [271] NA -186.9360605 -38.8401022 391.4136061 82.4152728
## [276] -19.4879772 402.3624811 -235.8485605 -913.7684355 -686.0111439
## [281] 133.4886895 -51.3226022 355.2285645 128.6106895 5.1114811
## [286] -293.3344772 -201.4525605 926.1600645 968.5108978 577.7107728
## [291] 303.0760645 4.7126895 -147.1422272 -269.4918939 582.7151478
## [296] 642.7013145 491.6435228 397.0671895 458.6073145 177.6886895
## [301] -116.3373939 293.1175228 514.7375645 515.1347728 174.1544395
## [306] 51.9614811 -238.9284772 -234.0726855 67.1768145 -35.9909355
## [311] -228.9633522 -404.7848522 -378.3704355 -400.4898105 -339.2745189
## [316] 178.4076478 -35.2241022 -101.9974355 60.2368978 -68.8422272
## [321] -68.9473105 20.2231478 149.1605228 -147.0701855 -154.7416022
## [326] -439.3971855 -319.4183105 212.0645645 194.9122728 244.2484811
## [331] 147.6543978 240.5896478 311.1879395 125.9771061 -67.1380605
## [336] 118.2851895 636.4246478 444.8173978 351.3527311 490.0093561
## [341] 439.8525228 -358.6643105 -325.9313105 211.8859811 375.6648145
## [346] 548.1348978 474.3280645 448.6399395 13.7796478 938.5868978
## [351] 1264.2507311 785.8625645 361.2510228 444.1961895 334.3663145
## [356] -442.6463522 -908.0676022 -809.3265605 -471.6918522 -571.0613939
## [361] -851.2433522 -569.0393522 -673.5119772 -690.4754534 -967.0328586
errorSquared <- (errorArima * errorArima)
errorSquared
## Time Series:
## Start = c(2017, 3)
## End = c(2018, 2)
## Frequency = 365
## [1] 5.535085e+05 9.576827e+05 1.151676e+05 1.717749e+05 2.767592e+05
## [6] 6.139844e+05 2.026735e+05 1.049632e+03 1.293527e+02 1.273227e+05
## [11] 9.134058e+04 6.300326e+02 1.474340e+05 1.035208e+04 2.080192e+05
## [16] 4.039103e+05 3.021016e+05 3.362632e+05 6.937027e+05 3.620369e+05
## [21] 2.038831e+05 3.237844e+05 2.079729e+05 3.355776e+05 9.896931e+04
## [26] 1.237474e+05 4.831525e+05 2.964042e+05 3.653075e+04 4.959180e+01
## [31] 2.300968e+05 3.757263e+05 2.059138e+01 2.019351e+05 1.224131e+05
## [36] 1.331377e+05 3.995168e+05 3.148628e+05 2.884216e+02 9.566939e+04
## [41] 5.780425e+04 4.297548e+04 9.824778e+04 4.647834e+03 3.374772e+04
## [46] 1.436592e+05 1.351982e+05 1.192806e+05 2.528413e+04 7.720529e+04
## [51] 1.558290e+05 2.783805e+05 1.090769e+05 1.992145e+05 9.316428e+03
## [56] 2.276319e+05 5.209434e+02 1.792569e+04 1.124767e+04 4.493236e+03
## [61] 2.050838e+04 1.559955e+05 7.633003e+04 1.248858e+04 7.857614e+02
## [66] 5.704054e+01 3.078973e+04 5.412309e+03 6.451885e+04 5.649542e+04
## [71] 4.730082e+04 9.617200e+04 1.837730e+05 2.138269e+05 9.742187e+04
## [76] 6.247193e+03 1.398181e+04 7.547253e+04 7.383512e+04 1.306110e+05
## [81] 1.966813e+02 8.841088e+03 1.566825e+05 1.252092e+02 2.060501e+05
## [86] 6.056276e+04 3.416708e+04 1.327523e+03 1.943662e+04 3.241217e+04
## [91] 9.580310e+03 1.211166e+05 1.110012e+05 3.204357e+04 1.092621e+01
## [96] 1.167488e+03 2.490967e+04 3.254291e+03 4.342851e+03 3.490955e+04
## [101] 1.002623e+02 1.380448e+04 8.765484e+02 4.996511e+04 8.943797e+04
## [106] 1.601604e+04 5.869587e+03 2.829876e+04 1.288485e+05 1.102635e+05
## [111] 1.145906e+04 4.801490e+04 4.885633e+05 4.926470e+05 7.220344e+03
## [116] 5.309220e+01 1.516954e+04 3.918124e+04 5.508643e+04 1.466759e+04
## [121] 1.376149e+03 1.332027e+03 1.119361e+03 4.952341e+04 2.954725e+04
## [126] 3.270761e+03 1.889452e+04 1.994633e+03 1.242846e+05 1.471278e+04
## [131] 9.965326e+03 1.464447e+04 6.874363e+04 1.036259e+04 3.699278e+05
## [136] 4.538869e+05 2.114316e+05 4.089681e+05 1.453767e+04 1.540170e+05
## [141] 5.785625e+05 5.950926e+05 1.093734e+06 1.700584e+06 2.317520e+05
## [146] 2.447900e+05 1.598337e+05 2.194222e+04 1.195866e+05 2.738937e+04
## [151] 1.957469e+05 1.661316e+05 2.145934e+03 2.823146e+04 2.451165e+05
## [156] 1.110829e+05 5.251710e+04 1.864129e+05 4.253427e+05 1.814486e+05
## [161] 2.569601e+03 1.435837e+04 1.816323e+04 9.945515e+04 1.397765e+05
## [166] 1.369058e+05 1.043485e+03 1.517937e+05 5.124388e+05 1.019986e+06
## [171] 5.408280e+05 3.786711e+05 2.422920e+05 2.355701e+03 7.624922e+05
## [176] 5.186339e+05 6.778652e+05 6.277559e+04 2.023817e+03 1.843634e+04
## [181] 3.109022e+04 1.957709e+05 1.392781e+04 7.088483e+05 1.746483e+06
## [186] 1.306276e+06 1.079222e+05 3.123548e+05 9.135237e+03 5.906513e+05
## [191] 9.259729e+04 2.843755e+04 1.333593e+05 8.973562e+05 4.208490e+05
## [196] 5.371347e+03 2.543732e+05 3.042583e+04 1.776024e+04 1.435783e+03
## [201] 1.823619e+03 1.061098e+05 2.499833e+04 4.138876e+04 5.163192e+03
## [206] 1.147142e+05 2.206459e+05 3.606170e+05 3.983699e+05 1.498543e+03
## [211] 9.151394e+05 8.439877e+05 1.605405e+06 1.604675e+06 5.110102e+05
## [216] 1.437531e+05 1.345955e+05 4.615903e+05 7.172154e+05 7.971792e+05
## [221] 9.221432e+05 5.233921e+05 4.040344e+04 3.583291e+04 4.278350e+05
## [226] 4.284325e+04 2.230677e+04 2.616201e+04 8.749167e+03 4.418341e+05
## [231] 1.122625e+06 4.961085e+05 9.766058e+04 4.479261e-01 2.706995e+05
## [236] 1.529854e+05 2.089477e+04 2.927246e+05 3.759483e+05 1.219925e+05
## [241] 3.967293e+05 3.962517e+04 1.041212e+00 8.111824e+04 6.601119e+02
## [246] 7.880158e+04 2.823204e+05 5.037475e+05 2.178275e+06 1.861100e+06
## [251] 8.060530e+04 4.740491e+04 2.590547e+05 4.344640e+05 2.146179e+05
## [256] 1.654973e+05 7.559854e+00 3.261176e+05 2.994927e+05 2.666917e+05
## [261] 8.925146e+05 8.516231e+04 6.771177e+04 2.362213e+05 1.481073e+05
## [266] 3.335479e+05 4.007309e+05 5.302073e+05 2.825117e+04 2.827114e+02
## [271] NA 3.494509e+04 1.508554e+03 1.532046e+05 6.792277e+03
## [276] 3.797813e+02 1.618956e+05 5.562454e+04 8.349728e+05 4.706113e+05
## [281] 1.781923e+04 2.634009e+03 1.261873e+05 1.654071e+04 2.612724e+01
## [286] 8.604512e+04 4.058313e+04 8.577725e+05 9.380134e+05 3.337497e+05
## [291] 9.185510e+04 2.220944e+01 2.165084e+04 7.262588e+04 3.395569e+05
## [296] 4.130650e+05 2.417134e+05 1.576624e+05 2.103207e+05 3.157327e+04
## [301] 1.353439e+04 8.591788e+04 2.649548e+05 2.653638e+05 3.032977e+04
## [306] 2.699996e+03 5.708682e+04 5.479002e+04 4.512724e+03 1.295347e+03
## [311] 5.242422e+04 1.638508e+05 1.431642e+05 1.603921e+05 1.151072e+05
## [316] 3.182929e+04 1.240737e+03 1.040348e+04 3.628484e+03 4.739252e+03
## [321] 4.753732e+03 4.089757e+02 2.224886e+04 2.162964e+04 2.394496e+04
## [326] 1.930699e+05 1.020281e+05 4.497138e+04 3.799079e+04 5.965732e+04
## [331] 2.180182e+04 5.788338e+04 9.683793e+04 1.587023e+04 4.507519e+03
## [336] 1.399139e+04 4.050363e+05 1.978625e+05 1.234487e+05 2.401092e+05
## [341] 1.934702e+05 1.286401e+05 1.062312e+05 4.489567e+04 1.411241e+05
## [346] 3.004519e+05 2.249871e+05 2.012778e+05 1.898787e+02 8.809454e+05
## [351] 1.598330e+06 6.175800e+05 1.305023e+05 1.973103e+05 1.118008e+05
## [356] 1.959358e+05 8.245868e+05 6.550095e+05 2.224932e+05 3.261111e+05
## [361] 7.246152e+05 3.238058e+05 4.536184e+05 4.767564e+05 9.351525e+05
library(tsbox)
## Warning: package 'tsbox' was built under R version 3.6.1
#somehow this became a time series now I have to put it back as a numeric vector.
errorSquared <- ts_df(errorSquared)
errortest <- errorSquared$value
meanError <- mean(errortest, na.rm = T)
meanError
## [1] 217777
RMSE <- sqrt(meanError)
RMSE
## [1] 466.6658
The RMSE for the ARIMA Model is 466.6658
now I will calculate the RMSE for the TBATS model.
tbatsTotalForecastData <-forecast(tbatsForecast, h = 365)
library(tsbox)
TbatsForecastPoints <- ts_df(tbatsTotalForecastData$mean)
TbatsForecastPoints$Actual <- (avgDailyLoad2017$dailyAvg2017[1:365])
errorBats <- TbatsForecastPoints$value - TbatsForecastPoints$Actual
errorSquaredBats <- errorBats*errorBats
meanErrorBats <- mean(errorSquaredBats, na.rm = T)
RMSE <- sqrt(meanErrorBats)
RMSE
## [1] 342.5353
It appears the TBATS model has a lower RMSE than the ARIMA model. 342.5353
I will weight the forecasts by their accuracy as measured by the RMSE. the TBATS model will be weighted heavier than the ARIMA model.
their weights are their inverse porportional error.
totalRMSE <- 342.5353 + 466.6658
ARIMAWeight <- 1-(466.6658/totalRMSE)
ARIMAWeight
## [1] 0.4233006
TBATSWeight <- 1-(342.5353/totalRMSE)
TBATSWeight
## [1] 0.5766994
the TBATS model will be weighted as 57% of the combined forecast, and the ARIMA model will be weighted as 42% of the combined forecast.
the specifications for the ARIMA forecast are:
arimaModel2015_2016
## Series: LoadTimeSeries2015_2016
## ARIMA(1,1,2)(0,1,0)[365]
##
## Coefficients:
## ar1 ma1 ma2
## 0.5204 -0.4773 -0.4952
## s.e. 0.0575 0.0565 0.0529
##
## sigma^2 estimated as 93093: log likelihood=-2616.11
## AIC=5240.22 AICc=5240.33 BIC=5255.83
the specifications for the TBATS model are:
tbatsForecast
## TBATS(0.002, {2,1}, -, {<365,6>})
##
## Call: tbats(y = LoadTimeSeries2015_2016)
##
## Parameters
## Lambda: 0.002352
## Alpha: 0.01956328
## Gamma-1 Values: -5.888553e-06
## Gamma-2 Values: -4.908293e-05
## AR coefficients: 0.66134 -0.149549
## MA coefficients: 0.40783
##
## Seed States:
## [,1]
## [1,] 8.344733212
## [2,] -0.112373456
## [3,] 0.105799916
## [4,] 0.004144564
## [5,] 0.018913529
## [6,] -0.008441220
## [7,] 0.002504026
## [8,] -0.096993135
## [9,] 0.089164714
## [10,] -0.008436778
## [11,] -0.018838742
## [12,] -0.006558487
## [13,] -0.013053801
## [14,] 0.000000000
## [15,] 0.000000000
## [16,] 0.000000000
## attr(,"lambda")
## [1] 0.002352119
##
## Sigma: 0.06007148
## AIC: 12705.81
I will combine the forecasts with their respective weights and test the combined out of sample accuracy.
arimadata <- ts_df(future$mean)
ARIMADualForecastPortion <- as.data.frame(.42 * arimadata$value)
TBATSDualForecastPortion <- as.data.frame(.57 * TbatsForecastPoints$value)
combinedForecast <- as.data.frame(ARIMADualForecastPortion + TBATSDualForecastPortion)
now I will check the RMSE of the combined forecast:
errorFinal = combinedForecast$`0.42 * arimadata$value` - avgDailyLoad2017$dailyAvg2017[1:365]
squareErrorFinal <- errorFinal * errorFinal
meanSquareErrorFinal <- mean(squareErrorFinal, na.rm = T)
RMSEFinal <- sqrt(meanSquareErrorFinal)
RMSEFinal
## [1] 350.1393
the final combined model is more accurate than the ARIMA model, and marginally less accurate than the BATS model.
plot combined forecast results:
plot(combinedForecast$`0.42 * arimadata$value`, col = "blue", xlab = "Out of Sample Time", ylab = "Load (MW)", main = "Results of Combined Forecast, Red as Actual Load", type = "l")+
lines(avgDailyLoad2017$dailyAvg2017[1:365], col = "red", type = "l")
## integer(0)