简体   繁体   中英

R forecast.holtwinters in forecast package not found

I am trying to use the forecast.holtwinters function and when I try to run it:

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

I get this error:

Error: could not find function "forecast.HoltWinters"

I have also tried this:

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

But I get this error message:

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

I look at this list of functions in the forecast package using this code:

ls("package:forecast")

and this 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"

Does anyone know what is going on? I've used this before and had no problems. I'm using forecast version 8.1.

None of these things are in the forecast package. They are in 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.HoltWinters is an unexported function from stats which should only be called on objects from HoltWinters() .

forecast.HoltWinters is an unexported function from forecast which means you need three colons to access it. But you should never have to do this because it should be automatically found when you run forecast on a the output from HoltWinters() :

> 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]

Same as:

> 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]

Use like this:

forecast:::forecast.HoltWinters().

It will work.

在使用R v3.4.4和预测v8.2时,这适用于我:

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

Use:

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

after updating your r version and it will work

you can try belows code,it will work. you need not HoltWinters.forecast.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM