Required R Libraries

  1. Tidymodels package

  2. Tidyverse package

  3. Modeltime

  4. Timetk

library(tidymodels)
library(tidyverse)
library(modeltime)
library(timetk)

The USM Heat Index Data

Data was recorded from October 06, 2020, at 9:00 PM until April 26, 2021, at 2:00 PM with a 15-minute interval. The data contains heat index (Heat), Date and Time columns. Date and Time were combined to create a single variable Date_Time.

The Structure of the Data

glimpse(usmdata)
## Rows: 18,591
## Columns: 2
## $ Heat      <dbl> 26.6, 26.3, 26.2, 26.1, 25.9, 25.9, 25.8, 25.7, 25.6, 25.6, …
## $ Date_Time <dttm> 2020-10-06 21:00:00, 2020-10-06 21:15:00, 2020-10-06 21:30:…
head(usmdata, 10)
## # A tibble: 10 × 2
##     Heat Date_Time          
##    <dbl> <dttm>             
##  1  26.6 2020-10-06 21:00:00
##  2  26.3 2020-10-06 21:15:00
##  3  26.2 2020-10-06 21:30:00
##  4  26.1 2020-10-06 21:45:00
##  5  25.9 2020-10-06 22:00:00
##  6  25.9 2020-10-06 22:15:00
##  7  25.8 2020-10-06 22:30:00
##  8  25.7 2020-10-06 22:45:00
##  9  25.6 2020-10-06 23:00:00
## 10  25.6 2020-10-06 23:15:00

Plot of the Time Series Data

Time Series Modeling

Splitting Data into Training (90%) and Testing Sets (10%)

## <Training/Testing/Total>
## <16731/1860/18591>

Using Prophet

## parsnip model object
## 
## PROPHET Model
## - growth: 'linear'
## - n.changepoints: 25
## - changepoint.range: 0.8
## - yearly.seasonality: 'TRUE'
## - weekly.seasonality: 'TRUE'
## - daily.seasonality: 'TRUE'
## - seasonality.mode: 'additive'
## - changepoint.prior.scale: 0.05
## - seasonality.prior.scale: 10
## - holidays.prior.scale: 10
## - logistic_cap: NULL
## - logistic_floor: NULL
## - extra_regressors: 0

Using ARIMA Regression

## frequency = 96 observations per 1 day
## parsnip model object
## 
## Series: outcome 
## ARIMA(4,0,1)(0,1,0)[96] 
## 
## Coefficients:
##          ar1     ar2      ar3     ar4     ma1
##       0.7657  0.3603  -0.2877  0.0711  0.6969
## s.e.  0.1330  0.1956   0.0908  0.0223  0.1324
## 
## sigma^2 = 4.695:  log likelihood = -36465.86
## AIC=72943.73   AICc=72943.73   BIC=72990.04

Comparing Model Performance

## # A tibble: 2 × 9
##   .model_id .model_desc             .type   mae  mape  mase smape  rmse   rsq
##       <int> <chr>                   <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1         1 PROPHET                 Test  13.0   33.3  9.92  42.3  15.0 0.639
## 2         2 ARIMA(4,0,1)(0,1,0)[96] Test   7.94  17.7  6.06  19.5  11.8 0.426
## Using '.calibration_data' to forecast.

Forecast the next 7 Days