forecast::ets, auto.arima offset by one





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm not sure if this is intended behaviour. Consider the following snippet of code -



library(forecast)
x <- c(
0, 0, 0, 0, 0.00217764964493354, 0.00339032724317772, 0.00357374918778428,
0.00282328811130057, 0.00272679331678393, 0.0030360769697858,
0.00316665914235777, 0.00163300219677676, 0.00249817841157489,
0.00207838479809976, 0.00192104504850639, 0.00209700948212983,
0.00216356555603635, 0.00250983016815862, 0.0017474879860201
)
tsData <- ts(data = x, start = 2000, frequency = 1)
df <- data.frame(
x = x,
fittedets = fitted(forecast(ets(tsData), h = 7)),
fittedarima = fitted(forecast(auto.arima(tsData), h = 7))
)
df

x fittedets fittedarima
1 0.000000000 -6.997521e-07 0.000000000
2 0.000000000 -7.065016e-11 0.000000000
3 0.000000000 -7.133162e-15 0.000000000
4 0.000000000 -7.201966e-19 0.000000000
5 0.002177650 0.000000e+00 0.000000000
6 0.003390327 2.177430e-03 0.002007587
7 0.003573749 3.390205e-03 0.003125561
8 0.002823288 3.573731e-03 0.003294659
9 0.002726793 2.823364e-03 0.002602805
10 0.003036077 2.726803e-03 0.002513846
11 0.003166659 3.036046e-03 0.002798976
12 0.001633002 3.166646e-03 0.002919360
13 0.002498178 1.633157e-03 0.001505474
14 0.002078385 2.498091e-03 0.002303084
15 0.001921045 2.078427e-03 0.001916074
16 0.002097009 1.921061e-03 0.001771022
17 0.002163566 2.096992e-03 0.001933245
18 0.002509830 2.163559e-03 0.001994603
19 0.001747488 2.509795e-03 0.002313826


The actual values are 0 until the fifth value, while in case of both models, the fitted values are about 0 until the sixth value.



I would assume them to be approximately 0 for the first five values, like the x column. Am I missing something basic?










share|improve this question


















  • 1





    The forecast is made on the known information up to that point, meaning that the prediction for the fifth value are made using the first four observations (well, depending on the chosen model ofc). Since the historical data is 0 until then, there will be no trend. If there is also no intercept, the prediction is 0 as well.

    – CIAndrews
    Nov 22 '18 at 2:17











  • Makes sense, thanks!

    – Ameya
    Nov 22 '18 at 2:25











  • have a look at this post this will help - stackoverflow.com/questions/35448610/…

    – Hunaidkhan
    Nov 22 '18 at 4:37


















0















I'm not sure if this is intended behaviour. Consider the following snippet of code -



library(forecast)
x <- c(
0, 0, 0, 0, 0.00217764964493354, 0.00339032724317772, 0.00357374918778428,
0.00282328811130057, 0.00272679331678393, 0.0030360769697858,
0.00316665914235777, 0.00163300219677676, 0.00249817841157489,
0.00207838479809976, 0.00192104504850639, 0.00209700948212983,
0.00216356555603635, 0.00250983016815862, 0.0017474879860201
)
tsData <- ts(data = x, start = 2000, frequency = 1)
df <- data.frame(
x = x,
fittedets = fitted(forecast(ets(tsData), h = 7)),
fittedarima = fitted(forecast(auto.arima(tsData), h = 7))
)
df

x fittedets fittedarima
1 0.000000000 -6.997521e-07 0.000000000
2 0.000000000 -7.065016e-11 0.000000000
3 0.000000000 -7.133162e-15 0.000000000
4 0.000000000 -7.201966e-19 0.000000000
5 0.002177650 0.000000e+00 0.000000000
6 0.003390327 2.177430e-03 0.002007587
7 0.003573749 3.390205e-03 0.003125561
8 0.002823288 3.573731e-03 0.003294659
9 0.002726793 2.823364e-03 0.002602805
10 0.003036077 2.726803e-03 0.002513846
11 0.003166659 3.036046e-03 0.002798976
12 0.001633002 3.166646e-03 0.002919360
13 0.002498178 1.633157e-03 0.001505474
14 0.002078385 2.498091e-03 0.002303084
15 0.001921045 2.078427e-03 0.001916074
16 0.002097009 1.921061e-03 0.001771022
17 0.002163566 2.096992e-03 0.001933245
18 0.002509830 2.163559e-03 0.001994603
19 0.001747488 2.509795e-03 0.002313826


