Professional Documents
Culture Documents
Essentials of Data Analytics: Timeseries Forecasting
Essentials of Data Analytics: Timeseries Forecasting
DATA ANALYTICS
Lab : 2
Date: 27-01-2022
TIMESERIES FORECASTING
Aim:
To convert data into timeseries data and then to predict the future values by
forecasting the timeseries dataset.
Importing dataset:
Dataset preview:
Forecasting plot:
ACF and PACF after forecasting:
FINAL CODE :
class(Soyaoil)
Soya=ts(Soyaoil$Dollar,start=1,frequency = 4)
class(Soya)
plot(Soya,xlab='years',ylab='Dollors')
dTs<-diff(Soya)
plot(dTs)
lTs<-log10(Soya)
plot(lTs)
dlTs<-diff(lTs)
plot(dlTs)
par(mfrow=c(1,2))
acf(dlTs,main='AutoCorrelationFactor')
pacf(dlTs,main='PartialAutoCorrelationFactor')
library(forecast)
library(tseries)
ar<-auto.arima(dlTs,ic="aic",trace = TRUE)
attributes(ar)
par(mfrow=c(1,1))
myfc<-forecast(ar,level=c(95),h=10*4)
myfc
plot(myfc)
par(mfrow=c(1,2))
acf(ts(ar$residuals),main='ACF Residual')
pacf(ts(ar$residuals),main='PACF Residual')
Importing dataset:
Dataset preview:
Forecasting:
Forecasting plot:
Inference: