7.1

Question)

Describe a situation or problem from your job, everyday life, current events, etc., for which exponential smoothing would be appropriate. What data would you need? Would you expect the value of alpha (the first smoothing parameter) to be closer to 0 or 1, and why?

Answer:

Growing up in a background in agriculture, yields for crops for a given season I would deem to be appropriate for applying exponential smoothing. Yields can be determined by a number of factors including weather, frequency and quality of fertilizers & herbicides, and the amount of rotation for the field (i.e. changing a field to grow a different crop type). I will focus on hay/hailage since it is typically cut several times within a season.

For every field of hay for the study we would need daily measures of yield from the day it is planted (or conditions are warm enough for changes in yield for cases where not re-seeding is done) up until it is cut.

This would result in cyclical effects as there are several times (i.e. cuts) a farmers cuts their hay over a given season. Trend would also be present as yields tend to increase for the later cycles of the season.

Since there wouldn’t be too much variability in yields from week to week, I would anticipate that the value for alpha would be closer to 1 in this case to represent not much randomness in our data.

Answer:

7.2

Using the 20 years of daily high temperature data for Atlanta (July through October) from Question 6.2 (file temps.txt), build and use an exponential smoothing model to help make a judgment of whether the unofficial end of summer has gotten later over the 20 years. (Part of the point of this assignment is for you to think about how you might use exponential smoothing to answer this question. Feel free to combine it with other models if you’d like to. There’s certainly more than one reasonable approach.)

temps_data <- read.table('C:/Users/mjpearl/Desktop/omsa/ISYE-6501-OAN/hw4/data/temps.txt',header = TRUE, stringsAsFactors = FALSE)
head(temps_data)
##     DAY X1996 X1997 X1998 X1999 X2000 X2001 X2002 X2003 X2004 X2005 X2006
## 1 1-Jul    98    86    91    84    89    84    90    73    82    91    93
## 2 2-Jul    97    90    88    82    91    87    90    81    81    89    93
## 3 3-Jul    97    93    91    87    93    87    87    87    86    86    93
## 4 4-Jul    90    91    91    88    95    84    89    86    88    86    91
## 5 5-Jul    89    84    91    90    96    86    93    80    90    89    90
## 6 6-Jul    93    84    89    91    96    87    93    84    90    82    81
##   X2007 X2008 X2009 X2010 X2011 X2012 X2013 X2014 X2015
## 1    95    85    95    87    92   105    82    90    85
## 2    85    87    90    84    94    93    85    93    87
## 3    82    91    89    83    95    99    76    87    79
## 4    86    90    91    85    92    98    77    84    85
## 5    88    88    80    88    90   100    83    86    84
## 6    87    82    87    89    90    98    83    87    84

Create Time Series Data

In this section we will create a time series data object by passing a vector containing all time-series relevant data and excluding any date variables.

#Drop the day feature as it has no use to the vector we will be passing to the time series object 
drops <- c("DAY")
temps_data <- temps_data[ , !(names(temps_data) %in% drops)]

#Create vector from new dataframe and pass to time_series object creation
data <- as.vector(unlist(temps_data[,1:20]))

time_series <- ts(data, frequency=123, start=c(1996,7,1),end=c(2015,10,31))
plot(time_series)

Run Holt-Winters Test for Exponential Smoothing

In this section we run the HW test for different combinations either including or not including seasonality and/or trend.

hw_exp <- HoltWinters(time_series,beta=FALSE,gamma=FALSE)
hw_exp
## Holt-Winters exponential smoothing without trend and without seasonal component.
## 
## Call:
## HoltWinters(x = time_series, beta = FALSE, gamma = FALSE)
## 
## Smoothing parameters:
##  alpha: 0.8401212
##  beta : FALSE
##  gamma: FALSE
## 
## Coefficients:
##       [,1]
## a 84.22329

With the results we can determine that the best value for alpha found was 0.84 with a baseline of 84.22. With such a low value for alpha we can start to create an initial assumption that we shouldn’t expect to see much variation over the 20 year period.