The actual values are 0 until the fifth value, while in case of both models, the fitted values are about 0 until the sixth value.



I would assume them to be approximately 0 for the first five values, like the x column. Am I missing something basic?










share|improve this question


















  • 1





    The forecast is made on the known information up to that point, meaning that the prediction for the fifth value are made using the first four observations (well, depending on the chosen model ofc). Since the historical data is 0 until then, there will be no trend. If there is also no intercept, the prediction is 0 as well.

    – CIAndrews
    Nov 22 '18 at 2:17











  • Makes sense, thanks!

    – Ameya
    Nov 22 '18 at 2:25











  • have a look at this post this will help - stackoverflow.com/questions/35448610/…

    – Hunaidkhan
    Nov 22 '18 at 4:37














0












0








0








I'm not sure if this is intended behaviour. Consider the following snippet of code -



library(forecast)
x <- c(
0, 0, 0, 0, 0.00217764964493354, 0.00339032724317772, 0.00357374918778428,
0.00282328811130057, 0.00272679331678393, 0.0030360769697858,
0.00316665914235777, 0.00163300219677676, 0.00249817841157489,
0.00207838479809976, 0.00192104504850639, 0.00209700948212983,
0.00216356555603635, 0.00250983016815862, 0.0017474879860201
)
tsData <- ts(data = x, start = 2000, frequency = 1)
df <- data.frame(
x = x,
fittedets = fitted(forecast(ets(tsData), h = 7)),
fittedarima = fitted(forecast(auto.arima(tsData), h = 7))
)
df

x fittedets fittedarima
1 0.000000000 -6.997521e-07 0.000000000
2 0.000000000 -7.065016e-11 0.000000000
3 0.000000000 -7.133162e-15 0.000000000
4 0.000000000 -7.201966e-19 0.000000000
5 0.002177650 0.000000e+00 0.000000000
6 0.003390327 2.177430e-03 0.002007587
7 0.003573749 3.390205e-03 0.003125561
8 0.002823288 3.573731e-03 0.003294659
9 0.002726793 2.823364e-03 0.002602805
10 0.003036077 2.726803e-03 0.002513846
11 0.003166659 3.036046e-03 0.002798976
12 0.001633002 3.166646e-03 0.002919360
13 0.002498178 1.633157e-03 0.001505474
14 0.002078385 2.498091e-03 0.002303084
15 0.001921045 2.078427e-03 0.001916074
16 0.002097009 1.921061e-03 0.001771022
17 0.002163566 2.096992e-03 0.001933245
18 0.002509830 2.163559e-03 0.001994603
19 0.001747488 2.509795e-03 0.002313826


The actual values are 0 until the fifth value, while in case of both models, the fitted values are about 0 until the sixth value.



I would assume them to be approximately 0 for the first five values, like the x column. Am I missing something basic?










share|improve this question














I'm not sure if this is intended behaviour. Consider the following snippet of code -



library(forecast)
x <- c(
0, 0, 0, 0, 0.00217764964493354, 0.00339032724317772, 0.00357374918778428,
0.00282328811130057, 0.00272679331678393, 0.0030360769697858,
0.00316665914235777, 0.00163300219677676, 0.00249817841157489,
0.00207838479809976, 0.00192104504850639, 0.00209700948212983,
0.00216356555603635, 0.00250983016815862, 0.0017474879860201
)
tsData <- ts(data = x, start = 2000, frequency = 1)
df <- data.frame(
x = x,
fittedets = fitted(forecast(ets(tsData), h = 7)),
fittedarima = fitted(forecast(auto.arima(tsData), h = 7))
)
df

