i'm trying create forecast using exponential smoothing method, error "nonseasonal data". not true - see code below. why getting error? should use different function (it should able perform simple, double, damped trend, seasonal, winters method)?
library(forecast) timelen<-48 # use 48 months dates<-seq(from=as.date("2008/1/1"), by="month", length.out=timelen) # create seasonal data time<-seq(1,timelen) season<-sin(2*pi*time/12) constant<-40 noise<-rnorm(timelen,mean=0,sd=0.1) trend<-time*0.01 values<-constant+season+trend+noise # create time series object timeseries<-as.ts(x=values,start=min(dates),end=max(dates),frequency=1) plot(timeseries) # forecast mam ets<-ets(timeseries,model="mam") # ann works, why mam not? ets.forecast<-forecast(ets,h=24,level=0.9) plot(ets.forecast)
thanks&kind regards
you should use ts
create time series numeric vector. see file more details.
your start , end values aren't correctly specified. , setting frequency @ 1 not valid seasonality, it's same no seasonality @ all.
try:
timeseries <- ts(data=values, frequency=12) ets <- ets(timeseries, model="mam") print(ets) #### ets(m,a,m) #### call: #### ets(y = timeseries, model = "mam") #### ...
the question in comments, why ann works because third n
means no seasonnality, model can computed non-seasonal timeseries.
Comments
Post a Comment