hw_exp_trend <- HoltWinters(time_series,beta=FALSE)
hw_exp_trend
## Holt-Winters exponential smoothing without trend and with additive seasonal component.
## 
## Call:
## HoltWinters(x = time_series, beta = FALSE)
## 
## Smoothing parameters:
##  alpha: 0.6648223
##  beta : FALSE
##  gamma: 0.6272596
## 
## Coefficients:
##              [,1]
## a     71.08948138
## s1    12.87448302
## s2    11.04839995
## s3     8.89346371
## s4     9.59579851
## s5     7.80917682
## s6     4.46759353
## s7     2.30080427
## s8     4.64728086
## s9     2.40419343
## s10    3.50835191
## s11    1.70784274
## s12    2.98086627
## s13    6.19282322
## s14    5.01092284
## s15    8.52826688
## s16    5.43706177
## s17   10.35581798
## s18   10.09736025
## s19    9.63821461
## s20    7.67724469
## s21    7.17090341
## s22    6.31793433
## s23    5.84648170
## s24    5.74637094
## s25    4.23471410
## s26    7.18391943
## s27    4.58897220
## s28    5.97717031
## s29    6.45077505
## s30    5.73083931
## s31    3.57643295
## s32    3.89025932
## s33    3.51484054
## s34    2.81429843
## s35    2.09500635
## s36    2.60630670
## s37    1.65268669
## s38    0.17176878
## s39    0.01805922
## s40   -1.55626084
## s41   -2.19100464
## s42   -2.32550787
## s43    0.38998159
## s44    2.41408968
## s45    6.47372675
## s46    7.17204184
## s47    8.34583041
## s48    8.60780720
## s49    7.50430790
## s50    4.82551102
## s51    0.46714706
## s52   -1.04011188
## s53    1.55988189
## s54    1.62621886
## s55    0.83419836
## s56    2.86001742
## s57    0.55147121
## s58    4.41396012
## s59    4.50581973
## s60    3.01860944
## s61    3.76473367
## s62   -2.16836008
## s63    1.74554841
## s64    1.53272385
## s65    1.26675841
## s66    0.86622717
## s67    1.96351436
## s68    3.64124323
## s69    4.62445658
## s70    4.48980913
## s71    1.66553360
## s72    0.77626986
## s73    2.33736699
## s74    1.92415644
## s75   -1.66026444
## s76   -1.82629754
## s77   -0.44081995
## s78    0.05052496
## s79   -1.13533244
## s80   -1.03419849
## s81   -2.82187547
## s82   -4.59484305
## s83   -3.10856518
## s84   -2.73844357
## s85   -2.28929690
## s86   -4.57663516
## s87   -5.22261619
## s88   -4.47738155
## s89   -5.80520364
## s90   -7.46344822
## s91   -8.88065168
## s92   -8.62365450
## s93   -6.19022333
## s94   -6.02244189
## s95  -11.12487095
## s96  -13.44409821
## s97  -13.57587198
## s98  -14.35108706
## s99  -15.15223591
## s100 -14.45962171
## s101 -14.08268358
## s102 -16.26789452
## s103 -16.09448205
## s104 -12.16417339
## s105  -9.28139870
## s106 -10.49902846
## s107 -12.18491755
## s108  -9.81444750
## s109  -5.90252142
## s110  -8.07505307
## s111  -9.64118408
## s112 -10.50233437
## s113 -12.88723944
## s114  -8.69340613
## s115  -9.87750239
## s116 -14.59760898
## s117 -11.94926943
## s118  -8.83008669
## s119  -4.83142118
## s120  18.65085007
## s121  17.78416657
## s122  12.16050734
## s123  13.17135107
hw_exp_seasonal <- HoltWinters(time_series)
hw_exp_seasonal
## Holt-Winters exponential smoothing with trend and additive seasonal component.
## 
## Call:
## HoltWinters(x = time_series)
## 
## Smoothing parameters:
##  alpha: 0.6648032
##  beta : 0
##  gamma: 0.6272408
## 
## Coefficients:
##               [,1]
## a     71.063343113
## b     -0.004362918
## s1    12.898656422
## s2    11.072823521
## s3     8.918121877
## s4     9.620692611
## s5     7.834225028
## s6     4.492700971
## s7     2.325855884
## s8     4.672314160
## s9     2.429186892
## s10    3.533290169
## s11    1.732660128
## s12    3.005526398
## s13    6.217412871
## s14    5.035452320
## s15    8.552817150
## s16    5.461617819
## s17   10.380494047
## s18   10.122220765
## s19    9.663246239
## s20    7.702340992
## s21    7.196012985
## s22    6.342993995
## s23    5.871449376
## s24    5.771219502
## s25    4.259431188
## s26    7.208626104
## s27    4.613693985
## s28    6.001972222
## s29    6.475788099
## s30    5.755997406
## s31    3.601599343
## s32    3.915318912
## s33    3.539817341
## s34    2.839204563
## s35    2.119829046
## s36    2.631157927
## s37    1.677628610
## s38    0.196785573
## s39    0.043159179
## s40   -1.531257221
## s41   -2.166195703
## s42   -2.300902443
## s43    0.414463675
## s44    2.438544521
## s45    6.498231828
## s46    7.196609095
## s47    8.370503763
## s48    8.632627806
## s49    7.529281802
## s50    4.850618088
## s51    0.492240335
## s52   -1.015087342
## s53    1.584857571
## s54    1.651168007
## s55    0.859053012
## s56    2.884714045
## s57    0.576011137
## s58    4.438473119
## s59    4.530426680
## s60    3.043305039
## s61    3.789568797
## s62   -2.143504202
## s63    1.770441815
## s64    1.557656038
## s65    1.291675007
## s66    0.891040960
## s67    1.988225570
## s68    3.665903114
## s69    4.649133035
## s70    4.514513773
## s71    1.690245846
## s72    0.800972814
## s73    2.362185272
## s74    1.949127293
## s75   -1.635296628
## s76   -1.801406762
## s77   -0.415920239
## s78    0.075470113
## s79   -1.110337490
## s80   -1.009192425
## s81   -2.796912250
## s82   -4.569952404
## s83   -3.083746707
## s84   -2.713625223
## s85   -2.264511676
## s86   -4.551990817
## s87   -5.198013203
## s88   -4.452629913
## s89   -5.780318133
## s90   -7.438483366
## s91   -8.855657757
## s92   -8.598691002
## s93   -6.165180822
## s94   -5.997260147
## s95  -11.099628214
## s96  -13.418833373
## s97  -13.550640181
## s98  -14.325955463
## s99  -15.127295264
## s100 -14.434863783
## s101 -14.058047947
## s102 -16.243390736
## s103 -16.070070719
## s104 -12.139738522
## s105  -9.256911537
## s106 -10.474618120
## s107 -12.160595321
## s108  -9.790029446
## s109  -5.877890955
## s110  -8.050245940
## s111  -9.616235930
## s112 -10.477304191
## s113 -12.862307673
## s114  -8.668628346
## s115  -9.852808699
## s116 -14.573069827
## s117 -11.924865142
## s118  -8.805795677
## s119  -4.807165817
## s120  18.675303082
## s121  17.808999408
## s122  12.185573927
## s123  13.196630762

For the remaining tests where we’re testing the exponential with multiplicative seasonality enabled, followed by the second test with both seasonality and trend enabled that we’re still experiencing very low values for alpha, beta and gamma.

From these results we can likely conclude that there isn’t varation in the 20 year period.