Libraries
require(fpp2)
## Loading required package: fpp2
## Warning: package 'fpp2' was built under R version 4.0.3
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## -- Attaching packages ---------------------------------------------- fpp2 2.4 --
## v ggplot2 3.3.2 v fma 2.4
## v forecast 8.13 v expsmooth 2.3
## Warning: package 'fma' was built under R version 4.0.3
## Warning: package 'expsmooth' was built under R version 4.0.3
##
require(forecast)
require(urca)
## Loading required package: urca
require(zoo)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
require(vars)
## Loading required package: vars
## Warning: package 'vars' was built under R version 4.0.3
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following objects are masked from 'package:fma':
##
## cement, housing, petrol
## Loading required package: strucchange
## Warning: package 'strucchange' was built under R version 4.0.3
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 4.0.3
## Loading required package: lmtest
require(tidyverse)
## Loading required package: tidyverse
## Warning: package 'tidyverse' was built under R version 4.0.3
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x stringr::boundary() masks strucchange::boundary()
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x dplyr::select() masks MASS::select()
require(seasonal)
## Loading required package: seasonal
## Warning: package 'seasonal' was built under R version 4.0.3
##
## Attaching package: 'seasonal'
## The following object is masked from 'package:tibble':
##
## view
require(corrplot)
## Loading required package: corrplot
## corrplot 0.84 loaded
require(psych)
## Loading required package: psych
## Warning: package 'psych' was built under R version 4.0.3
##
## Attaching package: 'psych'
## The following object is masked from 'package:seasonal':
##
## outlier
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
require(dplyr)
require(kableExtra)
## Loading required package: kableExtra
## Warning: package 'kableExtra' was built under R version 4.0.3
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
Import Data
cases.train<-read.csv("C:/Users/jbiasi/OneDrive - CoStar Realty Information, Inc/Documents/Dengai/dengue_labels_train.csv")
features.train<-read.csv("C:/Users/jbiasi/OneDrive - CoStar Realty Information, Inc/Documents/Dengai/dengue_features_train.csv")
features.test<-read.csv("C:/Users/jbiasi/OneDrive - CoStar Realty Information, Inc/Documents/Dengai/dengue_features_test.csv")
submission_format <- read.csv("C:/Users/jbiasi/OneDrive - CoStar Realty Information, Inc/Documents/Dengai/submission_format.csv")
#Seperating Data
train.all <- left_join(x = features.train, y = cases.train, by = c("year", "weekofyear", "city"))
test <- left_join(x = features.test, y = submission_format, by = c("year", "weekofyear", "city"))
Looking At missing values
missing_values<-summarise_all(train.all,funs(sum(is.na(.))/n()))
## Warning: `funs()` is deprecated as of dplyr 0.8.0.
## Please use a list of either functions or lambdas:
##
## # Simple named list:
## list(mean = mean, median = median)
##
## # Auto named with `tibble::lst()`:
## tibble::lst(mean, median)
##
## # Using lambdas
## list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
missing_values<-gather(missing_values,key="Feature",value = "Missing_percentage")
g<-ggplot(data=missing_values)
g<-g+geom_bar(stat="identity",aes(x=reorder(Feature,-Missing_percentage),y=Missing_percentage))
g<-g+coord_flip()+ggtitle("Missing %-Features")+ylab("Features")+xlab("Missing Percentage")
g
#replace missing values with mean
for(i in 5:24){
train.all[,i]<-replace_na(train.all[,i],mean(train.all[,i],na.rm = T))
test[,i]<-replace_na(features.test[,i],mean(features.test[,i],na.rm = T))
}
#split by city
train.sj <- train.all %>% filter(city == 'sj')
train.iq <- train.all %>% filter(city == 'iq')
test.sj <- train.all %>% filter(city == 'sj')
test.iq <- train.all %>% filter(city == 'iq')
Summarize Data
describe(cases.train[,4])
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 1456 24.68 43.6 12 15.97 13.34 0 461 461 5.26 36.33 1.14
describe(features.train[,5:24])
## vars n mean sd median trimmed
## ndvi_ne 1 1262 0.14 0.14 0.13 0.14
## ndvi_nw 2 1404 0.13 0.12 0.12 0.13
## ndvi_se 3 1434 0.20 0.07 0.20 0.20
## ndvi_sw 4 1434 0.20 0.08 0.19 0.20
## precipitation_amt_mm 5 1443 45.76 43.72 38.34 40.16
## reanalysis_air_temp_k 6 1446 298.70 1.36 298.65 298.72
## reanalysis_avg_temp_k 7 1446 299.23 1.26 299.29 299.25
## reanalysis_dew_point_temp_k 8 1446 295.25 1.53 295.64 295.37
## reanalysis_max_air_temp_k 9 1446 303.43 3.23 302.40 303.10
## reanalysis_min_air_temp_k 10 1446 295.72 2.57 296.20 295.93
## reanalysis_precip_amt_kg_per_m2 11 1446 40.15 43.43 27.24 32.38
## reanalysis_relative_humidity_percent 12 1446 82.16 7.15 80.30 81.69
## reanalysis_sat_precip_amt_mm 13 1443 45.76 43.72 38.34 40.16
## reanalysis_specific_humidity_g_per_kg 14 1446 16.75 1.54 17.09 16.85
## reanalysis_tdtr_k 15 1446 4.90 3.55 2.86 4.36
## station_avg_temp_c 16 1413 27.19 1.29 27.41 27.27
## station_diur_temp_rng_c 17 1413 8.06 2.13 7.30 7.85
## station_max_temp_c 18 1436 32.45 1.96 32.80 32.52
## station_min_temp_c 19 1442 22.10 1.57 22.20 22.14
## station_precip_mm 20 1434 39.33 47.46 23.85 30.46
## mad min max range skew kurtosis
## ndvi_ne 0.15 -0.41 0.51 0.91 -0.11 -0.14
## ndvi_nw 0.12 -0.46 0.45 0.91 -0.01 0.05
## ndvi_se 0.07 -0.02 0.54 0.55 0.57 0.56
## ndvi_sw 0.07 -0.06 0.55 0.61 0.75 0.70
## precipitation_amt_mm 44.23 0.00 390.60 390.60 1.73 6.74
## reanalysis_air_temp_k 1.57 294.64 302.20 7.56 -0.08 -0.69
## reanalysis_avg_temp_k 1.43 294.89 302.93 8.04 -0.19 -0.54
## reanalysis_dew_point_temp_k 1.52 289.64 298.45 8.81 -0.72 -0.12
## reanalysis_max_air_temp_k 2.67 297.80 314.00 16.20 0.85 -0.19
## reanalysis_min_air_temp_k 2.82 286.90 299.90 13.00 -0.67 -0.22
## reanalysis_precip_amt_kg_per_m2 25.12 0.00 570.50 570.50 3.38 22.12
## reanalysis_relative_humidity_percent 5.68 57.79 98.61 40.82 0.57 -0.40
## reanalysis_sat_precip_amt_mm 44.23 0.00 390.60 390.60 1.73 6.74
## reanalysis_specific_humidity_g_per_kg 1.63 11.72 20.46 8.75 -0.54 -0.49
## reanalysis_tdtr_k 1.16 1.36 16.03 14.67 1.07 -0.21
## station_avg_temp_c 1.28 21.40 30.80 9.40 -0.57 -0.16
## station_diur_temp_rng_c 1.63 4.53 15.80 11.27 0.84 -0.26
## station_max_temp_c 1.63 26.70 42.20 15.50 -0.26 0.21
## station_min_temp_c 1.63 14.70 25.60 10.90 -0.31 0.21
## station_precip_mm 26.76 0.00 543.30 543.30 2.98 15.29
## se
## ndvi_ne 0.00
## ndvi_nw 0.00
## ndvi_se 0.00
## ndvi_sw 0.00
## precipitation_amt_mm 1.15
## reanalysis_air_temp_k 0.04
## reanalysis_avg_temp_k 0.03
## reanalysis_dew_point_temp_k 0.04
## reanalysis_max_air_temp_k 0.09
## reanalysis_min_air_temp_k 0.07
## reanalysis_precip_amt_kg_per_m2 1.14
## reanalysis_relative_humidity_percent 0.19
## reanalysis_sat_precip_amt_mm 1.15
## reanalysis_specific_humidity_g_per_kg 0.04
## reanalysis_tdtr_k 0.09
## station_avg_temp_c 0.03
## station_diur_temp_rng_c 0.06
## station_max_temp_c 0.05
## station_min_temp_c 0.04
## station_precip_mm 1.25
Seperate Cities
#features.test.sj <- features.test %>% filter(city == 'sj')
#features.test.iq <- features.test %>% filter(city == 'iq')
#Create TS objects
train.sj<-ts(train.sj, frequency = 365.25/7, start = c(1990, 4, 30))
train.iq<-ts(train.iq, frequency = 365.25/7, start = c(2000, 1, 8))
test.sj<-ts(test.sj, frequency = 365.25/7, start = c(2008, 4, 29))
test.iq<-ts(test.iq, frequency = 365.25/7, start = c(2010, 9, 3))
Summarize Data
describe(train.sj)
## vars n mean sd median trimmed
## city 1 936 1.00 0.00 1.00 1.00
## year 2 936 1998.83 5.21 1999.00 1998.83
## weekofyear 3 936 26.50 15.02 26.50 26.50
## week_start_date 4 936 468.50 270.34 468.50 468.50
## ndvi_ne 5 936 0.08 0.10 0.09 0.08
## ndvi_nw 6 936 0.07 0.09 0.07 0.07
## ndvi_se 7 936 0.18 0.06 0.18 0.18
## ndvi_sw 8 936 0.17 0.06 0.17 0.17
## precipitation_amt_mm 9 936 35.57 44.40 21.44 27.69
## reanalysis_air_temp_k 10 936 299.16 1.23 299.24 299.19
## reanalysis_avg_temp_k 11 936 299.28 1.21 299.38 299.31
## reanalysis_dew_point_temp_k 12 936 295.11 1.56 295.45 295.23
## reanalysis_max_air_temp_k 13 936 301.41 1.27 301.50 301.44
## reanalysis_min_air_temp_k 14 936 297.29 1.30 297.50 297.37
## reanalysis_precip_amt_kg_per_m2 15 936 30.53 35.52 21.41 24.42
## reanalysis_relative_humidity_percent 16 936 78.59 3.39 78.68 78.65
## reanalysis_sat_precip_amt_mm 17 936 35.57 44.40 21.44 27.69
## reanalysis_specific_humidity_g_per_kg 18 936 16.55 1.56 16.83 16.64
## reanalysis_tdtr_k 19 936 2.53 0.53 2.46 2.49
## station_avg_temp_c 20 936 27.01 1.41 27.21 27.06
## station_diur_temp_rng_c 21 936 6.77 0.84 6.76 6.76
## station_max_temp_c 22 936 31.61 1.71 31.70 31.70
## station_min_temp_c 23 936 22.60 1.50 22.80 22.67
## station_precip_mm 24 936 26.87 29.25 17.95 21.80
## total_cases 25 936 34.18 51.38 19.00 23.84
## mad min max range skew
## city 0.00 1.00 1.00 0.00 NaN
## year 6.67 1990.00 2008.00 18.00 0.00
## weekofyear 19.27 1.00 53.00 52.00 0.00
## week_start_date 346.93 1.00 936.00 935.00 0.00
## ndvi_ne 0.08 -0.41 0.49 0.90 -0.41
## ndvi_nw 0.08 -0.46 0.44 0.89 -0.18
## ndvi_se 0.05 -0.02 0.39 0.41 0.19
## ndvi_sw 0.05 -0.06 0.38 0.44 0.11
## precipitation_amt_mm 31.78 0.00 390.60 390.60 2.61
## reanalysis_air_temp_k 1.45 295.94 302.20 6.26 -0.21
## reanalysis_avg_temp_k 1.40 296.11 302.16 6.05 -0.22
## reanalysis_dew_point_temp_k 1.71 289.64 297.80 8.15 -0.63
## reanalysis_max_air_temp_k 1.48 297.80 304.30 6.50 -0.16
## reanalysis_min_air_temp_k 1.48 292.60 299.90 7.30 -0.52
## reanalysis_precip_amt_kg_per_m2 18.39 0.00 570.50 570.50 5.56
## reanalysis_relative_humidity_percent 3.53 66.74 87.58 20.84 -0.20
## reanalysis_sat_precip_amt_mm 31.78 0.00 390.60 390.60 2.61
## reanalysis_specific_humidity_g_per_kg 1.79 11.72 19.44 7.72 -0.47
## reanalysis_tdtr_k 0.49 1.36 4.90 3.55 1.05
## station_avg_temp_c 1.67 22.84 30.07 7.23 -0.31
## station_diur_temp_rng_c 0.80 4.53 9.91 5.39 0.10
## station_max_temp_c 1.63 26.70 35.60 8.90 -0.45
## station_min_temp_c 1.63 17.80 25.60 7.80 -0.39
## station_precip_mm 18.90 0.00 305.90 305.90 2.62
## total_cases 17.79 0.00 461.00 461.00 4.46
## kurtosis se
## city NaN 0.00
## year -1.19 0.17
## weekofyear -1.20 0.49
## week_start_date -1.20 8.84
## ndvi_ne 2.16 0.00
## ndvi_nw 2.07 0.00
## ndvi_se 0.45 0.00
## ndvi_sw 0.64 0.00
## precipitation_amt_mm 11.80 1.45
## reanalysis_air_temp_k -0.87 0.04
## reanalysis_avg_temp_k -0.81 0.04
## reanalysis_dew_point_temp_k -0.39 0.05
## reanalysis_max_air_temp_k -0.80 0.04
## reanalysis_min_air_temp_k -0.34 0.04
## reanalysis_precip_amt_kg_per_m2 62.57 1.16
## reanalysis_relative_humidity_percent -0.09 0.11
## reanalysis_sat_precip_amt_mm 11.80 1.45
## reanalysis_specific_humidity_g_per_kg -0.72 0.05
## reanalysis_tdtr_k 2.04 0.02
## station_avg_temp_c -0.89 0.05
## station_diur_temp_rng_c 0.41 0.03
## station_max_temp_c -0.52 0.06
## station_min_temp_c -0.47 0.05
## station_precip_mm 12.71 0.96
## total_cases 25.17 1.68
describe(train.iq)
## vars n mean sd median trimmed
## city 1 520 1.00 0.00 1.00 1.00
## year 2 520 2005.00 2.92 2005.00 2005.00
## weekofyear 3 520 26.50 15.03 26.50 26.50
## week_start_date 4 520 260.50 150.26 260.50 260.50
## ndvi_ne 5 520 0.26 0.08 0.26 0.26
## ndvi_nw 6 520 0.24 0.08 0.23 0.24
## ndvi_se 7 520 0.25 0.08 0.25 0.25
## ndvi_sw 8 520 0.27 0.09 0.26 0.26
## precipitation_amt_mm 9 520 64.10 35.12 60.25 62.06
## reanalysis_air_temp_k 10 520 297.88 1.17 297.83 297.87
## reanalysis_avg_temp_k 11 520 299.13 1.33 299.14 299.15
## reanalysis_dew_point_temp_k 12 520 295.49 1.41 295.83 295.62
## reanalysis_max_air_temp_k 13 520 307.05 2.40 307.00 307.00
## reanalysis_min_air_temp_k 14 520 292.89 1.68 293.10 293.05
## reanalysis_precip_amt_kg_per_m2 15 520 57.48 50.12 45.98 49.24
## reanalysis_relative_humidity_percent 16 520 88.59 7.58 90.87 89.53
## reanalysis_sat_precip_amt_mm 17 520 64.10 35.12 60.25 62.06
## reanalysis_specific_humidity_g_per_kg 18 520 17.09 1.44 17.42 17.20
## reanalysis_tdtr_k 19 520 9.17 2.47 8.94 9.09
## station_avg_temp_c 20 520 27.51 0.89 27.50 27.54
## station_diur_temp_rng_c 21 520 10.39 1.61 10.44 10.38
## station_max_temp_c 22 520 33.96 1.33 33.90 33.92
## station_min_temp_c 23 520 21.21 1.26 21.40 21.33
## station_precip_mm 24 520 61.76 62.39 44.00 51.52
## total_cases 25 520 7.57 10.77 5.00 5.38
## mad min max range skew
## city 0.00 1.00 1.00 0.00 NaN
## year 3.71 2000.00 2010.00 10.00 0.00
## weekofyear 19.27 1.00 53.00 52.00 0.00
## week_start_date 192.74 1.00 520.00 519.00 0.00
## ndvi_ne 0.09 0.06 0.51 0.45 0.23
## ndvi_nw 0.08 0.04 0.45 0.42 0.24
## ndvi_se 0.08 0.03 0.54 0.51 0.28
## ndvi_sw 0.09 0.06 0.55 0.48 0.28
## precipitation_amt_mm 33.35 0.00 210.83 210.83 0.61
## reanalysis_air_temp_k 1.15 294.64 301.64 7.00 0.09
## reanalysis_avg_temp_k 1.40 294.89 302.93 8.04 -0.11
## reanalysis_dew_point_temp_k 1.28 290.09 298.45 8.36 -0.88
## reanalysis_max_air_temp_k 2.67 300.00 314.00 14.00 0.16
## reanalysis_min_air_temp_k 1.63 286.90 296.00 9.10 -0.92
## reanalysis_precip_amt_kg_per_m2 33.19 0.00 362.03 362.03 2.01
## reanalysis_relative_humidity_percent 6.43 57.79 98.61 40.82 -1.08
## reanalysis_sat_precip_amt_mm 33.35 0.00 210.83 210.83 0.61
## reanalysis_specific_humidity_g_per_kg 1.39 12.11 20.46 8.35 -0.66
## reanalysis_tdtr_k 2.73 3.71 16.03 12.31 0.28
## station_avg_temp_c 0.74 21.40 30.80 9.40 -0.87
## station_diur_temp_rng_c 1.79 5.20 15.80 10.60 0.01
## station_max_temp_c 1.33 30.10 42.20 12.10 0.63
## station_min_temp_c 1.04 14.70 24.20 9.50 -1.16
## station_precip_mm 45.96 0.00 543.30 543.30 2.26
## total_cases 5.93 0.00 116.00 116.00 3.97
## kurtosis se
## city NaN 0.00
## year -1.16 0.13
## weekofyear -1.21 0.66
## week_start_date -1.21 6.59
## ndvi_ne -0.35 0.00
## ndvi_nw -0.51 0.00
## ndvi_se 0.02 0.00
## ndvi_sw -0.18 0.00
## precipitation_amt_mm 0.42 1.54
## reanalysis_air_temp_k -0.04 0.05
## reanalysis_avg_temp_k -0.19 0.06
## reanalysis_dew_point_temp_k 0.60 0.06
## reanalysis_max_air_temp_k -0.51 0.11
## reanalysis_min_air_temp_k 0.92 0.07
## reanalysis_precip_amt_kg_per_m2 5.65 2.20
## reanalysis_relative_humidity_percent 0.75 0.33
## reanalysis_sat_precip_amt_mm 0.42 1.54
## reanalysis_specific_humidity_g_per_kg 0.08 0.06
## reanalysis_tdtr_k -0.66 0.11
## station_avg_temp_c 4.81 0.04
## station_diur_temp_rng_c -0.32 0.07
## station_max_temp_c 2.42 0.06
## station_min_temp_c 2.54 0.06
## station_precip_mm 8.77 2.74
## total_cases 26.35 0.47
Chart Cases
autoplot(train.sj[,"total_cases"])
autoplot(train.iq[,"total_cases"])
#Decomposition
train.sj[,"total_cases"] %>%
stl(t.window=52, s.window="periodic", robust=TRUE) %>%
autoplot()
train.iq[,"total_cases"] %>%
stl(t.window=52, s.window="periodic", robust=TRUE) %>%
autoplot()
Check ACF plots
#SJ
train.sj[,"total_cases"] %>% ur.kpss() %>% summary()
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 6 lags.
##
## Value of test-statistic is: 0.7987
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
ggtsdisplay(train.sj[,"total_cases"])
ndiffs(train.sj[,"total_cases"])
## [1] 1
cases.diff.sj<-diff(train.sj[,"total_cases"])
ggtsdisplay(cases.diff.sj)
train.sj<-ts(data.frame(train.sj[2:936,], cases.diff.sj), frequency = 365.25/7, start = c(1990, 4, 30))
#IQ
train.iq[,"total_cases"] %>% ur.kpss() %>% summary()
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 6 lags.
##
## Value of test-statistic is: 0.4686
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
ggtsdisplay(train.iq[,"total_cases"])
ndiffs(train.iq[,"total_cases"])
## [1] 1
cases.diff.iq<-diff(train.iq[,"total_cases"])
ggtsdisplay(cases.diff.iq)
train.iq<-ts(data.frame(train.iq[2:520,], cases.diff.iq), frequency = 365.25/7, start = c(2000, 1, 8))
Summarize Data
describe(train.sj)
## vars n mean sd median trimmed
## city 1 935 1.00 0.00 1.00 1.00
## year 2 935 1998.84 5.21 1999.00 1998.84
## weekofyear 3 935 26.51 15.03 27.00 26.51
## week_start_date 4 935 469.00 270.06 469.00 469.00
## ndvi_ne 5 935 0.08 0.10 0.09 0.08
## ndvi_nw 6 935 0.07 0.09 0.07 0.07
## ndvi_se 7 935 0.18 0.06 0.18 0.18
## ndvi_sw 8 935 0.17 0.06 0.17 0.17
## precipitation_amt_mm 9 935 35.59 44.42 21.53 27.71
## reanalysis_air_temp_k 10 935 299.16 1.23 299.24 299.19
## reanalysis_avg_temp_k 11 935 299.28 1.21 299.38 299.31
## reanalysis_dew_point_temp_k 12 935 295.11 1.56 295.45 295.23
## reanalysis_max_air_temp_k 13 935 301.41 1.26 301.50 301.44
## reanalysis_min_air_temp_k 14 935 297.29 1.30 297.50 297.37
## reanalysis_precip_amt_kg_per_m2 15 935 30.53 35.54 21.40 24.41
## reanalysis_relative_humidity_percent 16 935 78.60 3.39 78.68 78.65
## reanalysis_sat_precip_amt_mm 17 935 35.59 44.42 21.53 27.71
## reanalysis_specific_humidity_g_per_kg 18 935 16.56 1.55 16.83 16.65
## reanalysis_tdtr_k 19 935 2.53 0.53 2.46 2.49
## station_avg_temp_c 20 935 27.01 1.41 27.21 27.06
## station_diur_temp_rng_c 21 935 6.77 0.84 6.76 6.76
## station_max_temp_c 22 935 31.62 1.71 31.70 31.70
## station_min_temp_c 23 935 22.60 1.50 22.80 22.67
## station_precip_mm 24 935 26.88 29.26 18.00 21.81
## total_cases 25 935 34.21 51.40 19.00 23.86
## cases.diff.sj 26 935 0.00 13.63 0.00 0.04
## mad min max range skew
## city 0.00 1.00 1.00 0.00 NaN
## year 5.93 1990.00 2008.00 18.00 0.00
## weekofyear 19.27 1.00 53.00 52.00 0.00
## week_start_date 346.93 2.00 936.00 934.00 0.00
## ndvi_ne 0.08 -0.41 0.49 0.90 -0.41
## ndvi_nw 0.08 -0.46 0.44 0.89 -0.18
## ndvi_se 0.05 -0.02 0.39 0.41 0.19
## ndvi_sw 0.05 -0.06 0.38 0.44 0.11
## precipitation_amt_mm 31.92 0.00 390.60 390.60 2.61
## reanalysis_air_temp_k 1.44 295.94 302.20 6.26 -0.21
## reanalysis_avg_temp_k 1.40 296.11 302.16 6.05 -0.23
## reanalysis_dew_point_temp_k 1.71 289.64 297.80 8.15 -0.63
## reanalysis_max_air_temp_k 1.48 297.80 304.30 6.50 -0.16
## reanalysis_min_air_temp_k 1.48 292.60 299.90 7.30 -0.52
## reanalysis_precip_amt_kg_per_m2 18.38 0.00 570.50 570.50 5.56
## reanalysis_relative_humidity_percent 3.52 66.74 87.58 20.84 -0.20
## reanalysis_sat_precip_amt_mm 31.92 0.00 390.60 390.60 2.61
## reanalysis_specific_humidity_g_per_kg 1.79 11.72 19.44 7.72 -0.47
## reanalysis_tdtr_k 0.49 1.36 4.90 3.55 1.05
## station_avg_temp_c 1.67 22.84 30.07 7.23 -0.31
## station_diur_temp_rng_c 0.80 4.53 9.91 5.39 0.10
## station_max_temp_c 1.63 26.70 35.60 8.90 -0.45
## station_min_temp_c 1.63 17.80 25.60 7.80 -0.39
## station_precip_mm 18.98 0.00 305.90 305.90 2.62
## total_cases 17.79 0.00 461.00 461.00 4.46
## cases.diff.sj 7.41 -82.00 93.00 175.00 -0.08
## kurtosis se
## city NaN 0.00
## year -1.19 0.17
## weekofyear -1.20 0.49
## week_start_date -1.20 8.83
## ndvi_ne 2.16 0.00
## ndvi_nw 2.06 0.00
## ndvi_se 0.45 0.00
## ndvi_sw 0.64 0.00
## precipitation_amt_mm 11.78 1.45
## reanalysis_air_temp_k -0.87 0.04
## reanalysis_avg_temp_k -0.81 0.04
## reanalysis_dew_point_temp_k -0.38 0.05
## reanalysis_max_air_temp_k -0.79 0.04
## reanalysis_min_air_temp_k -0.34 0.04
## reanalysis_precip_amt_kg_per_m2 62.50 1.16
## reanalysis_relative_humidity_percent -0.09 0.11
## reanalysis_sat_precip_amt_mm 11.78 1.45
## reanalysis_specific_humidity_g_per_kg -0.72 0.05
## reanalysis_tdtr_k 2.03 0.02
## station_avg_temp_c -0.88 0.05
## station_diur_temp_rng_c 0.41 0.03
## station_max_temp_c -0.51 0.06
## station_min_temp_c -0.46 0.05
## station_precip_mm 12.70 0.96
## total_cases 25.15 1.68
## cases.diff.sj 11.75 0.45
describe(train.iq)
## vars n mean sd median trimmed
## city 1 519 1.00 0.00 1.00 1.00
## year 2 519 2005.01 2.91 2005.00 2005.01
## weekofyear 3 519 26.50 15.04 27.00 26.50
## week_start_date 4 519 261.00 149.97 261.00 261.00
## ndvi_ne 5 519 0.26 0.08 0.26 0.26
## ndvi_nw 6 519 0.24 0.08 0.23 0.24
## ndvi_se 7 519 0.25 0.08 0.25 0.25
## ndvi_sw 8 519 0.27 0.09 0.26 0.26
## precipitation_amt_mm 9 519 64.18 35.11 60.36 62.17
## reanalysis_air_temp_k 10 519 297.88 1.17 297.84 297.87
## reanalysis_avg_temp_k 11 519 299.14 1.33 299.15 299.15
## reanalysis_dew_point_temp_k 12 519 295.49 1.41 295.83 295.62
## reanalysis_max_air_temp_k 13 519 307.05 2.40 307.00 307.00
## reanalysis_min_air_temp_k 14 519 292.89 1.68 293.10 293.05
## reanalysis_precip_amt_kg_per_m2 15 519 57.50 50.16 46.00 49.33
## reanalysis_relative_humidity_percent 16 519 88.58 7.58 90.86 89.51
## reanalysis_sat_precip_amt_mm 17 519 64.18 35.11 60.36 62.17
## reanalysis_specific_humidity_g_per_kg 18 519 17.09 1.44 17.42 17.20
## reanalysis_tdtr_k 19 519 9.17 2.47 8.96 9.09
## station_avg_temp_c 20 519 27.51 0.89 27.50 27.54
## station_diur_temp_rng_c 21 519 10.39 1.62 10.43 10.38
## station_max_temp_c 22 519 33.97 1.33 33.90 33.92
## station_min_temp_c 23 519 21.21 1.26 21.40 21.33
## station_precip_mm 24 519 61.87 62.40 44.00 51.73
## total_cases 25 519 7.58 10.77 5.00 5.41
## cases.diff.iq 26 519 0.01 7.66 0.00 -0.02
## mad min max range skew
## city 0.00 1.00 1.00 0.00 NaN
## year 2.97 2000.00 2010.00 10.00 0.00
## weekofyear 19.27 1.00 53.00 52.00 0.00
## week_start_date 192.74 2.00 520.00 518.00 0.00
## ndvi_ne 0.09 0.06 0.51 0.45 0.22
## ndvi_nw 0.08 0.04 0.45 0.42 0.24
## ndvi_se 0.08 0.03 0.54 0.51 0.28
## ndvi_sw 0.09 0.06 0.55 0.48 0.28
## precipitation_amt_mm 32.96 0.00 210.83 210.83 0.61
## reanalysis_air_temp_k 1.15 294.64 301.64 7.00 0.09
## reanalysis_avg_temp_k 1.41 294.89 302.93 8.04 -0.11
## reanalysis_dew_point_temp_k 1.28 290.09 298.45 8.36 -0.88
## reanalysis_max_air_temp_k 2.67 300.00 314.00 14.00 0.16
## reanalysis_min_air_temp_k 1.63 286.90 296.00 9.10 -0.92
## reanalysis_precip_amt_kg_per_m2 33.21 0.00 362.03 362.03 2.00
## reanalysis_relative_humidity_percent 6.43 57.79 98.61 40.82 -1.08
## reanalysis_sat_precip_amt_mm 32.96 0.00 210.83 210.83 0.61
## reanalysis_specific_humidity_g_per_kg 1.39 12.11 20.46 8.35 -0.66
## reanalysis_tdtr_k 2.71 3.71 16.03 12.31 0.28
## station_avg_temp_c 0.74 21.40 30.80 9.40 -0.88
## station_diur_temp_rng_c 1.80 5.20 15.80 10.60 0.01
## station_max_temp_c 1.33 30.10 42.20 12.10 0.63
## station_min_temp_c 1.04 14.70 24.20 9.50 -1.16
## station_precip_mm 45.96 0.00 543.30 543.30 2.26
## total_cases 5.93 0.00 116.00 116.00 3.97
## cases.diff.iq 2.97 -84.00 65.00 149.00 -1.15
## kurtosis se
## city NaN 0.00
## year -1.16 0.13
## weekofyear -1.21 0.66
## week_start_date -1.21 6.58
## ndvi_ne -0.35 0.00
## ndvi_nw -0.51 0.00
## ndvi_se 0.03 0.00
## ndvi_sw -0.19 0.00
## precipitation_amt_mm 0.42 1.54
## reanalysis_air_temp_k -0.04 0.05
## reanalysis_avg_temp_k -0.19 0.06
## reanalysis_dew_point_temp_k 0.60 0.06
## reanalysis_max_air_temp_k -0.52 0.11
## reanalysis_min_air_temp_k 0.91 0.07
## reanalysis_precip_amt_kg_per_m2 5.63 2.20
## reanalysis_relative_humidity_percent 0.74 0.33
## reanalysis_sat_precip_amt_mm 0.42 1.54
## reanalysis_specific_humidity_g_per_kg 0.08 0.06
## reanalysis_tdtr_k -0.66 0.11
## station_avg_temp_c 4.84 0.04
## station_diur_temp_rng_c -0.32 0.07
## station_max_temp_c 2.43 0.06
## station_min_temp_c 2.53 0.06
## station_precip_mm 8.77 2.74
## total_cases 26.33 0.47
## cases.diff.iq 38.74 0.34
hist(cases.diff.sj)
hist(cases.diff.iq)
#Seasonality Charts
ggseasonplot(train.sj[,"total_cases"], year.labels=TRUE, year.labels.left=TRUE) +
ylab("Cases SJ") +
ggtitle("Seasonal plot: Cases")
ggseasonplot(train.iq[,"total_cases"], year.labels=TRUE, year.labels.left=TRUE) +
ylab("Cases IQ") +
ggtitle("Seasonal plot: Cases")
ggplot(data=cases.train,aes(x=weekofyear,y=total_cases,fill=city))+geom_bar(stat="identity")+facet_wrap(.~city)
ggplot(data=cases.train,aes(x=year,y=total_cases,fill=city))+geom_bar(stat="identity")+facet_wrap(.~city)
Correlation to cases for different features
#SJ
corr.vars.sj<-train.sj[,5:24]
co_v<-cor(corr.vars.sj)
corrplot(co_v,tl.cex=.7)
#IQ
corr.vars.iq<-train.iq[,5:24]
co_v<-cor(corr.vars.iq)
corrplot(co_v,tl.cex=.7)
validation create
sj.train.train <- head(train.sj, 800)
sj.train.valid <- tail(train.sj, nrow(train.sj) - 800)
iq.train.train <- head(train.iq, 400)
iq.train.valid <- tail(train.iq, nrow(train.iq) - 400)
xreg.sj.train<-stats::lag(sj.train.train[, 5:23], 1)
#This gives a ank deficiancy error
xreg.sj.train<-xreg.sj.train[,-13]
xreg.iq.train<-stats::lag(iq.train.train[, 5:23], 1)
xreg.iq.train<-xreg.iq.train[,-13]
xreg.sj.test<-stats::lag(sj.train.valid[, 5:23], 1)
xreg.sj.test<-xreg.sj.test[,-13]
xreg.iq.test<-stats::lag(iq.train.valid[, 5:23], 1)
xreg.iq.test<-xreg.iq.test[,-13]
cases.diff.sj<-sj.train.train[,"cases.diff.sj"]
cases.diff.iq<-iq.train.train[,"cases.diff.iq"]
valid.cases.diff.sj<-sj.train.valid[,"cases.diff.sj"]
valid.cases.diff.iq<-iq.train.valid[,"cases.diff.iq"]
ETS
fit.ets.sj <- ets(cases.diff.sj)
## Warning in ets(cases.diff.sj): I can't handle data with frequency greater than
## 24. Seasonality will be ignored. Try stlf() if you need seasonal forecasts.
autoplot(fit.ets.sj)
fc.ets.sj <- forecast(fit.ets.sj, h=78)
autoplot(fc.ets.sj)
checkresiduals(fc.ets.sj)
##
## Ljung-Box test
##
## data: Residuals from ETS(A,N,N)
## Q* = 166.33, df = 102.36, p-value = 6.582e-05
##
## Model df: 2. Total lags used: 104.357142857143
fit.ets.iq <- ets(cases.diff.iq)
## Warning in ets(cases.diff.iq): I can't handle data with frequency greater than
## 24. Seasonality will be ignored. Try stlf() if you need seasonal forecasts.
autoplot(fit.ets.iq)
fc.ets.iq <- forecast(fit.ets.iq, h=78)
autoplot(fc.ets.iq)
checkresiduals(fc.ets.iq)
##
## Ljung-Box test
##
## data: Residuals from ETS(A,N,N)
## Q* = 135.49, df = 78, p-value = 5.952e-05
##
## Model df: 2. Total lags used: 80
accuracy(fc.ets.sj, valid.cases.diff.sj)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.004602636 13.893921 8.145813 -Inf Inf 0.6543243 0.1690799
## Test set -1.312371442 7.927418 5.430700 -Inf Inf 0.4362289 -0.2542126
## Theil's U
## Training set NA
## Test set NaN
accuracy(fc.ets.iq, valid.cases.diff.iq)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.001809297 8.091881 3.977151 -Inf Inf 0.5978611 -0.1752091
## Test set -0.110192544 6.828784 4.145220 -Inf Inf 0.6231260 -0.2302014
## Theil's U
## Training set NA
## Test set NaN
ARIMA with Fourier
#SJ
fit <- auto.arima(na.omit(cases.diff.sj), xreg = fourier(na.omit(cases.diff.sj), K = 3),
seasonal = FALSE)
fit.fcst.fourier.sj<-forecast(fit, xreg=fourier(cases.diff.sj, K = 3, h=240))
autoplot(fit.fcst.fourier.sj)
#IQ
fit <- auto.arima(na.omit(cases.diff.iq), xreg = fourier(na.omit(cases.diff.iq), K = 3),
seasonal = FALSE)
fit.fcst.fourier.iq<-forecast(fit, xreg=fourier(cases.diff.iq, K = 3, h=240))
autoplot(fit.fcst.fourier.iq)
accuracy(fit.fcst.fourier.sj, valid.cases.diff.sj)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.06205098 13.43882 8.198425 NaN Inf 0.6585505 0.003352907
## Test set -0.44264915 12.03714 7.494192 NaN Inf 0.6019819 -0.125049511
## Theil's U
## Training set NA
## Test set NaN
accuracy(fit.fcst.fourier.iq, valid.cases.diff.iq)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.1234457 7.282897 4.000109 NaN Inf 0.6013123 0.001961717
## Test set -0.1055674 6.052472 3.766331 NaN Inf 0.5661699 -0.200652235
## Theil's U
## Training set NA
## Test set NaN
ARIMA
#fit arima models
#SJ
fit<-auto.arima(cases.diff.sj, xreg=xreg.sj.train)
fit.fcst.arima.sj<-forecast(fit, xreg=xreg.sj.test, h=24)
autoplot(fit.fcst.arima.sj)
#IQ
fit<-auto.arima(cases.diff.iq, xreg=xreg.iq.train)
fit.fcst.arima.iq<-forecast(fit, xreg=xreg.iq.test, h=24)
autoplot(fit.fcst.arima.iq)
xreg.iq.test
## Time Series:
## Start = 2007.64681724846
## End = 2009.90828199863
## Frequency = 52.1785714285714
## ndvi_ne ndvi_nw ndvi_se ndvi_sw precipitation_amt_mm
## 2007.647 0.23833330 0.23272860 0.12394290 0.20007140 91.87000
## 2007.666 0.33660000 0.30421430 0.32290000 0.37731430 62.13000
## 2007.685 0.27008330 0.19027140 0.19065710 0.21515710 107.00000
## 2007.704 0.28435710 0.35367140 0.32178570 0.30282860 71.45000
## 2007.723 0.30261430 0.24467140 0.29631430 0.32875710 79.74000
## 2007.743 0.27060000 0.37131430 0.34422860 0.28307140 42.05000
## 2007.762 0.06172857 0.13390000 0.09471429 0.11784290 42.12000
## 2007.781 0.13615710 0.16315710 0.13915710 0.13455710 50.50000
## 2007.800 0.19638570 0.29632000 0.26415710 0.22558570 30.08000
## 2007.819 0.22101670 0.23531670 0.18044290 0.19947140 45.69000
## 2007.838 0.12245000 0.15710000 0.08600000 0.10331430 72.04000
## 2007.858 0.19518570 0.15771430 0.18442860 0.13361430 30.09000
## 2007.877 0.29374290 0.26436670 0.24662860 0.29195710 13.27000
## 2007.896 0.22402860 0.17547140 0.26565710 0.24521430 111.18000
## 2007.915 0.19704290 0.27798330 0.21394290 0.26561430 89.88000
## 2007.934 0.30482860 0.23367140 0.24891430 0.25581430 0.00000
## 2007.953 0.15385000 0.14958570 0.32944290 0.13288570 0.00000
## 2007.973 0.23238570 0.21395710 0.22030000 0.19842860 62.84000
## 2007.992 0.32701670 0.20911670 0.28376670 0.30955000 52.36000
## 2008.011 0.35480000 0.34655000 0.26741670 0.39211670 44.63000
## 2008.030 0.20020000 0.25138570 0.21134290 0.19972860 32.45000
## 2008.049 0.43037140 0.43301430 0.43691430 0.46572860 26.03000
## 2008.068 0.28330000 0.30447140 0.27445710 0.38050000 12.88000
## 2008.088 0.31818570 0.31976670 0.30817140 0.32360000 58.20000
## 2008.107 0.33980000 0.36910000 0.28880000 0.30923330 34.59000
## 2008.126 0.23190000 0.27625000 0.26120000 0.23278330 86.14000
## 2008.145 0.21680000 0.27733330 0.20893330 0.33626670 65.43000
## 2008.164 0.41495000 0.36342860 0.32240000 0.40068570 61.38000
## 2008.183 0.39308570 0.37827140 0.34370000 0.40484290 24.28000
## 2008.203 0.16055710 0.16387140 0.19493330 0.20611430 69.47000
## 2008.222 0.28820000 0.22785710 0.28075710 0.35797140 69.39000
## 2008.241 0.32915710 0.22790000 0.27334290 0.25684290 52.65000
## 2008.260 0.16174290 0.19620000 0.19827140 0.21961430 43.60000
## 2008.279 0.50102860 0.44500000 0.42768570 0.54572860 57.85000
## 2008.298 0.30428570 0.29464290 0.30627140 0.40038570 60.36000
## 2008.318 0.19305710 0.19652860 0.17625710 0.18305710 59.44000
## 2008.337 0.25101430 0.28831430 0.25370000 0.32130000 81.11000
## 2008.356 0.16436670 0.19635000 0.17313330 0.15491670 45.03000
## 2008.375 0.28941670 0.34778000 0.27482860 0.25808570 64.03000
## 2008.394 0.17838570 0.21917140 0.24972860 0.19230000 70.92000
## 2008.413 0.26341250 0.21987500 0.20008750 0.22662500 55.11000
## 2008.433 0.15128570 0.16168570 0.15327140 0.11944290 45.76039
## 2008.452 0.22991670 0.12234000 0.26116670 0.22305000 52.28000
## 2008.471 0.18848570 0.18818570 0.20391430 0.27750000 72.03000
## 2008.490 0.18845710 0.19931430 0.20270000 0.21392860 76.16000
## 2008.509 0.16673330 0.17373330 0.19043330 0.16171670 118.54000
## 2008.528 0.27991430 0.24028570 0.19572860 0.30765710 149.06000
## 2008.548 0.17027140 0.15111430 0.14047140 0.14297140 60.51000
## 2008.567 0.18878570 0.15945710 0.15687140 0.20298570 124.80000
## 2008.586 0.28236000 0.30511670 0.29408330 0.31601670 147.44000
## 2008.605 0.36207140 0.33670000 0.34530000 0.37928570 58.56000
## 2008.624 0.20342860 0.17844290 0.22597140 0.20187140 97.80000
## 2008.643 0.15788330 0.19210000 0.21372860 0.20138570 106.68000
## 2008.663 0.22358570 0.25913330 0.26328570 0.30578570 100.78000
## 2008.682 0.08905714 0.05895000 0.08927143 0.09934286 131.17000
## 2008.701 0.14684290 0.14165710 0.14118570 0.14877140 133.47000
## 2008.720 0.22360000 0.17882860 0.17500000 0.21614290 99.77000
## 2008.739 0.19534290 0.28567140 0.16118570 0.20238570 52.74000
## 2008.758 0.28358570 0.34551430 0.23744290 0.31612860 99.89000
## 2008.778 0.19075710 0.26455710 0.25388570 0.21920000 30.73000
## 2008.797 0.20774290 0.22785710 0.25420000 0.21604290 38.51000
## 2008.816 0.33121430 0.21720000 0.20938570 0.34451430 66.46000
## 2008.835 0.23834290 0.19731670 0.16550000 0.19014290 40.04000
## 2008.854 0.11400000 0.09244286 0.09747143 0.12628570 42.22000
## 2008.873 0.18712860 0.15780000 0.14345710 0.19947140 8.74000
## 2008.893 0.29167140 0.30702860 0.35622860 0.38911430 43.32000
## 2008.912 0.27080000 0.20518330 0.24012860 0.20015710 141.65000
## 2008.931 0.18685710 0.17691430 0.22307140 0.21898570 68.15000
## 2008.950 0.38591430 0.29038330 0.33642860 0.29278570 91.40000
## 2008.969 0.21965000 0.37805000 0.22387140 0.26590000 65.19000
## 2008.988 0.20788330 0.28085000 0.17560000 0.26160000 35.82000
## 2009.008 0.15435710 0.11527140 0.15345710 0.15590000 51.77000
## 2009.027 0.39500000 0.35273330 0.48428570 0.40191430 9.79000
## 2009.046 0.33088570 0.40830000 0.44335710 0.33477140 35.23000
## 2009.065 0.22062860 0.19435710 0.27857140 0.26045710 6.52000
## 2009.084 0.24534290 0.18598570 0.18134290 0.28205710 95.83000
## 2009.103 0.50835710 0.45442860 0.53831430 0.51482860 83.02000
## 2009.123 0.18961670 0.19200000 0.23681430 0.26968570 13.74000
## 2009.142 0.26632000 0.31336670 0.19565710 0.30707140 40.17000
## 2009.161 0.29431430 0.27067140 0.30207140 0.25401430 78.68000
## 2009.180 0.20630000 0.25525710 0.27995710 0.20665710 57.18000
## 2009.199 0.23227140 0.27250000 0.27157140 0.28538570 20.58000
## 2009.218 0.29741430 0.28217140 0.25592860 0.31978570 30.49000
## 2009.238 0.29680000 0.30848570 0.36230000 0.36165710 82.59000
## 2009.257 0.29075710 0.23795000 0.31768570 0.26160000 77.38000
## 2009.276 0.38867140 0.37281670 0.24990000 0.37301430 45.79000
## 2009.295 0.36887140 0.37995710 0.38002860 0.46792860 96.23000
## 2009.314 0.40705000 0.33510000 0.36650000 0.38935000 29.72000
## 2009.333 0.33611430 0.28776670 0.32545710 0.35760000 38.17000
## 2009.352 0.34852860 0.29040000 0.41061430 0.37045710 73.45000
## 2009.372 0.19220000 0.19352860 0.23988570 0.28588570 85.62000
## 2009.391 0.21760000 0.24030000 0.18177140 0.26230000 81.21000
## 2009.410 0.21042220 0.25713750 0.22113330 0.30025560 98.79000
## 2009.429 0.14229354 0.13055258 0.20378319 0.20230549 45.76039
## 2009.448 0.12457140 0.17912860 0.16384290 0.13547140 27.04000
## 2009.467 0.14528570 0.14231430 0.13530000 0.16752860 32.99000
## 2009.487 0.25211430 0.23048570 0.18732860 0.30278570 19.04000
## 2009.506 0.26327140 0.23060000 0.21887140 0.26128570 138.51000
## 2009.525 0.17010000 0.14211670 0.11791430 0.13934290 47.31000
## 2009.544 0.23075710 0.18925710 0.16348570 0.23887140 78.25000
## 2009.563 0.29330000 0.24782860 0.20662860 0.26667140 32.19000
## 2009.582 0.30365710 0.26005710 0.22548570 0.33331430 84.67000
## 2009.602 0.12731670 0.18116000 0.12046670 0.14276670 80.58000
## 2009.621 0.31172860 0.29268570 0.27258570 0.39480000 57.78000
## 2009.640 0.29460000 0.25097140 0.28147140 0.34164290 121.20000
## 2009.659 0.26628570 0.30123330 0.29600000 0.29574290 51.29000
## 2009.678 0.14143330 0.20472860 0.25097140 0.14524290 49.80000
## 2009.697 0.24284290 0.27275710 0.20227140 0.26011430 93.76000
## 2009.717 0.15768570 0.15661430 0.18401430 0.13588570 17.33000
## 2009.736 0.23148570 0.29468570 0.33165710 0.24440000 86.70000
## 2009.755 0.23974290 0.25927140 0.30778570 0.30794290 26.00000
## 2009.774 0.26081430 0.25578570 0.25777140 0.34028570 73.97000
## 2009.793 0.16868570 0.15850000 0.13307140 0.14560000 59.40000
## 2009.812 0.26307140 0.27250000 0.25827140 0.24450000 1.15000
## 2009.832 0.34275000 0.31890000 0.25634290 0.29251430 55.30000
## 2009.851 0.16015710 0.16037140 0.13604290 0.22565710 86.47000
## 2009.870 0.24705710 0.14605710 0.25035710 0.23371430 58.94000
## 2009.889 0.33391430 0.24577140 0.27888570 0.32548570 59.67000
## 2009.908 0.29818570 0.23297140 0.27421430 0.31575710 63.22000
## reanalysis_air_temp_k reanalysis_avg_temp_k
## 2007.647 296.7557 297.9929
## 2007.666 297.0943 297.9929
## 2007.685 297.6943 298.8429
## 2007.704 297.5371 298.9000
## 2007.723 297.4471 298.6643
## 2007.743 296.7600 297.4143
## 2007.762 298.0729 299.4143
## 2007.781 295.9757 296.8714
## 2007.800 294.8500 295.4214
## 2007.819 296.2686 296.9357
## 2007.838 296.7414 297.6929
## 2007.858 296.4000 297.3571
## 2007.877 296.1871 297.3643
## 2007.896 296.7429 297.6500
## 2007.915 296.4586 297.2500
## 2007.934 296.5429 297.8071
## 2007.953 296.5457 297.4786
## 2007.973 296.0786 297.4071
## 2007.992 296.5457 297.3143
## 2008.011 297.0443 298.5000
## 2008.030 297.3100 298.5714
## 2008.049 297.2143 298.5000
## 2008.068 299.2286 300.3071
## 2008.088 298.5743 300.1429
## 2008.107 298.5314 300.0714
## 2008.126 296.9214 298.2429
## 2008.145 297.5886 298.4286
## 2008.164 297.6600 298.6214
## 2008.183 299.1786 301.1500
## 2008.203 300.1014 301.4071
## 2008.222 298.3500 299.9000
## 2008.241 297.8671 298.9857
## 2008.260 298.3729 299.8000
## 2008.279 298.4643 299.5286
## 2008.298 298.4986 300.2214
## 2008.318 298.8900 300.3071
## 2008.337 298.5300 299.7214
## 2008.356 298.1114 299.1286
## 2008.375 298.6514 300.2143
## 2008.394 298.5286 300.2571
## 2008.413 299.5571 300.7714
## 2008.433 298.7019 299.2256
## 2008.452 297.7257 299.0071
## 2008.471 296.6829 297.4143
## 2008.490 296.5500 297.5143
## 2008.509 297.4957 298.8000
## 2008.528 297.4057 298.1929
## 2008.548 297.3229 298.4714
## 2008.567 297.6857 299.0143
## 2008.586 297.3914 298.8643
## 2008.605 297.8443 299.0000
## 2008.624 297.0586 298.0143
## 2008.643 297.3657 298.2500
## 2008.663 297.1529 298.3214
## 2008.682 297.2457 298.3857
## 2008.701 297.8900 298.9000
## 2008.720 296.6357 297.6214
## 2008.739 297.5457 298.2786
## 2008.758 297.4043 298.3214
## 2008.778 297.5629 298.5429
## 2008.797 297.6071 299.0071
## 2008.816 297.7243 299.5214
## 2008.835 296.7043 297.5214
## 2008.854 296.1257 296.7786
## 2008.873 295.1043 295.7786
## 2008.893 296.0314 297.3143
## 2008.912 297.2171 298.5214
## 2008.931 296.4529 297.8214
## 2008.950 296.0657 296.9929
## 2008.969 296.5271 297.6643
## 2008.988 296.5257 297.9643
## 2009.008 297.0871 298.2357
## 2009.027 297.3700 298.8786
## 2009.046 298.3571 299.9857
## 2009.065 298.6771 300.1071
## 2009.084 298.9971 300.9214
## 2009.103 297.3886 298.4500
## 2009.123 299.8557 300.7500
## 2009.142 299.4700 300.8143
## 2009.161 299.3243 301.0286
## 2009.180 298.0343 299.5714
## 2009.199 298.7071 300.1286
## 2009.218 299.7371 301.0000
## 2009.238 298.8557 300.2857
## 2009.257 298.6786 300.0714
## 2009.276 299.1614 300.4786
## 2009.295 300.3214 301.7857
## 2009.314 300.4857 301.7500
## 2009.333 299.4557 300.6143
## 2009.352 298.7629 299.9357
## 2009.372 299.1986 300.6786
## 2009.391 298.3471 299.3500
## 2009.410 297.1814 298.1857
## 2009.429 298.7019 299.2256
## 2009.448 299.2643 300.5214
## 2009.467 298.2971 299.9357
## 2009.487 298.9257 300.4571
## 2009.506 298.2914 299.6143
## 2009.525 298.7543 300.3429
## 2009.544 298.2514 299.6786
## 2009.563 299.6486 300.9500
## 2009.582 298.9171 300.4857
## 2009.602 298.3371 299.6643
## 2009.621 298.8371 300.0929
## 2009.640 299.1914 300.9286
## 2009.659 299.0043 300.3000
## 2009.678 299.0029 300.7143
## 2009.697 299.1157 300.2714
## 2009.717 298.3057 299.5571
## 2009.736 298.4386 299.5071
## 2009.755 299.0486 300.0286
## 2009.774 297.6171 298.5857
## 2009.793 297.2786 297.9357
## 2009.812 297.6486 298.7071
## 2009.832 299.3343 300.7714
## 2009.851 298.3300 299.3929
## 2009.870 296.5986 297.5929
## 2009.889 296.3457 297.5214
## 2009.908 298.0971 299.8357
## reanalysis_dew_point_temp_k reanalysis_max_air_temp_k
## 2007.647 295.4757 305.0000
## 2007.666 295.9486 303.7000
## 2007.685 295.8543 305.4000
## 2007.704 296.6329 306.1000
## 2007.723 295.9357 305.5000
## 2007.743 296.3829 301.9000
## 2007.762 296.7414 306.3000
## 2007.781 294.6657 304.5000
## 2007.800 293.2443 304.4000
## 2007.819 295.6386 303.4000
## 2007.838 295.9943 304.1000
## 2007.858 295.2100 304.4000
## 2007.877 293.8914 305.8000
## 2007.896 295.9343 304.4000
## 2007.915 295.1929 304.8000
## 2007.934 293.8300 304.9000
## 2007.953 293.5943 305.9000
## 2007.973 294.6914 304.6000
## 2007.992 295.0029 306.8000
## 2008.011 295.3700 307.5000
## 2008.030 295.5057 307.4000
## 2008.049 295.3471 305.6000
## 2008.068 294.4186 310.2000
## 2008.088 295.0929 310.4000
## 2008.107 294.8614 309.3000
## 2008.126 295.4843 305.9000
## 2008.145 295.3071 306.7000
## 2008.164 295.4900 309.3000
## 2008.183 294.7614 310.2000
## 2008.203 295.3614 310.4000
## 2008.222 295.9157 310.5000
## 2008.241 296.7014 305.0000
## 2008.260 296.8257 308.5000
## 2008.279 297.4686 307.2000
## 2008.298 296.0100 309.6000
## 2008.318 297.7414 307.2000
## 2008.337 297.5771 306.1000
## 2008.356 297.0443 305.2000
## 2008.375 296.1829 308.9000
## 2008.394 296.8471 306.3000
## 2008.413 295.5943 308.3000
## 2008.433 295.2464 303.4271
## 2008.452 296.7843 304.6000
## 2008.471 296.4186 304.0000
## 2008.490 295.1371 303.5000
## 2008.509 296.5143 304.4000
## 2008.528 296.8400 302.7000
## 2008.548 296.1943 305.7000
## 2008.567 296.2543 306.7000
## 2008.586 296.4943 306.6000
## 2008.605 296.7100 304.6000
## 2008.624 296.7157 304.0000
## 2008.643 296.5000 304.6000
## 2008.663 296.1843 303.3000
## 2008.682 296.5457 304.5000
## 2008.701 295.8043 306.8000
## 2008.720 296.1357 304.7000
## 2008.739 296.8871 303.6000
## 2008.758 296.4486 303.6000
## 2008.778 296.4843 306.8000
## 2008.797 296.2714 306.5000
## 2008.816 296.0129 307.1000
## 2008.835 296.2643 305.1000
## 2008.854 295.2671 302.5000
## 2008.873 293.9100 305.2000
## 2008.893 294.8629 305.2000
## 2008.912 296.1100 305.6000
## 2008.931 295.3571 304.6000
## 2008.950 295.1671 306.2000
## 2008.969 295.4114 306.8000
## 2008.988 294.0529 306.7000
## 2009.008 295.0457 307.9000
## 2009.027 294.8243 307.9000
## 2009.046 295.5071 308.2000
## 2009.065 294.7086 309.3000
## 2009.084 296.4443 310.4000
## 2009.103 296.3886 305.0000
## 2009.123 294.3143 310.0000
## 2009.142 294.6186 310.0000
## 2009.161 295.8271 309.8000
## 2009.180 296.3443 307.4000
## 2009.199 296.5614 308.3000
## 2009.218 295.3500 311.3000
## 2009.238 296.9186 307.2000
## 2009.257 297.4429 310.8000
## 2009.276 297.1400 309.7000
## 2009.295 296.9257 308.7000
## 2009.314 296.1086 311.0000
## 2009.333 297.2257 308.7000
## 2009.352 296.9700 308.9000
## 2009.372 296.5957 308.6000
## 2009.391 296.9057 307.5000
## 2009.410 296.5571 302.9000
## 2009.429 295.2464 303.4271
## 2009.448 294.5300 308.6000
## 2009.467 296.1471 308.0000
## 2009.487 296.3800 307.8000
## 2009.506 296.5600 308.3000
## 2009.525 296.8371 306.1000
## 2009.544 297.5686 306.2000
## 2009.563 297.0900 309.2000
## 2009.582 297.9286 308.2000
## 2009.602 297.9171 306.3000
## 2009.621 298.1414 306.9000
## 2009.640 298.4500 307.4000
## 2009.659 297.5557 307.9000
## 2009.678 296.5686 309.1000
## 2009.697 298.1614 308.4000
## 2009.717 297.0029 307.3000
## 2009.736 297.6786 304.7000
## 2009.755 296.4686 308.4000
## 2009.774 296.9757 304.7000
## 2009.793 296.7386 306.0000
## 2009.812 293.2271 308.7000
## 2009.832 296.8257 309.7000
## 2009.851 296.4529 308.5000
## 2009.870 295.5014 305.5000
## 2009.889 295.3243 306.1000
## 2009.908 295.8071 307.8000
## reanalysis_min_air_temp_k reanalysis_precip_amt_kg_per_m2
## 2007.647 293.3000 90.50000
## 2007.666 293.1000 53.36000
## 2007.685 293.7000 24.90000
## 2007.704 292.8000 99.96000
## 2007.723 293.8000 45.96000
## 2007.743 293.7000 62.52000
## 2007.762 293.1000 115.99000
## 2007.781 290.6000 47.10000
## 2007.800 288.5000 18.08000
## 2007.819 291.7000 59.40000
## 2007.838 293.8000 134.66000
## 2007.858 292.2000 73.01000
## 2007.877 288.2000 12.90000
## 2007.896 293.8000 57.87000
## 2007.915 291.2000 61.80000
## 2007.934 290.7000 9.40000
## 2007.953 290.5000 7.47000
## 2007.973 291.8000 27.33000
## 2007.992 287.8000 47.59000
## 2008.011 292.9000 39.00000
## 2008.030 292.6000 143.35000
## 2008.049 292.7000 39.69000
## 2008.068 291.8000 33.00000
## 2008.088 292.7000 37.00000
## 2008.107 293.2000 29.00000
## 2008.126 293.4000 59.10000
## 2008.145 292.1000 53.50000
## 2008.164 292.7000 63.27000
## 2008.183 292.4000 121.30000
## 2008.203 294.0000 53.90000
## 2008.222 292.7000 67.90000
## 2008.241 292.7000 111.90000
## 2008.260 294.0000 149.10000
## 2008.279 293.1000 107.48000
## 2008.298 293.7000 63.90000
## 2008.318 295.2000 199.52000
## 2008.337 294.7000 90.68000
## 2008.356 293.4000 139.55000
## 2008.375 295.1000 53.25000
## 2008.394 295.2000 57.61000
## 2008.413 293.9000 41.60000
## 2008.433 295.7192 40.15182
## 2008.452 294.2000 93.55000
## 2008.471 295.2000 149.77000
## 2008.490 292.7000 53.81000
## 2008.509 294.0000 66.10000
## 2008.528 294.5000 93.30000
## 2008.548 292.9000 48.72000
## 2008.567 294.2000 124.00000
## 2008.586 294.3000 102.72000
## 2008.605 294.5000 87.28000
## 2008.624 293.6000 108.83000
## 2008.643 293.6000 66.83000
## 2008.663 294.6000 49.93000
## 2008.682 294.1000 63.30000
## 2008.701 293.1000 50.64000
## 2008.720 292.6000 74.50000
## 2008.739 294.9000 62.74000
## 2008.758 294.3000 93.80000
## 2008.778 292.9000 59.50000
## 2008.797 292.7000 46.43000
## 2008.816 293.4000 39.89000
## 2008.835 292.7000 73.00000
## 2008.854 292.8000 53.91000
## 2008.873 289.9000 112.31000
## 2008.893 292.0000 45.97000
## 2008.912 293.2000 66.41000
## 2008.931 292.3000 55.50000
## 2008.950 291.4000 39.67000
## 2008.969 292.7000 40.10000
## 2008.988 292.3000 12.93000
## 2009.008 290.4000 39.30000
## 2009.027 290.7000 34.40000
## 2009.046 292.2000 43.20000
## 2009.065 293.0000 25.30000
## 2009.084 293.4000 45.34000
## 2009.103 293.5000 78.37000
## 2009.123 291.8000 9.30000
## 2009.142 293.5000 23.01000
## 2009.161 293.7000 33.00000
## 2009.180 294.8000 79.10000
## 2009.199 294.3000 43.94000
## 2009.218 293.8000 18.10000
## 2009.238 294.1000 67.40000
## 2009.257 294.9000 84.54000
## 2009.276 292.2000 47.31000
## 2009.295 296.0000 31.65000
## 2009.314 294.5000 47.00000
## 2009.333 295.1000 60.70000
## 2009.352 295.0000 134.43000
## 2009.372 294.6000 49.32000
## 2009.391 295.0000 208.87000
## 2009.410 294.9000 66.30000
## 2009.429 295.7192 40.15182
## 2009.448 292.8000 8.50000
## 2009.467 293.8000 144.60000
## 2009.487 294.8000 31.20000
## 2009.506 295.0000 65.76000
## 2009.525 295.6000 95.83000
## 2009.544 295.5000 172.70000
## 2009.563 294.5000 54.20000
## 2009.582 295.2000 288.40000
## 2009.602 295.8000 144.98000
## 2009.621 292.8000 86.10000
## 2009.640 294.0000 191.76000
## 2009.659 294.6000 214.90000
## 2009.678 294.2000 24.25000
## 2009.697 294.6000 164.70000
## 2009.717 294.3000 150.80000
## 2009.736 294.7000 81.40000
## 2009.755 294.6000 23.60000
## 2009.774 294.6000 85.46000
## 2009.793 294.0000 87.30000
## 2009.812 290.1000 8.80000
## 2009.832 294.5000 45.00000
## 2009.851 291.9000 207.10000
## 2009.870 292.4000 50.60000
## 2009.889 291.9000 62.33000
## 2009.908 292.3000 36.90000
## reanalysis_relative_humidity_percent
## 2007.647 93.45143
## 2007.666 94.07429
## 2007.685 90.95714
## 2007.704 95.15714
## 2007.723 92.12429
## 2007.743 97.97143
## 2007.762 93.66286
## 2007.781 93.15857
## 2007.800 91.50429
## 2007.819 96.62143
## 2007.838 96.02571
## 2007.858 93.98286
## 2007.877 88.81000
## 2007.896 95.86000
## 2007.915 93.79571
## 2007.934 86.52429
## 2007.953 85.65571
## 2007.973 93.05571
## 2007.992 92.77714
## 2008.011 92.04857
## 2008.030 91.09286
## 2008.049 90.72714
## 2008.068 78.27714
## 2008.088 84.49143
## 2008.107 83.05000
## 2008.126 92.65286
## 2008.145 88.52571
## 2008.164 90.18143
## 2008.183 79.50286
## 2008.203 78.45429
## 2008.222 88.85714
## 2008.241 93.85429
## 2008.260 92.60857
## 2008.279 95.29000
## 2008.298 88.32857
## 2008.318 94.14143
## 2008.337 95.26000
## 2008.356 94.64000
## 2008.375 88.55143
## 2008.394 91.77714
## 2008.413 81.86857
## 2008.433 82.16196
## 2008.452 95.22286
## 2008.471 98.61000
## 2008.490 92.46714
## 2008.509 94.92857
## 2008.528 97.00714
## 2008.548 94.23429
## 2008.567 92.90571
## 2008.586 95.12143
## 2008.605 94.37857
## 2008.624 98.13429
## 2008.643 95.70857
## 2008.663 94.90286
## 2008.682 96.39571
## 2008.701 89.67286
## 2008.720 97.30000
## 2008.739 96.66429
## 2008.758 95.07857
## 2008.778 95.10000
## 2008.797 93.29857
## 2008.816 91.79000
## 2008.835 97.74286
## 2008.854 95.50714
## 2008.873 94.13000
## 2008.893 93.97143
## 2008.912 94.55571
## 2008.931 94.53857
## 2008.950 95.38571
## 2008.969 94.62429
## 2008.988 88.23000
## 2009.008 89.97143
## 2009.027 87.81143
## 2009.046 87.11000
## 2009.065 80.64000
## 2009.084 88.17714
## 2009.103 94.99286
## 2009.123 75.23286
## 2009.142 78.11857
## 2009.161 83.76286
## 2009.180 91.57571
## 2009.199 89.31000
## 2009.218 79.22286
## 2009.238 90.65714
## 2009.257 93.80857
## 2009.276 90.37286
## 2009.295 84.31143
## 2009.314 80.78714
## 2009.333 89.59429
## 2009.352 91.70857
## 2009.372 87.75286
## 2009.391 92.95857
## 2009.410 96.88571
## 2009.429 82.16196
## 2009.448 78.27143
## 2009.467 89.80714
## 2009.487 87.64143
## 2009.506 91.79857
## 2009.525 90.64857
## 2009.544 96.51571
## 2009.563 88.36571
## 2009.582 94.91571
## 2009.602 97.70000
## 2009.621 96.25000
## 2009.640 96.12429
## 2009.659 93.08286
## 2009.678 88.70714
## 2009.697 95.18286
## 2009.717 93.65571
## 2009.736 95.99571
## 2009.755 87.65714
## 2009.774 96.71286
## 2009.793 97.44571
## 2009.812 78.99857
## 2009.832 88.76571
## 2009.851 91.60000
## 2009.870 94.28000
## 2009.889 94.66000
## 2009.908 89.08286
## reanalysis_specific_humidity_g_per_kg reanalysis_tdtr_k
## 2007.647 16.99714 7.214286
## 2007.666 17.50714 6.557143
## 2007.685 17.42143 8.600000
## 2007.704 18.31571 7.400000
## 2007.723 17.50429 7.785714
## 2007.743 17.96429 4.885714
## 2007.762 18.39857 8.685714
## 2007.781 16.18000 6.971429
## 2007.800 14.78000 7.385714
## 2007.819 17.14429 5.957143
## 2007.838 17.52000 5.757143
## 2007.858 16.71143 6.771429
## 2007.877 15.37571 9.300000
## 2007.896 17.44714 6.957143
## 2007.915 16.71286 7.385714
## 2007.934 15.28571 9.442857
## 2007.953 15.08000 9.271429
## 2007.973 16.14286 8.442857
## 2007.992 16.58286 8.600000
## 2008.011 16.87286 9.771429
## 2008.030 17.05714 9.742857
## 2008.049 16.84714 9.342857
## 2008.068 15.99857 13.557143
## 2008.088 16.65286 10.742857
## 2008.107 16.46571 10.657143
## 2008.126 17.03000 7.685714
## 2008.145 16.81857 8.571429
## 2008.164 17.04714 8.157143
## 2008.183 16.33143 12.785714
## 2008.203 17.01857 12.014286
## 2008.222 17.52714 9.971429
## 2008.241 18.38857 8.714286
## 2008.260 18.48429 8.571429
## 2008.279 19.25286 7.085714
## 2008.298 17.62571 10.014286
## 2008.318 19.61714 7.814286
## 2008.337 19.38857 7.100000
## 2008.356 18.77857 7.142857
## 2008.375 17.78429 9.200000
## 2008.394 18.57286 9.057143
## 2008.413 17.24857 10.342857
## 2008.433 16.74643 4.903754
## 2008.452 18.46143 7.500000
## 2008.471 17.99571 3.714286
## 2008.490 16.64143 6.485714
## 2008.509 18.13000 8.142857
## 2008.528 18.48429 5.185714
## 2008.548 17.76571 7.171429
## 2008.567 17.85286 6.828571
## 2008.586 18.12857 7.071429
## 2008.605 18.35429 6.800000
## 2008.624 18.35286 6.028571
## 2008.643 18.10571 6.185714
## 2008.663 17.78000 6.357143
## 2008.682 18.17571 6.742857
## 2008.701 17.42000 9.028571
## 2008.720 17.70429 6.385714
## 2008.739 18.50429 4.985714
## 2008.758 18.01857 6.271429
## 2008.778 18.09000 7.142857
## 2008.797 17.85857 9.071429
## 2008.816 17.58571 10.071429
## 2008.835 17.83000 5.614286
## 2008.854 16.75714 6.071429
## 2008.873 15.48286 6.242857
## 2008.893 16.36286 7.714286
## 2008.912 17.66714 8.642857
## 2008.931 16.87429 8.642857
## 2008.950 16.68000 8.128571
## 2008.969 16.92000 7.271429
## 2008.988 15.51000 9.528571
## 2009.008 16.60286 9.757143
## 2009.027 16.33714 11.757143
## 2009.046 17.04000 11.342857
## 2009.065 16.22857 10.928571
## 2009.084 18.12286 11.785714
## 2009.103 17.98857 7.642857
## 2009.123 15.86571 13.042857
## 2009.142 16.20286 11.600000
## 2009.161 17.38000 11.000000
## 2009.180 17.94714 8.514286
## 2009.199 18.13429 9.285714
## 2009.218 16.89571 11.885714
## 2009.238 18.66143 8.571429
## 2009.257 19.25429 8.342857
## 2009.276 18.93714 10.185714
## 2009.295 18.66429 10.457143
## 2009.314 17.80714 11.928571
## 2009.333 19.00143 8.714286
## 2009.352 18.67143 7.757143
## 2009.372 18.30429 10.442857
## 2009.391 18.60143 6.671429
## 2009.410 18.18000 5.257143
## 2009.429 16.74643 4.903754
## 2009.448 16.12714 11.100000
## 2009.467 17.75857 9.157143
## 2009.487 18.00143 8.628571
## 2009.506 18.19286 7.685714
## 2009.525 18.52286 8.314286
## 2009.544 19.34571 6.328571
## 2009.563 18.85714 9.414286
## 2009.582 19.77286 8.171429
## 2009.602 19.75429 6.242857
## 2009.621 20.09143 8.814286
## 2009.640 20.46143 8.828571
## 2009.659 19.36857 8.028571
## 2009.678 18.21429 9.514286
## 2009.697 20.07857 7.714286
## 2009.717 18.67714 7.228571
## 2009.736 19.44857 7.757143
## 2009.755 18.06857 8.257143
## 2009.774 18.60286 5.714286
## 2009.793 18.39143 6.185714
## 2009.812 14.90857 11.242857
## 2009.832 18.48571 9.800000
## 2009.851 18.07000 7.471429
## 2009.870 17.00857 7.500000
## 2009.889 16.81571 7.871429
## 2009.908 17.35571 11.014286
## station_avg_temp_c station_diur_temp_rng_c station_max_temp_c
## 2007.647 27.18578 8.059328 31.70000
## 2007.666 26.90000 8.266667 31.70000
## 2007.685 27.86667 9.000000 33.40000
## 2007.704 28.30000 9.000000 32.80000
## 2007.723 26.80000 8.100000 33.60000
## 2007.743 26.65000 7.700000 33.00000
## 2007.762 27.86667 8.000000 32.50000
## 2007.781 26.60000 8.966667 32.40000
## 2007.800 26.16667 7.900000 31.00000
## 2007.819 26.35000 8.850000 31.50000
## 2007.838 27.20000 9.200000 32.30000
## 2007.858 26.90000 7.550000 31.10000
## 2007.877 27.18578 8.059328 32.45244
## 2007.896 27.18578 8.059328 32.45244
## 2007.915 27.18578 8.059328 32.45244
## 2007.934 27.18578 8.059328 32.45244
## 2007.953 27.18578 8.059328 32.45244
## 2007.973 27.18578 8.059328 32.45244
## 2007.992 26.60000 9.775000 32.40000
## 2008.011 26.68000 11.240000 33.40000
## 2008.030 27.40000 12.100000 34.20000
## 2008.049 27.90000 11.225000 34.80000
## 2008.068 28.00000 14.075000 38.60000
## 2008.088 27.83333 12.533333 35.10000
## 2008.107 27.35000 13.225000 36.20000
## 2008.126 27.96667 12.583333 36.20000
## 2008.145 27.80000 11.600000 35.60000
## 2008.164 27.75000 12.450000 37.00000
## 2008.183 27.18578 8.059328 36.00000
## 2008.203 30.03333 13.966667 37.00000
## 2008.222 26.45000 9.100000 34.70000
## 2008.241 27.33333 10.066667 35.50000
## 2008.260 27.40000 11.350000 35.00000
## 2008.279 27.82000 12.100000 35.60000
## 2008.298 28.30000 12.866667 36.00000
## 2008.318 27.96667 12.100000 34.50000
## 2008.337 26.10000 8.350000 33.50000
## 2008.356 26.96000 10.640000 33.70000
## 2008.375 27.80000 11.175000 35.00000
## 2008.394 27.82500 12.150000 35.00000
## 2008.413 28.08000 12.020000 35.40000
## 2008.433 27.18578 8.059328 32.45244
## 2008.452 27.26667 11.100000 34.80000
## 2008.471 27.18000 10.240000 33.30000
## 2008.490 27.56667 10.700000 34.00000
## 2008.509 27.65000 11.650000 33.90000
## 2008.528 27.46667 12.333333 35.00000
## 2008.548 28.10000 12.333333 35.00000
## 2008.567 27.70000 12.540000 35.00000
## 2008.586 26.58000 10.520000 33.20000
## 2008.605 28.40000 11.450000 35.00000
## 2008.624 27.30000 11.800000 33.80000
## 2008.643 27.80000 10.500000 33.70000
## 2008.663 28.50000 11.500000 34.40000
## 2008.682 27.95000 10.900000 34.20000
## 2008.701 27.13333 10.866667 35.00000
## 2008.720 26.90000 10.833333 33.00000
## 2008.739 26.80000 8.700000 34.40000
## 2008.758 27.15000 10.750000 34.00000
## 2008.778 28.10000 10.500000 35.00000
## 2008.797 28.07500 11.425000 35.00000
## 2008.816 28.35000 11.450000 34.60000
## 2008.835 27.60000 10.266667 34.40000
## 2008.854 28.10000 11.800000 34.00000
## 2008.873 24.66667 8.633333 33.50000
## 2008.893 27.05000 10.900000 33.50000
## 2008.912 27.37500 11.125000 33.40000
## 2008.931 27.45000 10.700000 33.40000
## 2008.950 27.60000 10.766667 33.40000
## 2008.969 26.82500 10.425000 34.50000
## 2008.988 26.95000 10.250000 32.20000
## 2009.008 27.00000 11.500000 33.50000
## 2009.027 27.97500 12.100000 35.40000
## 2009.046 27.70000 11.500000 33.40000
## 2009.065 28.32000 12.860000 36.20000
## 2009.084 29.00000 13.000000 36.20000
## 2009.103 27.60000 13.200000 34.20000
## 2009.123 29.16667 14.133333 37.40000
## 2009.142 28.85000 12.750000 37.20000
## 2009.161 28.86667 13.300000 37.00000
## 2009.180 27.95000 12.225000 35.20000
## 2009.199 27.64000 11.660000 34.80000
## 2009.218 27.75000 10.650000 34.20000
## 2009.238 27.73333 12.200000 35.30000
## 2009.257 27.80000 11.320000 35.20000
## 2009.276 29.86667 12.733333 36.80000
## 2009.295 28.94000 11.960000 35.30000
## 2009.314 28.90000 12.333333 36.20000
## 2009.333 28.43333 11.833333 36.20000
## 2009.352 28.02500 10.375000 35.30000
## 2009.372 28.55000 11.000000 35.20000
## 2009.391 28.20000 11.125000 35.60000
## 2009.410 27.20000 8.200000 32.20000
## 2009.429 27.18578 8.059328 32.45244
## 2009.448 28.60000 12.300000 35.10000
## 2009.467 27.83333 11.300000 34.20000
## 2009.487 28.96667 11.266667 35.20000
## 2009.506 27.80000 10.520000 35.30000
## 2009.525 27.80000 9.266667 34.20000
## 2009.544 27.00000 8.300000 33.20000
## 2009.563 27.30000 11.800000 35.50000
## 2009.582 28.02000 10.360000 35.40000
## 2009.602 28.50000 9.900000 35.40000
## 2009.621 28.55000 10.050000 35.40000
## 2009.640 30.00000 12.000000 36.00000
## 2009.659 27.46667 9.333333 34.50000
## 2009.678 27.93333 12.300000 35.30000
## 2009.697 29.20000 12.300000 35.40000
## 2009.717 27.15000 9.600000 33.00000
## 2009.736 27.85000 9.600000 33.50000
## 2009.755 28.85000 12.125000 36.20000
## 2009.774 27.60000 9.600000 33.20000
## 2009.793 27.40000 10.400000 33.70000
## 2009.812 25.63333 9.200000 34.00000
## 2009.832 28.63333 11.933333 35.40000
## 2009.851 27.43333 10.500000 34.70000
## 2009.870 24.40000 6.900000 32.20000
## 2009.889 25.43333 8.733333 31.20000
## 2009.908 27.47500 9.900000 33.70000
## station_min_temp_c
## 2007.647 22.00000
## 2007.666 22.60000
## 2007.685 22.50000
## 2007.704 21.00000
## 2007.723 21.70000
## 2007.743 21.60000
## 2007.762 22.70000
## 2007.781 20.60000
## 2007.800 18.00000
## 2007.819 21.40000
## 2007.838 21.70000
## 2007.858 20.40000
## 2007.877 17.80000
## 2007.896 21.00000
## 2007.915 18.00000
## 2007.934 20.80000
## 2007.953 21.00000
## 2007.973 21.00000
## 2007.992 20.80000
## 2008.011 20.60000
## 2008.030 18.50000
## 2008.049 19.80000
## 2008.068 19.20000
## 2008.088 20.40000
## 2008.107 20.40000
## 2008.126 20.80000
## 2008.145 20.70000
## 2008.164 20.80000
## 2008.183 19.60000
## 2008.203 21.50000
## 2008.222 21.00000
## 2008.241 21.50000
## 2008.260 21.20000
## 2008.279 21.20000
## 2008.298 20.50000
## 2008.318 21.70000
## 2008.337 21.00000
## 2008.356 21.00000
## 2008.375 21.20000
## 2008.394 20.50000
## 2008.413 21.20000
## 2008.433 22.10215
## 2008.452 21.10000
## 2008.471 21.10000
## 2008.490 21.80000
## 2008.509 21.10000
## 2008.528 21.00000
## 2008.548 21.20000
## 2008.567 20.50000
## 2008.586 20.50000
## 2008.605 21.00000
## 2008.624 21.00000
## 2008.643 21.00000
## 2008.663 21.50000
## 2008.682 21.70000
## 2008.701 21.00000
## 2008.720 21.20000
## 2008.739 21.20000
## 2008.758 21.00000
## 2008.778 22.00000
## 2008.797 22.00000
## 2008.816 21.40000
## 2008.835 21.00000
## 2008.854 22.20000
## 2008.873 20.00000
## 2008.893 19.40000
## 2008.912 21.20000
## 2008.931 21.40000
## 2008.950 21.60000
## 2008.969 21.30000
## 2008.988 21.00000
## 2009.008 20.50000
## 2009.027 20.50000
## 2009.046 21.00000
## 2009.065 21.20000
## 2009.084 22.00000
## 2009.103 21.00000
## 2009.123 21.40000
## 2009.142 20.40000
## 2009.161 21.00000
## 2009.180 20.50000
## 2009.199 21.00000
## 2009.218 21.20000
## 2009.238 21.00000
## 2009.257 21.00000
## 2009.276 21.20000
## 2009.295 21.90000
## 2009.314 22.30000
## 2009.333 21.80000
## 2009.352 22.20000
## 2009.372 21.20000
## 2009.391 22.00000
## 2009.410 21.80000
## 2009.429 22.10215
## 2009.448 21.80000
## 2009.467 22.10000
## 2009.487 22.50000
## 2009.506 22.40000
## 2009.525 22.00000
## 2009.544 22.90000
## 2009.563 21.40000
## 2009.582 21.40000
## 2009.602 21.20000
## 2009.621 21.40000
## 2009.640 22.00000
## 2009.659 21.00000
## 2009.678 21.00000
## 2009.697 22.50000
## 2009.717 21.20000
## 2009.736 22.50000
## 2009.755 21.40000
## 2009.774 21.40000
## 2009.793 21.20000
## 2009.812 20.00000
## 2009.832 22.40000
## 2009.851 21.70000
## 2009.870 19.20000
## 2009.889 21.00000
## 2009.908 22.20000
accuracy(fit.fcst.arima.sj, valid.cases.diff.sj)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -0.001754407 13.45774 8.251882 NaN Inf 0.6628445 0.004469666
## Test set -1.650993653 12.12328 7.431525 NaN Inf 0.5969481 -0.155052566
## Theil's U
## Training set NA
## Test set NaN
accuracy(fit.fcst.arima.iq, valid.cases.diff.iq)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.001797607 7.175697 4.178178 NaN Inf 0.6280803 0.004935981
## Test set -0.278016343 6.215963 4.077756 NaN Inf 0.6129845 -0.188875861
## Theil's U
## Training set NA
## Test set NaN
Neural Net
#Size=1
fit1.sj <- nnetar(cases.diff.sj, xreg=xreg.sj.train, size=1,repeats=100,lambda="auto")
fcast1.sj <- forecast(fit1.sj, h=24, xreg=xreg.sj.test)
#Size=2
fit2.sj <- nnetar(cases.diff.sj, xreg=xreg.sj.train, size=2,repeats=100,lambda="auto")
fcast2.sj <- forecast(fit2.sj, h=24, xreg=xreg.sj.test)
#Size=3
fit3.sj <- nnetar(cases.diff.sj, xreg=xreg.sj.train, size=3,repeats=100,lambda="auto")
fcast3.sj <- forecast(fit3.sj, h=24, xreg=xreg.sj.test)
#Size=4
fit4.sj <- nnetar(cases.diff.sj, xreg=xreg.sj.train, size=4,repeats=100,lambda="auto")
fcast4.sj <- forecast(fit4.sj, h=24, xreg=xreg.sj.test)
#Size=5
fit5.sj <- nnetar(cases.diff.sj, xreg=xreg.sj.train, size=5,repeats=100,lambda="auto")
fcast5.sj <- forecast(fit5.sj, h=24, xreg=xreg.sj.test)
autoplot(fcast1.sj)+autolayer(fcast2.sj, series="size=2")+autolayer(fcast3.sj, series="size=3")+autolayer(fcast4.sj, series="size=4")+autolayer(fcast5.sj, series="size=5")+autolayer(valid.cases.diff.sj, series="Orig")+coord_cartesian(xlim = c(2005, 2008))+ylim(-50, 50)
autoplot(diffinv(fcast1.sj$mean, xi=112))+autolayer(diffinv(valid.cases.diff.sj, xi=112), series="Orig")
Accuracy, they are all really close, so I am going to stick with size=1
kable(accuracy(fcast1.sj,valid.cases.diff.sj),caption="NNAR(13,1,1)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | -0.0144232 | 12.20853 | 7.298412 | NaN | Inf | 0.5862556 | 0.1126203 | NA |
| Test set | -1.0908624 | 11.97830 | 7.222230 | NaN | Inf | 0.5801362 | -0.1669801 | NaN |
kable(accuracy(fcast2.sj,valid.cases.diff.sj),caption="NNAR(13,1,2)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | -0.0132114 | 10.22842 | 6.512499 | NaN | Inf | 0.523126 | 0.0258677 | NA |
| Test set | -0.7480997 | 11.93446 | 7.116198 | NaN | Inf | 0.571619 | -0.1639925 | NaN |
kable(accuracy(fcast3.sj,valid.cases.diff.sj),caption="NNAR(13,1,3)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | -0.0137381 | 9.324173 | 6.048144 | NaN | Inf | 0.4858260 | 0.0107910 | NA |
| Test set | -0.6025257 | 11.981226 | 7.238839 | NaN | Inf | 0.5814703 | -0.1748187 | NaN |
kable(accuracy(fcast4.sj,valid.cases.diff.sj),caption="NNAR(13,1,4)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | 0.0000954 | 8.517263 | 5.465437 | NaN | Inf | 0.4390192 | 0.0026996 | NA |
| Test set | -0.5093721 | 12.172294 | 7.247682 | NaN | Inf | 0.5821807 | -0.1601930 | NaN |
kable(accuracy(fcast5.sj,valid.cases.diff.sj),caption="NNAR(13,1,5)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | -0.0097162 | 7.59050 | 4.978950 | NaN | Inf | 0.3999414 | -0.0296850 | NA |
| Test set | -0.6212553 | 11.98408 | 7.150526 | NaN | Inf | 0.5743764 | -0.1696778 | NaN |
Neural Net
#Size=1
fit1.iq <- nnetar(cases.diff.iq, xreg=xreg.iq.train, size=1,repeats=100,lambda="auto")
fcast1.iq <- forecast(fit1.iq, h=24, xreg=xreg.iq.test)
#Size=2
fit2.iq <- nnetar(cases.diff.iq, xreg=xreg.iq.train, size=2,repeats=100,lambda="auto")
fcast2.iq <- forecast(fit2.iq, h=24, xreg=xreg.iq.test)
#Size=3
fit3.iq <- nnetar(cases.diff.iq, xreg=xreg.iq.train, size=3,repeats=100,lambda="auto")
fcast3.iq<- forecast(fit3.iq, h=24, xreg=xreg.iq.test)
#Size=4
fit4.iq <- nnetar(cases.diff.iq, xreg=xreg.iq.train, size=4,repeats=100,lambda="auto")
fcast4.iq <- forecast(fit4.iq, h=24, xreg=xreg.iq.test)
#Size=5
fit5.iq <- nnetar(cases.diff.iq, xreg=xreg.iq.train, size=5,repeats=100,lambda="auto")
fcast5.iq <- forecast(fit5.iq, h=24, xreg=xreg.iq.test)
autoplot(fcast1.iq)+autolayer(fcast2.iq, series="size=2")+autolayer(fcast3.iq, series="size=3")+autolayer(fcast4.iq, series="size=4")+autolayer(fcast5.iq, series="size=5")+autolayer(valid.cases.diff.iq, series="Orig")+coord_cartesian(xlim = c(2007, 2010))+ylim(-50, 50)
autoplot(diffinv(fcast1.iq$mean, xi=9))+autolayer(diffinv(valid.cases.diff.iq, xi=9), series="Orig")
Accuracy, , they are all really close, so I am going to stick with size=1
kable(accuracy(fcast1.iq,valid.cases.diff.iq),caption="NNAR(4,1,1)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | 0.3070690 | 7.970568 | 3.860653 | NaN | Inf | 0.5803487 | -0.1039925 | NA |
| Test set | -0.0969935 | 5.958823 | 3.721537 | NaN | Inf | 0.5594362 | -0.2455145 | NaN |
kable(accuracy(fcast2.iq,valid.cases.diff.iq),caption="NNAR(4,1,2)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | 0.1050144 | 7.173085 | 3.426589 | NaN | Inf | 0.5150985 | -0.0685181 | NA |
| Test set | -0.1718781 | 6.046592 | 3.749931 | NaN | Inf | 0.5637046 | -0.2304863 | NaN |
kable(accuracy(fcast3.iq,valid.cases.diff.iq),caption="NNAR(4,1,3)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | 0.1180780 | 6.391123 | 2.937410 | NaN | Inf | 0.4415632 | -0.0359170 | NA |
| Test set | -0.1984653 | 6.055794 | 3.756404 | NaN | Inf | 0.5646776 | -0.2397218 | NaN |
kable(accuracy(fcast4.iq,valid.cases.diff.iq),caption="NNAR(4,1,4)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | 0.1209073 | 5.580210 | 2.577832 | NaN | Inf | 0.3875100 | -0.0158883 | NA |
| Test set | -0.2255450 | 6.090679 | 3.794035 | NaN | Inf | 0.5703345 | -0.2377051 | NaN |
kable(accuracy(fcast5.iq,valid.cases.diff.iq),caption="NNAR(4,1,5)[52]")
| ME | RMSE | MAE | MPE | MAPE | MASE | ACF1 | Theil’s U | |
|---|---|---|---|---|---|---|---|---|
| Training set | 0.1229006 | 4.784357 | 2.158821 | NaN | Inf | 0.3245225 | 0.0190075 | NA |
| Test set | -0.2131806 | 6.074590 | 3.784238 | NaN | Inf | 0.5688618 | -0.2319003 | NaN |
#Submission
#SJ
test.sj.xreg<-test.sj[,5:23]
test.sj.xreg<-test.sj.xreg[,-13]
fcast1.sj <- forecast(fit1.sj, h=3, xreg=test.sj.xreg)
submission_format.sj<-submission_format[1:260,]
submission_format.sj<-submission_format.sj[,-4]
submission_format.sj<-cbind(submission_format.sj, total_cases=diffinv(fcast1.sj$mean, xi=49)[1:260])
#IQ
test.iq.xreg<-test.iq[,5:23]
test.iq.xreg<-test.iq.xreg[,-13]
fcast1.iq <- forecast(fit1.iq, h=3, xreg=test.iq.xreg)
submission_format.iq<-submission_format[261:416,]
submission_format.iq<-submission_format.iq[,-4]
submission_format.iq<-cbind(submission_format.iq, total_cases=diffinv(fcast1.iq$mean, xi=4)[261:416])
submission_final<-rbind(submission_format.sj,submission_format.iq)
View(submission_final)
write.csv(submission_final, "C:/Users/jbiasi/OneDrive - CoStar Realty Information, Inc/Documents/Dengai/submission_final.csv", quote = F)