[R] Time-series moving average question

MacQueen, Don m@cqueen1 @end|ng |rom ||n|@gov
Fri Jun 1 17:23:40 CEST 2018


My guess would be that if you inspect the output from
    ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I assume they come from some package you installed; it would be helpful to say which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 6/1/18, 4:20 AM, "R-help on behalf of Bill Poling" <r-help-bounces using r-project.org on behalf of Bill.Poling using zelis.com> wrote:

    Good morning, I hope someone can help with these questions, or perhaps suggest one of the other R-lists?
    
    I have two questions:
    
    
      1.  Why am I getting this warning?
      2.  Why is the second example "Point Forecast" the same value, I do not see that in previous attempts with similar but different data sets as in example 1?
    
    Example1:
    dat3 <- structure(c(3539122.86, 3081383.87, 4158672.31, 4137518.78, 4123682.08, 4819375.2, 4342687.77, 5028674.58, 4472145.07, 4967277.73, 4516240.31, 4876194.63, 4816446.59,
                        4887399.37, 5478504.85, 4871385.27, 5487543.68, 5464193.69, 5252591.03, 7071416.89, 5524350.89, 6107166.69, 6530003.55, 6445929.08, 7356743.81, 6750025.03,
                        6934714.08, 6656194.35
    
                        ,-13913, -29385.31, -39633.37, -23487.13, -18202.86, -57335.49, -26061.45, -60880.07, -17589.45, -35970.08, -89133.94,
                        -84694.58, -31724.89, -29847.95, -65421.74, -34334.22, -48511.98, -30298.97, -38729.46, -29292.89, -46098.4, -65909.49,
                        -85879.23, -71845.28, -69017.07, -93161.03, -70847.29, -85106.04
    
                        ,-357694.19, -444792.75, -361349.57, -386717.55, -547422.05, -518259.22, -417613.76, -578631.46, -804516.81, -572875.52, -510487.53,
                        -666294.87, -673233.37, -556564.45, -963346.75, -639288.2, -910104.23, -773428.8, -1008078.84, -546685.3, -729932.94, -987098.23,
                        -964001.63, -986995.93, -680066.58, -728854.58, -730766.92, -753861.59)
                        ,.Dim = c(28L, 3L)
                        ,.Dimnames = list(NULL, c("OONNetRev","OONAdjusted" ,"OONCancelled"))
                        ,.Tsp = c(2016, 2018.25, 12), class = c("mts", "ts", "matrix"))
    head(dat3); nrow(dat3)
    
    TNR_moving_average <- forecast(ma(dat3[1:28], order=3), h=8)
    TNR_moving_average
    
    # Warning message:
    #   In ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend,  :
    #            Missing values encountered. Using longest contiguous portion of time series
    #          > Point Forecast         Lo 80         Hi 80         Lo 95         Hi 95
    #         28  7007065.99688 6675015.72012 7339116.27365 6499238.92148 7514893.07229
    #         29  7135745.42473 6721543.41996 7549947.42950 6502278.12345 7769212.72601
    #         30  7264424.85258 6779532.18065 7749317.52450 6522845.50541 8006004.19974
    #         31  7393104.28042 6844496.10189 7941712.45896 6554080.47486 8232128.08599
    #         32  7521783.70827 6914203.11991 8129364.29663 6592569.38486 8450998.03168
    #         33  7650463.13612 6987355.72657 8313570.54567 6636327.86794 8664598.40429
    #         34  7779142.56396 7063123.29787 8495161.83005 6684085.59434 8874199.53358
    #         35  7907821.99181 7140937.69145 8674706.29217 6734973.66528 9080670.31834
    
    
    
    
    Example2:
    dat3 <- structure(c(994320.58, 811664.54, 1045259.43, 951659.48, 669458.94, 986741.09, 1023344.82, 938971.65, 897670.06, 1040074.6, 1090310.01,
                        1289821.17, 1187806.23, 971485.76, 1161147.42, 870585.04, 1021301.52, 1215798.03, 1015004.43, 1365863.09, 995769.41,
                        1331725.36, 1271032.91, 1092103.82, 1297131.4, 1129195.28, 1372594.58, 1553717.57,
    
                        -39811.51, -47356.74, -49046.86, -41311.13, -79063.98, -43916.59, -16746.33, -38347.9, -84797.44, -38961.44,
                        -72036.83, -62854.78, -35259.84, -44198.39, -34262.65, -49245.82, -34977.28, -36797.35, -47534.43, -33515.13,
                        -25764.41, -29130.53, -57693.63, -51026.83, -49624.49, -36508.13, -32667.21, -37900.5,
    
                        -247443.87, -372942.34, -344080.78, -355586.21, -458998.84, -378086.44, -333994.18, -567024.45, -521499.8, -428915.13,
                        -512034.28, -440865.42, -347494.22, -422436.19, -444588.65, -462891.57, -518395.47, -373818.5, -398899.53, -381573.69,
                        -531449.2, -476238.48, -434296.86, -655679.94, -528999.52, -423725.95, -556977.31, -518633.95)
                      ,.Dim = c(28L, 3L)
                      ,.Dimnames = list(NULL, c("EditNetRev","EditNetAdjusted" ,"EditNetCancelled"))
                      ,.Tsp = c(2016, 2018.25, 12), class = c("mts", "ts", "matrix"))
    head(dat3); nrow(dat3)
    
    
    
    TNR_moving_average <- forecast(ma(dat3[1:28], order=3), h=8)
    TNR_moving_average
    
    # Warning message:
    # In ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend,  :
    #          Missing values encountered. Using longest contiguous portion of time series
    #        > TNR_moving_average
    #        Point Forecast         Lo 80         Hi 80          Lo 95         Hi 95
    #        28  1351827.24389 1246570.02118 1457084.46661 1190850.213255 1512804.27453
    #        29  1351827.24389 1202841.21791 1500813.26987 1123972.779844 1579681.70794
    #        30  1351827.24389 1169192.03201 1534462.45578 1072510.790913 1631143.69687
    #        31  1351827.24389 1140745.29674 1562909.19105 1029005.263624 1674649.22416
    #        32  1351827.24389 1115613.58783 1588040.89996  990569.631639 1713084.85615
    #        33  1351827.24389 1092829.78856 1610824.69923  955724.817592 1747929.67020
    #        34  1351827.24389 1071819.89899 1631834.58880  923592.964312 1780061.52348
    #        35  1351827.24389 1052210.25675 1651444.23104  893602.604521 1810051.88327
    
    Thank you for any advice or direction.
    
    
    WHP
    
    
    
    Confidentiality Notice This message is sent from Zelis. ...{{dropped:15}}
    
    ______________________________________________
    R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
    



More information about the R-help mailing list