Time series
transformation
Models
White noise
Random walk
autoregression
simple moving average
R functions
Simulations
modeling
forecasting
Plot/ts.plot()
ts()
is.ts()
Predicting the future:Some time series exhibit predictability when strong periodic or seasonal patterns are present. Other time series exhibit predictability when positive autocorrelation - or correlation among neighboring observations - induces what appear as short-term trends.
not exhibit any clear trends over time
Linear
Rapid Growth
Periodic
Variance
Sample Transformations: log() :check ; can linearize a rapid growth trend
Sample transformations: diff() can remove a linear trend
Sample Transformations: diff(..,s) seasonal difference transformation, can remove periodic trends
White Noise Model:
A fixed constant mean
A fixed, constant variance
No correelation over time
ARIMA is an abbreviation for the autoregressive integrated moving average class of models
ARIMA(p, d, q) model has three parts, the autoregressive order p, the order of integration (or differencing) d, and the moving average order q
Random Walk (RW) Model
Non - stationary process
No specified mean or variance
Strong dependence over time
Its changes or increlents are WN
Random Walk with and without draft
pairs()
Correlations: Standardized version of covariance
+1: perfectyly positive linear relationship
-1: perfectly negative linear relationship
0: no linear association
Autocorrelation:(lagged correlation) are used to assess whether a time series is dependent on its past
(x[t], x[t-1])
acf(..., lag.max = 1, plot = FALSE)
xts: A matrix indexed on a time-based object
periodicity
nmonths
ndays
nyears
Forecast
ts(mydata[,2:4], start = c(1981, 1), frequency = 4): Creating time series objects
Time series plots: autoplot(), gglagplot(), ggAcf()
forecast and ggplot2, fpp2
Seasonal plots: ggseasonplot(polar = T), ggsubseriesplot()
Trends, seasonality and cyclicity
White noise: ljung-Box test: small p-value indicates the data are probably not white noise
Forecast
naive forecast: use the most recent observation
naive
snaive
checkresiduals
Well done! A good model forecasts well (so has low RMSE on the test set) and uses all available information in the training data (so has white noise residuals).
tsCV()
mean
Exponentially weighted forecasts
ses: no trend or seasonality
holt
ETS models