我使用forecast.HoltWinters
函数从数据框中绘制。但是,图中的下限是负数。如何将下限排列为零?下面的代码不起作用。谢谢。
library(forecast)
casesseriesforecasts2 <- forecast.HoltWinters(casesseriesforecasts, h=8,lower=0)
plot.forecast(casesseriesforecasts2)
数据
structure(list(method = "HoltWinters", model = structure(list(
fitted = structure(c(16352, 1558.78360573168, 240.89056661416,
123.482559033918, 113.022954320328, 112.091132607147, 112.008118790762,
112.000723284075, 112.000064435686, 112.000005740425, 19.0869418774497,
103.722593026472, 30.1913869583035, 128.395582887599, 113.460644121194,
26.5043654499464, 104.383393939123, 3228.46348032057, 326.785488915318,
131.134736706388, 14.4152239157357, 108.771874640265, 111.712413864057,
166.629119996883, 3835.21095053019, 443.692152949984, 47.7257069229214,
6.07359625225211, 148.108881487504, 115.216855773241, 112.286582154848,
114.758267952348, 112.245727638773, 112.021891300447, 118.378336621581,
112.568231087188, 112.050622378153, 166.659250202149, 116.86946472254,
33.1844356790589, 104.978505767486, 111.374471505952, 19.9421268355168,
5.4202467823966, 416.769816278597, 88.1401388937625, 109.874380795349,
144.603477781794, 419.149288967374, 64.6683997204517, 107.783338465671,
111.624347488991, 111.966533996651, 111.997018592057, 111.999734393342,
111.999976337724, 111.999997891983, 541.039711739565, 150.222144159646,
177.347160489922, 191.605525148625, 119.091869994501, 80.749866221837,
109.215998692908, 26.1262199192945, 15.9912089022784, 103.446801418331,
111.238015548982, 16352, 1558.78360573168, 240.89056661416,
123.482559033918, 113.022954320328, 112.091132607147, 112.008118790762,
112.000723284075, 112.000064435686, 112.000005740425, 19.0869418774497,
103.722593026472, 30.1913869583035, 128.395582887599, 113.460644121194,
26.5043654499464, 104.383393939123, 3228.46348032057, 326.785488915318,
131.134736706388, 14.4152239157357, 108.771874640265, 111.712413864057,
166.629119996883, 3835.21095053019, 443.692152949984, 47.7257069229214,
6.07359625225211, 148.108881487504, 115.216855773241, 112.286582154848,
114.758267952348, 112.245727638773, 112.021891300447, 118.378336621581,
112.568231087188, 112.050622378153, 166.659250202149, 116.86946472254,
33.1844356790589, 104.978505767486, 111.374471505952, 19.9421268355168,
5.4202467823966, 416.769816278597, 88.1401388937625, 109.874380795349,
144.603477781794, 419.149288967374, 64.6683997204517, 107.783338465671,
111.624347488991, 111.966533996651, 111.997018592057, 111.999734393342,
111.999976337724, 111.999997891983, 541.039711739565, 150.222144159646,
177.347160489922, 191.605525148625, 119.091869994501, 80.749866221837,
109.215998692908, 26.1262199192945, 15.9912089022784, 103.446801418331,
111.238015548982), .Dim = c(68L, 2L), .Dimnames = list(NULL,
c("xhat", "level")), .Tsp = c(2008.08333333333, 2013.66666666667,
12), class = c("mts", "ts", "matrix")), x = structure(c(16352L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 10L,
112L, 23L, 138L, 112L, 18L, 112L, 3534L, 43L, 112L, 3L, 118L,
112L, 172L, 4194L, 112L, 9L, 2L, 162L, 112L, 112L, 115L,
112L, 112L, 119L, 112L, 112L, 172L, 112L, 25L, 112L, 112L,
11L, 4L, 457L, 56L, 112L, 148L, 446L, 30L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 583L, 112L, 180L, 193L, 112L, 77L,
112L, 18L, 15L, 112L, 112L, 1L), .Tsp = c(2008, 2013.66666666667,
12), class = "ts"), alpha = 0.910912339548542, beta = FALSE,
gamma = FALSE, coefficients = structure(10.8208468980703, .Names = "a"),
seasonal = "additive", SSE = 319244834.790406, call = HoltWinters(x = casestimeseries,
beta = FALSE, gamma = FALSE)), .Names = c("fitted", "x",
“alpha”,“beta”,“gamma”,“系数”,“季节性”,“SSE”, “call”),class =“HoltWinters”),level = c(80,95),mean = structure(c(10.8208468980703, 10.8208468980703,10.8208468980703,10.8208468980703,108.208468980703, 10.8208468980703,10.8208468980703,10.8208468980703),. Tsp = c(2013.75, 2014.33333333333,12),class =“ts”),lower = structure(c(-2765.80536739846, -3745.08448556263,-4517.31305117681,-5175.81277534505,-5759.65054319398, -6289.61658207136,-6778.33841834582,-7234.16743889888,-4235.66249787343, -5733.34066706851,-6914.36234198927,-7921.45076347691,-8814.35357641357, -9624.86668970184,-10372.3022383832,-11069.4325665042),. Dim = c(8L, 2L),.。Dimnames = list(NULL,c(“80%”,“95%”))),upper = structure(c(2787.4470611946, 3766.72617935877,4538.95474497295,5197.45446914119,5781.29223699012, 6311.2582758675,6799.98011214196,7255.80913269502,4257.30419166957, 5754.98236086465,6936.00403578541,7943.09245727305,8835.99527020971, 9646.50838349799,10393.9439321793,11091.0742603004),. Dim = c(8L, 2L),. Dimnames = list(NULL,c(“80%”,“95%”))),x =结构(c(16352L, 112L,112L,112L,112L,112L,112L,112L,112L,112L,10L,112L, 23L,138L,112L,18L,112L,3534L,43L,112L,3L,118L,112L, 172L,4194L,112L,9L,2L,162L,112L,112L,115L,112L,112L, 119L,112L,112L,172L,112L,25L,112L,112L,11L,4L,457L, 56L,112L,148L,446L,30L,112L,112L,112L,112L,112L,112L, 112L,583L,112L,180L,193L,112L,77L,112L,18L,15L,112L, 112L,1L),. Tsp = c(2008,2013.66666666667,12),class =“ts”), xname =“x”,拟合=结构(c(16352,1558.78360573168, 240.89056661416,123.482559033918,113.022954320328,112.091132607147, 112.008118790762,112.000723284075,112.000064435686,112.000005740425, 19.0869418774497,103.722593026472,30.1913869583035,128.395582887599, 113.460644121194,26.5043654499464,104.383393939123,3228.46348032057, 326.785488915318,131.134736706388,14.4152239157357,108.771874640265, 111.712413864057,166.629119996883,3835.21095053019,443.692152949984, 47.7257069229214,6.07379625225211,148.108881487504,115.216855773241, 112.286582154848,114.758267952348,112.245727638773,112.021891300447, 118.378336621581,112.568231087188,112.050622378153,166.659250202149, 116.86946472254,33.1844356790589,104.978505767486,111.374471505952, 19.9421268355168,5.4202467823966,416.769816278597,88.1401388937625, 109.874380795349,144.603477781794,419.149288967374,64.6683997204517, 107.783338465671,111.624347488991,111.966533996651,111.997018592057, 111.999734393342,111.999976337724,111.999997891983,541.039711739565, 150.222144159646,177.347160489922,191.605525148625,119.091869994501, 80.749866221837,109.215998692908,26.1262199192945,159912089022784, 103.446801418331,111.238015548982),. Tsp = c(2008.08333333333, 2013.66666666667,12),class =“ts”),residuals = structure(c(-16240, -1446.78360573168,-128.89056661416,-11.4825590339183,-1.02295432032754, -0.0911326071466902,-0.00811879076154298,-0.000723284074638286, -6.44356860561857e-05,-102.000005740425,92.9130581225503, -80.7225930264717,107.808613041696,-16.3955828875987,-95.4606441211941, 85.4956345500536,3429.61660606088,-3185.46348032057,-214.785488915318, -128.134736706388,103.584776084264,3.22812535973524,60.2875861359428, 4027.37088000312,-3723.21095053019,-434.692152949984,-45.7257069229214, 155.926403747748,-36.1088814875037,-3.21685577324067,2.71341784515222, -2.75826795234815,-0.245727638772934,6.97810869955346, -6.37833662158081,-0.568231087188494,59.9493776218466, -54.6592502021487,-91.8694647225403,78.8155643209411,7.02149423251404, -100.374471505952,-15.9421268355168,451.579753217603,-360.769816278597, 23.8598611062375,38.1256192046514,301.396522218206,389.149288967374, 47.3316002795483,4.21666153432852,0.37565251100898,0.0334660033485079, 0.00298140794298263,0.000265606658487627,2.63622758080784e-05, 471.000002108017,-429.039711739565,29.7778558403542,15.6528395100779, -79.605525148625,-42.0918699945007,31.250133778163,-91.2159986929084, -11.1262199192945,96.0087910977216,8.55319858166878,-110.238015548982 ),.。tsp = c(2008.08333333333,2013.66666666667,12),class =“ts”)),。Name = c(“method”, “model”,“level”,“mean”,“lower”,“upper”,“x”,“xname”,“fit”, “residuals”),class =“forecast”)