x fittedets fittedarima
1 0.000000000 -6.997521e-07 0.000000000
2 0.000000000 -7.065016e-11 0.000000000
3 0.000000000 -7.133162e-15 0.000000000
4 0.000000000 -7.201966e-19 0.000000000
5 0.002177650 0.000000e+00 0.000000000
6 0.003390327 2.177430e-03 0.002007587
7 0.003573749 3.390205e-03 0.003125561
8 0.002823288 3.573731e-03 0.003294659
9 0.002726793 2.823364e-03 0.002602805
10 0.003036077 2.726803e-03 0.002513846
11 0.003166659 3.036046e-03 0.002798976
12 0.001633002 3.166646e-03 0.002919360
13 0.002498178 1.633157e-03 0.001505474
14 0.002078385 2.498091e-03 0.002303084
15 0.001921045 2.078427e-03 0.001916074
16 0.002097009 1.921061e-03 0.001771022
17 0.002163566 2.096992e-03 0.001933245
18 0.002509830 2.163559e-03 0.001994603
19 0.001747488 2.509795e-03 0.002313826


The actual values are 0 until the fifth value, while in case of both models, the fitted values are about 0 until the sixth value.



I would assume them to be approximately 0 for the first five values, like the x column. Am I missing something basic?







r forecasting forecast






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 1:48









AmeyaAmeya

1,0711920




1,0711920








  • 1





    The forecast is made on the known information up to that point, meaning that the prediction for the fifth value are made using the first four observations (well, depending on the chosen model ofc). Since the historical data is 0 until then, there will be no trend. If there is also no intercept, the prediction is 0 as well.

    – CIAndrews
    Nov 22 '18 at 2:17











  • Makes sense, thanks!

    – Ameya
    Nov 22 '18 at 2:25











  • have a look at this post this will help - stackoverflow.com/questions/35448610/…

    – Hunaidkhan
    Nov 22 '18 at 4:37














  • 1





    The forecast is made on the known information up to that point, meaning that the prediction for the fifth value are made using the first four observations (well, depending on the chosen model ofc). Since the historical data is 0 until then, there will be no trend. If there is also no intercept, the prediction is 0 as well.

    – CIAndrews
    Nov 22 '18 at 2:17











  • Makes sense, thanks!

    – Ameya
    Nov 22 '18 at 2:25











  • have a look at this post this will help - stackoverflow.com/questions/35448610/…

    – Hunaidkhan
    Nov 22 '18 at 4:37








1




1





The forecast is made on the known information up to that point, meaning that the prediction for the fifth value are made using the first four observations (well, depending on the chosen model ofc). Since the historical data is 0 until then, there will be no trend. If there is also no intercept, the prediction is 0 as well.

– CIAndrews
Nov 22 '18 at 2:17





The forecast is made on the known information up to that point, meaning that the prediction for the fifth value are made using the first four observations (well, depending on the chosen model ofc). Since the historical data is 0 until then, there will be no trend. If there is also no intercept, the prediction is 0 as well.

– CIAndrews
Nov 22 '18 at 2:17













Makes sense, thanks!

– Ameya
Nov 22 '18 at 2:25





Makes sense, thanks!

– Ameya
Nov 22 '18 at 2:25













have a look at this post this will help - stackoverflow.com/questions/35448610/…

– Hunaidkhan
Nov 22 '18 at 4:37





have a look at this post this will help - stackoverflow.com/questions/35448610/…

– Hunaidkhan
Nov 22 '18 at 4:37












1 Answer
1






active

oldest

votes


















0














It also has to do with the ARIMA model that auto.arima is fitting to your data. If you look at the model that it's being fitted:



Series: tsData 
ARIMA(1,0,0) with zero mean

Coefficients:
ar1
0.9219
s.e. 0.0638

sigma^2 estimated as 6.076e-07: log likelihood=108.59
AIC=-213.17 AICc=-212.42 BIC=-211.28


Remember that ARIMA stands for Autoregressive Integrated Moving Average, and the output tells us that only the AR part of the model was fitted, which makes it an AR(1) model:



