Publications by Priyank Goyal
Forecasting-Regression
load("workspace.RData") library(fpp2) eg. monthly sales y depening upon ad spend x as predictor eg. quarterly percentage change of real personal consumption expenditure y, and real personal disposable income x, for the US from 1970 Q1 to 2016 Q3 autoplot(uschange[,c("Consumption","Income")]) + ylab("% change") + xlab("Year") Lets see the scatt...
4241 sym R (6904 sym/30 pcs) 16 img
The Forecaster's Toolbox
load("workspace.RData") library(fpp2) ## Warning: package 'fpp2' was built under R version 3.6.1 ## Loading required package: ggplot2 ## Registered S3 methods overwritten by 'ggplot2': ## method from ## [.quosures rlang ## c.quosures rlang ## print.quosures rlang ## Loading required package: forecast ## Warning: pack...
5874 sym R (8228 sym/58 pcs) 12 img
Time Series Graphics
Forecasting Principles and Practices Load the library fpp2 library(fpp2) autoplot(melsyd[,"Economy.Class"])+ ggtitle("Economy class passengers:Melbourne-Syney")+ xlab("Year")+ ylab("Thousands") Seasonal Plots ggseasonplot(a10,year.labels = TRUE,year.lables.left=TRUE)+ ylab("$ million")+ ggtitle("Seasonal plot: antidiabetic drug sa...
973 sym R (1051 sym/11 pcs) 9 img
Stationary Models
load("workspace.RData") Stationary models are suitable for residual series that contain no obvious trends or seasonal cycles. Moving Average Models See the theory here Simulation of MA Process The code below simulates the MA process set.seed(1) b <- c(0.8,0.6,0.4) x <- w <- rnorm(1000) for (t in 4:1000){ for (j in 1:3) x[t] <- x[t]+b[j]*w...
1744 sym R (1869 sym/23 pcs) 4 img
Regression
load("workspace.RData") Trends in time series can be classified as stochastic or deterministic. When we have some plausible physical explanation for a trend, we’ll usually model it in some deterministic manner. eg. the reason can be increasing population or seasonal frequency. For short term trends Linear Models are used. Simulation of Regress...
2073 sym R (865 sym/17 pcs) 4 img
Forecasting- Basic Stochastic Models
load("workspace.RData") Simulate white Noise Lets Simulate the ACF of the white noise. it is normally distributed set.seed(2) acf(rnorm(100)) Here the statistical significant value at lag =7 is due to sampling variation. Simulate Random Walk x <- w <- rnorm(1000) for (t in 2:1000)x[t] <- x[t-1]+w[t] plot(x,type="l") The series exhibits an ...
3709 sym R (1313 sym/33 pcs) 13 img
Forecasting Strategies-2
Exponential Smoothing load("workspace.RData") Here we assume there is no trend or seasonality here. We use it for forecasting sales of a well established product in a stable market. Complaints to a motoring Organisation Period: 1996 to 1999 Data: values Any Transformation in the Data: number Type: Number of Complaints Unit: Number Frequency: Mon...
1637 sym R (4288 sym/35 pcs) 7 img
Autocorrelation - Time Series
load("workspace.RData") ACF Command: For creating Autocorrelation functions. Even after taking out the seasonal and trend component, the random component may be serially correlated. We measure it using Correlograms. Below is the image of the correlogram wave.dat <- read.table("ts/wave.dat",header=T) acf(wave.dat$waveht) A correlogram has the f...
2783 sym R (554 sym/14 pcs) 6 img
Introduction to Time Series
Simple Time Series AirPassengers Data Lets Look at an existing time series data("AirPassengers") AP <- AirPassengers AP ## Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ## 1949 112 118 132 129 121 135 148 148 136 119 104 118 ## 1950 115 126 141 135 125 149 170 170 158 133 114 140 ## 1951 145 150 178 163 172 178 199 199 184 162 146 16...
4215 sym R (4987 sym/68 pcs) 15 img
Decomposition of Time Series
Decomposition of Series An Observed time series is made of three components 1. trend 2. Seasonal effect 3. Error Term Here we find how we can extract trend and seasonal effect Simple additive decomposition model is: x = trend + season + error Simple Multiplicative decomposition model is: x = trenx x season + error Trend: is calculated using Movin...
1200 sym R (786 sym/9 pcs) 3 img