未找到预测包中的 R forecast.holtwinters

R forecast.holtwinters in forecast package not found

我正在尝试使用 forecast.holtwinters 函数,当我尝试 运行 它时:

dftimeseriesforecast <- forecast.HoltWinters(data, h=65)

我收到这个错误:

Error: could not find function "forecast.HoltWinters"

我也试过这个:

 dftimeseriesforecast= forecast::forecast.HoltWinters(data, h=65)

但我收到此错误消息:

Error: 'forecast.HoltWinters' is not an exported object from 'namespace:forecast'

我使用以下代码查看预测包中的函数列表:

ls("package:forecast")

和这个 returns:

[1] "%>%" "accuracy" "Acf" "arfima" "Arima" "arima.errors" "arimaorder" "auto.arima"
[9] "autolayer" "baggedETS" "bats" "bizdays" "bld.mbb.bootstrap" "BoxCox" "BoxCox.lambda" "Ccf"
[17] "checkresiduals" "croston" "CV" "CVar" "dm.test" "dshw" "easter" "ets"
[25] "findfrequency" "forecast" "forecast.ets" "fourier" "fourierf" "gas" "geom_forecast" "GeomForecast"
[33] "getResponse" "ggAcf" "ggCcf" "gghistogram" "gglagchull" "gglagplot" "ggmonthplot" "ggPacf"
[41] "ggseasonplot" "ggsubseriesplot" "ggtaperedacf" "ggtaperedpacf" "ggtsdisplay" "gold" "holt" "hw"
[49] "InvBoxCox" "is.acf" "is.Arima" "is.baggedETS" "is.bats" "is.constant" "is.ets" "is.forecast"
[57] "is.mforecast" "is.nnetar" "is.nnetarmodels" "is.splineforecast" "is.stlm" "ma" "meanf" "monthdays"
[65] "msts" "na.interp" "naive" "ndiffs" "nnetar" "nsdiffs" "Pacf" "remainder"
[73] "rwf" "seasadj" "seasonal" "seasonaldummy" "seasonaldummyf" "seasonplot" "ses" "sindexf"
[81] "snaive" "splinef" "StatForecast" "stlf" "stlm" "taperedacf" "taperedpacf" "taylor"
[89] "tbats" "tbats.components" "thetaf" "trendcycle" "tsclean" "tsCV" "tsdisplay" "tslm"
[97] "tsoutliers" "wineind" "woolyrnq"

有人知道这是怎么回事吗?我以前用过这个,没有问题。我正在使用预测版本 8.1。

None 这些东西在 forecast 包里。他们在 stats:

> m <- stats::HoltWinters(co2)
> class(m)
[1] "HoltWinters"
> p = predict(m)
> pp = stats:::predict.HoltWinters(m)
> p
          Jan
1998 365.1079
> pp
          Jan
1998 365.1079

predict.HoltWintersstats 中未导出的函数,只能在 HoltWinters().

中的对象上调用

forecast.HoltWintersforecast 的未导出函数,这意味着您需要 三个 冒号才能访问它。但是你应该 永远不必 这样做,因为当你 运行 forecastHoltWinters():[=22 的输出上时,它应该会自动找到=]

> m <- stats::HoltWinters(co2)
> forecast(m)
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Jan 1998       365.1079 364.7139 365.5019 364.5053 365.7105
Feb 1998       365.9664 365.5228 366.4100 365.2879 366.6449
[etc]

同于:

> forecast:::forecast.HoltWinters(m)
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Jan 1998       365.1079 364.7139 365.5019 364.5053 365.7105
Feb 1998       365.9664 365.5228 366.4100 365.2879 366.6449
[etc]

当我使用 R v3.4.4 和 forecast v8.2 时,这对我有用:

hw <- stats::HoltWinters(data) forecast_data <- forecast(hw, h=65)

这样使用:

forecast:::forecast.HoltWinters().

它会起作用。

使用:

forecast_data <-forecast(mydata #data name,h=56)

在更新您的 r 版本后它会工作

你可以试试下面的代码,它会起作用的。你不需要 HoltWinters.forecast.

    dftimeseries.hw <- HoltWinters(data)
    dftimeseries.forecast <-forecast(dftimeseries.hw,h=65)