Time Series Analysis and Forecasting using ARIMA models in R

Поділитися
Вставка
  • Опубліковано 17 вер 2024
  • This R tutorial will help you understand the Basics of ARIMA Models in R. In this video, we will cover how to build a model from scratch. The ADF (Augmented Dickey-Fuller test) will be used to check the stationarity of the series. We will also use the PACF and ACF plots to identify the p and q term of the ARIMA Model.
    Broad Topics are outlined below:
    1/ Import Data/Change working Directory
    2/ Covert Sales data into R time series object
    3/ Check Stationarity
    4/ Apply Differencing if not stationary
    5/ Identify autoregressive term using PACF plot
    6/ Identify moving average term using ACF plot
    7/ Build ARIMA model using the arima() function
    8/ Use forecast() function to forecast 12 months ahead
    9/ Plot Time Series with Forecast
    Code and Data Download: github.com/Kun...
    #ARIMA #Forecasting #R #TimeSeriesAnalysis

КОМЕНТАРІ • 105

  • @nathasyapramudita6312
    @nathasyapramudita6312 3 місяці тому +1

    Your video is the best explaination about ARIMA model so far in youtube, thanks for the information :)

  • @mundocuadra5151
    @mundocuadra5151 2 роки тому +3

    This is all you need to grasp an idea of how to build an ARIMA model using R. No more, no less, great video.

  • @HiltonFernandes
    @HiltonFernandes Місяць тому

    Great presentation: very clear and yet very informative, far from trivial.
    Congratulations !

  • @yokokoko9748
    @yokokoko9748 3 роки тому +1

    I just learned three weeks of work in 8 minutes. You can't beat expertise!! Thank you, Kunaal!!!

    • @yokokoko9748
      @yokokoko9748 3 роки тому

      @kunaal, do you offer tutoring? I am a business analytics MS candidate, will need some help

  • @ZhalgasOK
    @ZhalgasOK 2 роки тому +2

    Excellent lesson, I studied the whole semester but you explained it in 10 minutes

    • @KunaalNaik
      @KunaalNaik  2 роки тому +2

      I am glad you found it useful :) I usually start by learning in the context in which it is applied and then learn the theory later.

  • @bheemannanayak6728
    @bheemannanayak6728 2 роки тому +3

    Very nice explained but I did understand p value from ACF and q value from PACF plot for AR and MA respectively.

  • @sojibulislam1004
    @sojibulislam1004 2 роки тому +2

    Very Impressive.. Alhamdulillah...thank u

  • @jaelee5805
    @jaelee5805 6 місяців тому

    This is a 😀😀great video for beginners like me!! Thank you

  • @bumpagab
    @bumpagab 2 роки тому +1

    So well done. Thank you so much!

  • @sachithralakshani3509
    @sachithralakshani3509 2 роки тому

    Nice explanation on ARIMA...

  • @talkontech8524
    @talkontech8524 3 роки тому +1

    Thank you for Amazing explanation. I had a doubt regarding the forecasting step where the model was passed as paramter, but I read that the time series data can also be passed. Coukd you explain how that works. Thank you

  • @daphnechindundu1838
    @daphnechindundu1838 24 дні тому

    Thank you so much

  • @ravindrasinghs3014
    @ravindrasinghs3014 3 роки тому +1

    Nice one & Simple

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      I am glad you liked it!

    • @ravindrasinghs3014
      @ravindrasinghs3014 3 роки тому +1

      @@KunaalNaik Yes Understood. Thanks. Looking for the same using Python from your end!

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      @@ravindrasinghs3014 Will work on a Video :)

  • @chenstephen636
    @chenstephen636 3 роки тому +1

    Great video! I wonder if we would need to transform the predicted value, given our data has been differenced twice? If so, how can we do it in R?

  • @parasnathverma1405
    @parasnathverma1405 3 роки тому +3

    Sir, I did the same steps, but my forecasted value is showing constant for upcoming years. How to solve this issue. Please guide

  • @shakirullah5840
    @shakirullah5840 3 роки тому +1

    Thank you very much for the nice video that is so much helpful. Would you please explain the out put as the forecast results? What is really mean by Lo 80, Hi 80, Lo 95, Hi 95 and Point Forecast?

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      Those are just upper and lower ranges of the forecast.

  • @suprateekpande6326
    @suprateekpande6326 2 роки тому +2

    Nicely explained but don't we get p value from ACF plot and q value from PACF plot for AR and MA respectively?

  • @raminguyen7940
    @raminguyen7940 Рік тому +1

    Can you explain more about how to determine the p and q values? I am not quite understanding. Thanks.

  • @nikeshdubey4129
    @nikeshdubey4129 2 роки тому +1

    ❤️❤️

  • @danielgutierrez536
    @danielgutierrez536 3 роки тому +1

    It seems that the series contain seasonality as the coefficients for the MA part are significant for t=12,24,.... Could expand on this issue? Thank you.

  • @katerina8287
    @katerina8287 3 роки тому +1

    Very good work! One question only. Does the ADF test you did recognizes that there is unit root? You mentioned only the stationarity problem. And if there is unit root how can we deal it?

    • @KunaalNaik
      @KunaalNaik  2 роки тому +1

      You can try some other tests such as Elliott-Rothenberg-Stock Test, Schmidt-Phillips Test, Phillips-Perron (PP) Test and Zivot-Andrews test.

  • @rabinthapa9006
    @rabinthapa9006 3 роки тому +1

    Thank you its amazing

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      I am glad you liked it :)

    • @rabinthapa9006
      @rabinthapa9006 3 роки тому +2

      @@KunaalNaik I was not sure how to predict the p,d and q value but now I know with Akaike information we can know which is the best p d and q order to be set using R

    • @rabinthapa9006
      @rabinthapa9006 3 роки тому +1

      @@KunaalNaik I am trying it for a secular trend i.e yearly, for this how shall I set the time in command?

    • @kunaal_coaching
      @kunaal_coaching 3 роки тому +1

      @@rabinthapa9006 For d (stationarity test) p(pacf plot) and p (acf plot) This is the method used to select the p,d,q. Hope this helps.

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      @@rabinthapa9006 You can skip that argument if it's yearly.

  • @sunbreezy3935
    @sunbreezy3935 3 роки тому +1

    Thank you for this. It's a really helpful tutorial. My ACF and PACF plots seem to follow the same distribution as yours. However, the scale of my lag axis is between 0 and 2. Do you know why this might be the case? I have a feeling its something to do with setting the frequency to 12 for the sales_ts variable that we did at the start.

  • @RPenahli
    @RPenahli 3 роки тому

    Thank you!

  • @somnaik1819
    @somnaik1819 3 роки тому +1

    The k value in the adf function refers to the number of lags to be used when calculating the test statistic. How do we know this is 12?

    • @paulinetan3395
      @paulinetan3395 2 роки тому +1

      12 refers to monthly data. there is 12 months in one year.

  • @ryanthompson638
    @ryanthompson638 3 роки тому +1

    what about 7 tells you it has a high significance to the model? the bar associated to 7 on the pacf looks unassuming compared to the other bars. How did you choose 7?

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      We can choose either 5,6 or 7. Went with 7 as is was the nearest and highest among the 3. We can choose others too. You want to check the MAPE. Choose the p which has the highest MAPE.

  • @kar2194
    @kar2194 3 роки тому +2

    Hi, wondering why do we need check stationary so many times? The orginal, then the diff = 1, then diff = 2?
    Feel like it is a stubborn way, once it is not stationary after testing the original, it should be regards as not stationary. We should stop but not so insist to prove that it is while it is not.
    Sorry I am new :D
    Can anyone help to explain?

    • @hilmanhilmi5789
      @hilmanhilmi5789 2 роки тому

      By applying the diff = 1 or diff = 2, it will help the series to be stationary thus making the forecast reliable

    • @paulobritto681
      @paulobritto681 2 роки тому

      Also, this tells you how far you should as far as differentiating in order to set the d parameter.

    • @paulobritto681
      @paulobritto681 2 роки тому

      plus, If I am not mistaken, there is a function (ndiff?) which retrieves the best d in order to turn your series into a stationary one.

  • @karinarelita5627
    @karinarelita5627 3 роки тому +2

    > emas_ts

  • @shakirullah5840
    @shakirullah5840 3 роки тому +1

    The link you provided for code and data download is not working. can you pls help me ?

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      Here is the link for Data - github.com/KunaalNaik/YT_R_Shiny_Dashboards/tree/master/1%20Basic%20App

  • @antonioaugustocamargo6246
    @antonioaugustocamargo6246 Рік тому

    I'm having this error:
    Error in UseMethod("forecast") : no applicable method for 'forecast' applied to an object of class "c('forecast_ARIMA', 'ARIMA', 'Arima')"
    Please, do you know how to fix this?

  • @phamvuquynhnhu2089
    @phamvuquynhnhu2089 3 роки тому +1

    Can you help me to illustrate the way to automatically select (p, d, f) quickly without having to go through each step of running ACF and PACF to choose?

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      I am afraid that won't be possible. We need to identify the parameters. You could try Auto Arima. However, it does not get it right often.

    • @phamvuquynhnhu2089
      @phamvuquynhnhu2089 3 роки тому +1

      @@KunaalNaik Thank you Sir. However, can we use this model for multiple items at the same time?

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      @@phamvuquynhnhu2089 Do one model for one item at a time. This way the model is better interpretable.

    • @phamvuquynhnhu2089
      @phamvuquynhnhu2089 3 роки тому +1

      @@KunaalNaik Thank you Sir for your support.

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      @@phamvuquynhnhu2089 Let me know how it goes or want to connect on your analysis. We could brainstorm together.

  • @nikhiljagtap6799
    @nikhiljagtap6799 4 роки тому +1

    sir my project is crime forecasting
    i use auto.arima code in r then my ARIMA model is (0,0,0)
    so i confuse the forecasting
    plz ans to me

    • @avijitghorai5535
      @avijitghorai5535 3 роки тому

      I also face the same problem. If your problem is solved then please tell me how can I do??

  • @nitigyahanda3516
    @nitigyahanda3516 2 роки тому

    For stationarity, do we not take the log of the time series values before differentiating?

  • @ainafaqihah8328
    @ainafaqihah8328 3 роки тому +1

    do you have codes on arima for electric consumption

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      I don't have the directly. However, you can follow the method shown above. If it does not work try other methods such Holt's winter or ARIMAX.

  • @avijitghorai5535
    @avijitghorai5535 3 роки тому +1

    if is it stationary then how can i get the "d" value???

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      Then d = 0 if the series is already Stationery :)

  • @juniorclick4718
    @juniorclick4718 3 роки тому +1

    Why did you use the original data rather than the differenced data to fit the arima model ?

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      In the ARIMA (p,d,q) The "d" is the difference. It automatically does the differencing :)

    • @lawanadamuismail6283
      @lawanadamuismail6283 2 роки тому +1

      Because differenced data is no longer the original data that needed to make forecast

  • @megaladevi4430
    @megaladevi4430 7 місяців тому

    Hello sir
    My arima model order (1, 0,0) with non zero mean sir
    What can i do
    It is arima model are Ar model

  • @farisabubackarshabukker8703
    @farisabubackarshabukker8703 3 роки тому +1

    Which sales data is it ,cananyone reply

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      I took this as sample. This is Sales of Milk :P

  • @new.challenges
    @new.challenges 3 роки тому +1

    what if I have more than one product and data in days ?

    • @KunaalNaik
      @KunaalNaik  3 роки тому +1

      Hi Dhanunjay, you can then build one model for each product. Also, days could used as a support to build models. However, it might be very volatile.

    • @new.challenges
      @new.challenges 3 роки тому

      @@KunaalNaik thank you

  • @avijitghorai5535
    @avijitghorai5535 3 роки тому +1

    when i use the auto arima function in my data, the adq value given "000". and when i forecast by this adq value(000) the next all years forecasting data given same. why the adq value given "000"?? and why the all future forecasting value is given same???

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      Avijit Auto Arima is not reliable in many cases. Do you want to connect and lets see the data together and figure what we can do?
      Email me at fxexcel@gmail.com

    • @avijitghorai5535
      @avijitghorai5535 3 роки тому

      @@KunaalNaik i just sent a mail in this id please check.

    • @avijitghorai5535
      @avijitghorai5535 3 роки тому +1

      @@KunaalNaik sir, please check your email, i have sent a mail to you.

    • @KunaalNaik
      @KunaalNaik  3 роки тому

      @@avijitghorai5535 Got your mail. let me check and get back to you.

    • @avijitghorai5535
      @avijitghorai5535 3 роки тому

      @@KunaalNaik ok sir.. thank you

  • @loversvtloki5835
    @loversvtloki5835 2 роки тому +1

    How about sarima sir

    • @KunaalNaik
      @KunaalNaik  2 роки тому

      ARIMA does not handle the Seasonal Component well. It is always slower than the original seasonality. SARIMA help fix that.

  •  2 роки тому

  • @avijitghorai5535
    @avijitghorai5535 3 місяці тому +2

    Sir, please send me your email id??

    • @KunaalNaik
      @KunaalNaik  3 місяці тому

      kunaal@datasciencemasterminds.com

    • @avijitghorai5535
      @avijitghorai5535 3 місяці тому

      @@KunaalNaik sir please see your email. I have sent an email to you

    • @avijitghorai5535
      @avijitghorai5535 3 місяці тому

      Sir please check my email