Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 408
Tracy Avatar asked Jul 28 '17 13:07

Tracy


4 Answers

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]
like image 140
Spacedman Avatar answered Nov 18 '22 19:11

Spacedman


Use like this:

forecast:::forecast.HoltWinters().

It will work.

like image 38
Ashish Avatar answered Nov 18 '22 19:11

Ashish


This works for me when using R v3.4.4 and forecast v8.2:

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

like image 1
Subhash Chandran Avatar answered Nov 18 '22 20:11

Subhash Chandran


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

    dftimeseries.hw <- HoltWinters(data)
    dftimeseries.forecast <-forecast(dftimeseries.hw,h=65)
like image 1
xuelong deng Avatar answered Nov 18 '22 21:11

xuelong deng