Discussions for article "A Complete Tutorial on Time Series Modeling in R"

Hi All,

The article “A Complete Tutorial on Time Series Modeling in R” is quiet old now and you might not get a prompt response from the author.

We would request you to post your queries here to get them resolved.

A brief description of the article -

Time Series Modeling, as the name suggests, involves working on time-based data to derive hidden insights to make informed decision making. Time series models are very useful models when you have serially correlated data. Most of business houses work on time series data to analyze sales number for the next year, website traffic, competition position and much more.

If you want to understand the complete process of time series modeling, this guide would introduce you to various levels of time series modeling and its related techniques - such as Dickey-Fuller test, ARIMA modelling & forecasting and its derivative techniques.

Hi - I have Leads generated data for sales for 6 months (Daily Data) … I want to apply ARIMA model for Forecasting. Where do I start from? … I have arranged data in time series manner and started reading the above article. It says - “Time series models are very useful models when you have serially correlated data” … So, Should I apply correlation to check if data is positive or negative correlated? … Will that be my starting point?

Hi - I have Leads generated data for sales for 6 months (Daily Data) … I want to apply ARIMA model for Forecasting. Where do I start from?

@v.arora16 Before applying ARIMA model, you have to first check whether your time series data is stationary or not. If it is stationary then you can follow the steps given in the above tutorial else you should make your data stationary.


@pjoshi15 Just for clarification - doesn’t ARIMA handle stationarity by itself?

Hi @albela_angur,

To build an ARIMA model, time series must be stationary. It does not handle the stationarity by itself, you have to set the p,d,q parameters to build the ARIMA model. To learn more on how to make time series stationary and set these p,d,q parameters for ARIMA model, you can go through this course:

1 Like

Hi @PulkitS @pjoshi15

I believe @albela_angur is correct. ARIMA can take non-stationary series as input. It is in case or AR and MA models that you need to make the series stationary. Can someone confirm that ?

Hi @AishwaryaSingh, @albela_angur, @pjoshi15,

We can pass a non stationary series as an input in the ARIMA model. But it can not handle all kind of non stationarity by itself. Some non stationary time series can be made stationary just by differencing, i.e. setting the d parameter in the model. So for such case ARIMA can handle the non stationarity by itself. But there are cases where the time series can not be made stationary just by differencing. So, in such cases ARIMA model fails to handle the non stationarity by itself and we have to go for other approaches like: De-trending, Seasonal adjustment, EDA smoothing, etc.

Hi @PulkitS,

Thank you for the clarification.

Thanks for the valuable discussion @everyone!

I indeed searched for source which explicitly says “ARIMA can handle seasonality”. The closest statement that I could find was

d is the number of nonseasonal differences needed for stationarity,

mentioned here

1 Like

I have one more doubt, please bear with me :slight_smile:

Is there an algorithm, or any automated way, where it can handle all kinds of non-stationarity?

A friend of mine suggested using prophet library, but I couldnt wrap my head around the complexity. It would be great if you can suggest something around this?

Hi @albela_angur,

I don’t think there is any algorithm that can handle all kinds of non-stationarity by itself. I will research more about it and let you know if i finds something related to it.

Regarding the prophet library, it is optimized for the business forecast tasks which contains :

  • Hourly, daily, or weekly observations with at least a few months of history

  • Reasonable number of missing observations or large outliers

  • Strong multiple seasonality: day of week and time of year

  • Important holidays that occur at irregular intervals that are known in advance

So, it is a great library that can be used to forecast the time series.

1 Like

Thanks @PulkitS

Thank you for this article its really help full for me.
Actually I’m having the data set of daily dates and Prices of 13 years and using this I’ve to predict the values for next 30 days prices.
I got till the end correctly and I tested my whether my data was stationary or not. It’s Stationary.
But now I stuck a predicting the values as in the theory you mentioned “2.718^pred$pred”. Can you please help me to understand this ?
How to consider the particular value for my dataset?

Also I’m little bit confused how to consider p, d, q values? Can anyone explain me or help me out to clear my confusion

Thanks in advance


Very useful tutorial. Many Thanks.
In your tutorial, you consider that AirPassengers is not stationary but log(AirPassengers) is.

But the Augmented Dickey-Fuller Test for AirPassengers and log(AirPassengers) give save p.values (show below). Can you explain, please ? Thank your


data:  diff(AirPassengers)
Dickey-Fuller = -8.5472, Lag order = 0, p-value = 0.01
alternative hypothesis: stationary

data: diff(log(AirPassengers))
 Dickey-Fuller = -9.6003, Lag order = 0,
 p-value = 0.01
 alternative hypothesis: stationary

Very Nice Article.
We have differenced data once so d=1.
In Arima function we have to specify seasonal order as well i.e.we need to specify P,D, Q.which denotes seasonal terms for AR,differencing and MA
In arima function in seasonal you have mentioned (0,1,1) .Why we have taken D =1 ?
We have not seasonally differenced the series.
Really appreciate for your support.


The log of series is not stationary but after differencing the series becomes stationary. Arima can perform differencing if we set the value of parameter d. So we can use a the log of the series to fit the arima model.

Usually one level differencing is enough to make the series stationary, that is why the value of d is assigned as 1. In case the series does not become stationary with one level differencing, we can increase the value of d or use other transforms.

Secondly, the value of d here represents the number of times differencing will be performed. It does not represent the seasonality of the series.

Thanks for prompt reply.I am talking about D not d.In seasonal arima we have d which represents non seasonal differencing order and D which represents seasonal differencing order.I understand why d=1 but in seasonal part D is also 1 .Why is that so?

Please correct if I am wrong.how the orders chosen for this model.


  1. I didn’t get why we chose (0,1,1). When AR process we look at PACF and for MA we look at ACF right?
    i.e. we deduce ‘p’ from PACF plot and ‘q’ from ACF plot.

  2. can u please explain how we arrived at (0,1,1) values for (p,q,d)?

  3. what does it mean when there are significant spikes at many lags? PACF has significant spikes at lag 4, 7, 8 etc. so what is the p-value?

  4. Also ACF and PACF of order should have same correlation right?


I am currently trying to run the script from this tutorial. It all works until I get to
(fit <- arima(log(AirPassengers), c(0, 1, 1),seasonal = list(order = c(0, 1, 1), period = 12)))
Where I keep getting the error:

Error: unexpected ‘,’ in "(fit <- arima…

Why would this be?

© Copyright 2013-2019 Analytics Vidhya