y[t] = c + p1 * y[t-1]



With this equation you can get a sense of what happened here:



             x     fittedets fittedarima
1 0.000000000 -6.997521e-07 0.000000000
2 0.000000000 -7.065016e-11 0.000000000 # .9219 * 0 = 0
3 0.000000000 -7.133162e-15 0.000000000 # .9219 * 0 = 0
4 0.000000000 -7.201966e-19 0.000000000 # .9219 * 0 = 0
5 0.002177650 0.000000e+00 0.000000000 # .9219 * 0 = 0
6 0.003390327 2.177430e-03 0.002007587 # .9219 * .00217 = .002007
7 0.003573749 3.390205e-03 0.003125561 # .9219 * .00339 = .003125


You can also observe this behavior with a plot:



library(ggplot2)
fcast <- forecast(auto.arima(tsData), h = 7)

autoplot(fcast) +
autolayer(fitted(fcast))


enter image description here



For the ets model a similar thing happens, but I hope this made it clear why auto.arima had such result. Next time you could explore more forecasting models that are included in the forecast package.



Hope this helped!






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422824%2fforecastets-auto-arima-offset-by-one%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It also has to do with the ARIMA model that auto.arima is fitting to your data. If you look at the model that it's being fitted:



    Series: tsData 
    ARIMA(1,0,0) with zero mean

    Coefficients:
    ar1
    0.9219
    s.e. 0.0638

    sigma^2 estimated as 6.076e-07: log likelihood=108.59
    AIC=-213.17 AICc=-212.42 BIC=-211.28


    Remember that ARIMA stands for Autoregressive Integrated Moving Average, and the output tells us that only the AR part of the model was fitted, which makes it an AR(1) model:



    y[t] = c + p1 * y[t-1]



    With this equation you can get a sense of what happened here:



                 x     fittedets fittedarima
    1 0.000000000 -6.997521e-07 0.000000000
    2 0.000000000 -7.065016e-11 0.000000000 # .9219 * 0 = 0
    3 0.000000000 -7.133162e-15 0.000000000 # .9219 * 0 = 0
    4 0.000000000 -7.201966e-19 0.000000000 # .9219 * 0 = 0
    5 0.002177650 0.000000e+00 0.000000000 # .9219 * 0 = 0
    6 0.003390327 2.177430e-03 0.002007587 # .9219 * .00217 = .002007
    7 0.003573749 3.390205e-03 0.003125561 # .9219 * .00339 = .003125


    You can also observe this behavior with a plot:



    library(ggplot2)
    fcast <- forecast(auto.arima(tsData), h = 7)

    autoplot(fcast) +
    autolayer(fitted(fcast))


    enter image description here



    For the ets model a similar thing happens, but I hope this made it clear why auto.arima had such result. Next time you could explore more forecasting models that are included in the forecast package.



    Hope this helped!






    share|improve this answer




























      0














      It also has to do with the ARIMA model that auto.arima is fitting to your data. If you look at the model that it's being fitted:



      Series: tsData 
      ARIMA(1,0,0) with zero mean

      Coefficients:
      ar1
      0.9219
      s.e. 0.0638

      sigma^2 estimated as 6.076e-07: log likelihood=108.59
      AIC=-213.17 AICc=-212.42 BIC=-211.28


      Remember that ARIMA stands for Autoregressive Integrated Moving Average, and the output tells us that only the AR part of the model was fitted, which makes it an AR(1) model:



      y[t] = c + p1 * y[t-1]



      With this equation you can get a sense of what happened here:



                   x     fittedets fittedarima
      1 0.000000000 -6.997521e-07 0.000000000
      2 0.000000000 -7.065016e-11 0.000000000 # .9219 * 0 = 0
      3 0.000000000 -7.133162e-15 0.000000000 # .9219 * 0 = 0
      4 0.000000000 -7.201966e-19 0.000000000 # .9219 * 0 = 0
      5 0.002177650 0.000000e+00 0.000000000 # .9219 * 0 = 0
      6 0.003390327 2.177430e-03 0.002007587 # .9219 * .00217 = .002007
      7 0.003573749 3.390205e-03 0.003125561 # .9219 * .00339 = .003125


      You can also observe this behavior with a plot:



      library(ggplot2)
      fcast <- forecast(auto.arima(tsData), h = 7)

      autoplot(fcast) +
      autolayer(fitted(fcast))


      enter image description here



      For the ets model a similar thing happens, but I hope this made it clear why auto.arima had such result. Next time you could explore more forecasting models that are included in the forecast package.



      Hope this helped!






      share|improve this answer


























        0












        0








        0







        It also has to do with the ARIMA model that auto.arima is fitting to your data. If you look at the model that it's being fitted:



        Series: tsData 
        ARIMA(1,0,0) with zero mean

        Coefficients:
        ar1
        0.9219
        s.e. 0.0638

        sigma^2 estimated as 6.076e-07: log likelihood=108.59
        AIC=-213.17 AICc=-212.42 BIC=-211.28


        Remember that ARIMA stands for Autoregressive Integrated Moving Average, and the output tells us that only the AR part of the model was fitted, which makes it an AR(1) model:



        y[t] = c + p1 * y[t-1]



        With this equation you can get a sense of what happened here:



                     x     fittedets fittedarima
        1 0.000000000 -6.997521e-07 0.000000000
        2 0.000000000 -7.065016e-11 0.000000000 # .9219 * 0 = 0
        3 0.000000000 -7.133162e-15 0.000000000 # .9219 * 0 = 0
        4 0.000000000 -7.201966e-19 0.000000000 # .9219 * 0 = 0
        5 0.002177650 0.000000e+00 0.000000000 # .9219 * 0 = 0
        6 0.003390327 2.177430e-03 0.002007587 # .9219 * .00217 = .002007
        7 0.003573749 3.390205e-03 0.003125561 # .9219 * .00339 = .003125


        You can also observe this behavior with a plot:



        library(ggplot2)
        fcast <- forecast(auto.arima(tsData), h = 7)

        autoplot(fcast) +
        autolayer(fitted(fcast))


        enter image description here



        For the ets model a similar thing happens, but I hope this made it clear why auto.arima had such result. Next time you could explore more forecasting models that are included in the forecast package.



        Hope this helped!






        share|improve this answer













        It also has to do with the ARIMA model that auto.arima is fitting to your data. If you look at the model that it's being fitted:



        Series: tsData 
        ARIMA(1,0,0) with zero mean

        Coefficients:
        ar1
        0.9219
        s.e. 0.0638

        sigma^2 estimated as 6.076e-07: log likelihood=108.59
        AIC=-213.17 AICc=-212.42 BIC=-211.28


        Remember that ARIMA stands for Autoregressive Integrated Moving Average, and the output tells us that only the AR part of the model was fitted, which makes it an AR(1) model:



        y[t] = c + p1 * y[t-1]



        With this equation you can get a sense of what happened here:



                     x     fittedets fittedarima
        1 0.000000000 -6.997521e-07 0.000000000
        2 0.000000000 -7.065016e-11 0.000000000 # .9219 * 0 = 0
        3 0.000000000 -7.133162e-15 0.000000000 # .9219 * 0 = 0
        4 0.000000000 -7.201966e-19 0.000000000 # .9219 * 0 = 0
        5 0.002177650 0.000000e+00 0.000000000 # .9219 * 0 = 0
        6 0.003390327 2.177430e-03 0.002007587 # .9219 * .00217 = .002007
        7 0.003573749 3.390205e-03 0.003125561 # .9219 * .00339 = .003125


        You can also observe this behavior with a plot:



        library(ggplot2)
        fcast <- forecast(auto.arima(tsData), h = 7)

        autoplot(fcast) +
        autolayer(fitted(fcast))


        enter image description here



        For the ets model a similar thing happens, but I hope this made it clear why auto.arima had such result. Next time you could explore more forecasting models that are included in the forecast package.



        Hope this helped!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 5:23









        Kean HerreraKean Herrera

        112




        112
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422824%2fforecastets-auto-arima-offset-by-one%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)