0

my new result

I have daily sales data i am using Tbat function suggested by Rob Hyndman Sir in many Post.my result is not showing growing trend

I am using the following code

mydata<-read.csv ("D:/data.csv",header=TRUE);
y <- msts(mydata$sales, seasonal.periods=c(7,365.25))
fit <- tbats(y)
fc <- forecast(fit)
plot(fc)
rahul
  • 1
  • 2

1 Answers1

0

As I cannot use your data, here is an example that uses your approach to a) simulate some data with (some kinds of) seasonality, and b) forecasts the next periods.

A) Simulate data

The data is simulated with three components, a sine-function, a cosine-function, and a random component.

# 1. simulate some data:
set.seed(123) # set seed for reproducability
n <- 1000

# simulate the random components
sin.comp <- sin((1:n)/10)*10
cos.comp <- cos((1:n)/5)*5
rand.comp <- rnorm(n)

df <- data.frame(time = seq(from = as.Date("2000-01-01"), by = "day", 
                            length.out = n),
                 value = sin.comp + cos.comp + rand.comp)

# plot the data
plot(x = df$time, y = df$value, main = "Seasonal Series", type = "l")
lines(x = df$time, y = sin.comp, col = "red")
lines(x = df$time, y = cos.comp, col = "blue")
lines(x = df$time, y = rand.comp, col = "green")
legend("bottomleft", 
       c("Series", "Sin", "Cos", "Rand"), 
       lty = c(1, 1), 
       col = c("black", "red", "blue", "green"), cex = 0.7)

Seasonal Series

B) Forecast the series

y <- msts(df$value, seasonal.periods = c(7, 36)) # cut down to 36
fit <- tbats(y) #takes some time to calculate..
fc <- forecast(fit)

plot(fc)

Forecast

Additional Notes

If this approach doesn't work for you that means that your is probably data in some way not right for the forecast...

To check your data, you can inspect the types with str(mydata) (in my case str(df)), summary(mydata), and head/tail(mydata).

As a last note, your dput is obviously a bit too long... Either post dput(head(mydata, 100)), which gives the first 100 entries, or upload the csv to a hoster and post the link.

Does that point you in the right direction?

Community
  • 1
  • 1
David
  • 9,216
  • 4
  • 45
  • 78
  • David please tell me your email id i will mail to u...please its urgent...nothing is wrong with my data...after decomposing this i can see the data seasonal pattern – rahul Dec 18 '15 at 14:36
  • Can you first explain what exactly your issue is? You state that you don't see a trend. What if there is no trend in your data? – David Dec 18 '15 at 14:48
  • okk i had attached graph of my result in start of question.sales was growing but at the point of forecast it got down..this should not happen – rahul Dec 18 '15 at 14:53
  • can you include the graph of `plot(fit)`, not `plot(fc)` but an additional `plot(fit)` – David Dec 18 '15 at 14:54
  • yes i added when u click on Forecasted result graph – rahul Dec 18 '15 at 14:56
  • I have attached plot(fit) – rahul Dec 18 '15 at 15:11
  • I don't see anything wrong with the data.... The slope goes down in the end, and this is portrayed in the forecast. What exactly are you trying to achieve? – David Dec 18 '15 at 15:16
  • this time i again attach my result..blue line is ok but gray band gone very high ?? not acceptable – rahul Dec 18 '15 at 15:25
  • My final question why there is very high value of prediction band – rahul Dec 18 '15 at 18:31