[R] forecast using linear model
Mayukh Dass
mayukh.dass at gmail.com
Thu Feb 23 07:03:31 CET 2017
Hello,
I have a time series with sales data of two products A and B. The sales
data are reported weekly.
I want to forecast next 26 weeks sales data for product A using trend,
seasonality and sales of B.
So first I forecast next 26 weeks sales of B with only trend and season.
Next, I tried to create a data frame with these new 26 values of B, and
forecast sales of A. Unfortunately, I am getting the following error:
> train.lm.trend.season.pred <- forecast(train.lm.trend.season, h=26,
newdata=future_data)
Error in eval(expr, envir, enclos) : object 'solvedFN___1' not found
The code used:
nFuture <- 26
trainc1.ts <- window(pB.ts) #sales of Product B
train.ts <- window(pA.ts) #sales of Product A
trainc1.lm.trend.season <- tslm(trainc1.ts ~ trend + season)
summary(trainc1.lm.trend.season)
trainc1.lm.trend.season.pred <- forecast(trainc1.lm.trend.season, h =
nFuture, level = 0)
future_data <- data.frame(
com1 = trainc1.lm.trend.season.pred$mean
)
forecast(fit, newdata=future_data)
train.lm.trend.season <- tslm(train.ts ~ trend + season+trainc1.ts)
summary(train.lm.trend.season)
train.lm.trend.season.pred <- forecast(train.lm.trend.season, h=26,
newdata=future_data)
It will be great if you can help me.
Mayukh
[[alternative HTML version deleted]]
More information about the R-help
mailing list