Search code examples
rtime-seriesforecasting

R-Weekly Forecast


When I use ts <- ts(df, frequency=52, start=c(2007,1)) and then print it, I got results shown below, so instead of 2007.01, 2007.02, 2007.52 ...., I got 2007.000, 2007.019, ....which it gets from 1/52=0.019 which is mathematically correct but not really easy to interpret, is there a way to label it as the date itself just like data frame or at least 2007 wk1, 2007 wk2 ...

Time Series:

Start = c(2007, 1)

End = c(2014, 11)

Frequency = 52

Week,          Amount

2007.000,      645575.4

2007.019,      2185193.2

2007.038,      1016711.8

2007.058,      1894056.4    

2007.077,      2317517.6    

2007.096,      2522955.8    

2007.115,      2266107.3    

Solution

  • fit <- auto.arima(dmsales[[2]])
    fcast<-forecast(fit,h=input$ahead)
    dfcast<-data.frame(fcast)
    b<-data.frame(seq(as.Date(dmsales[[3]]+7), by = "week", length.out = input$ahead))
    ffcast<-as.data.frame(cbind(b,dfcast$Point.Forecast,dfcast$Lo.95,dfcast$Hi.95))
    names(ffcast)<-c("Week","Forecast","Lo-95","Hi-95")