What youre going to end up with is a fairly lengthy


Retail Forecast Assignment

This assignment utilizes retail data from the "retaildata.csv" file (or .xlsx file, or expandedretail files). You are to pick one series from the data (i.e., one column) and follow most or all of the following steps. This is an unrealistic exercise in the sense that one would typically skip over irrelevant methods. Be sure to discuss the quality and validity of each method as you go along, at least in general terms.

What you're going to end up with is a fairly lengthy document, and in the end you should identify the one or two best forecasting models that you have utilized. Plot the best forecast(s), and describe why you think they are the best choices among the methods available to you.

Step 1: Load the data, and for simplicity separate out whatever variables (columns) or observations (rows) that you're interested in examining. Make sure the resulting variables are time series, and convert to time series as appropriate.

• To select specific columns, use newvar <- (data$newvar), or newvar <- (data[,#]), where # is the column of "newvar".
• Check whether your data is a time series (if applicable) using is.ts(newvar).
• If it isn't a time series, use ts(newvar, start = ##, end=##, frequency=m) to convert it to one

Step 2: Plot the data, and answer the following questions.

1. Are there outliers or influential observations?
2. Is there seasonality? If so, is the seasonality consistent throughout the series, or changing?
3. Is there a trend? If so, is it roughly linear or non-linear?
4. Aside from seasonality, does the data have fairly consistent variation, or is a transformation potentially warranted?

• You're going to want to use autoplot() initially.
• Then, if there's seasonality, use ggseasonplot()
• You can decompose the data using stl(), changing argument s.window=## to see if the seasonality is changing over time. There's also the stlplus package.

Step 3: Simple is sometimes best. First, using a training set, see if a simple average or naïve method fits the series.

• If you're dealing with a time series, creating a training set using something along the following lines: newvar_training <- window(newvar, start=##, end=##)

• Once you've got your training set, experiment with rwf(), meanf(), and rwf(newvar_training, drift=TRUE). You'll want to set your forecast horizon, h, such that the last forecast based on your training set coincides with the last observation of your test set (i.e, newvar, in this case). If you cut four quarters off of your data to be your test set, for example, then set h=4.

• If data is seasonal, you should also try snaive()
• You're going to want to plot all of these.

Step 4: If simpler methods are sub-optimal, the next step is to apply the time series linear model, using a training set.

• Here you'll want to use tsfit <- tslm(newvar_training ~ trend + seasonal)
• Then tsfcast <- forecast(tsfit, h=##, level=c(80,95))
• Then autoplot(tsfcast). Also use autolayer() to superimpose your reserved (test set) data on your forecast.

Step 5: We looked at the seasonal naïve forecast earlier; that involved a naïve forecast for each seasonal period. The tslm with seasonal dummies is similar. Next up would be seasonally adjusting the data (usually using stl), and then performing naïve or simple forecasts on the adjusted data.

stlf <- stlf(newvar_training, h=##, s.window="periodic", robust=FALSE, method=c("rwdrift"), level=c(80,95))

Step 6a: Next in order of complexity/sophistication is simple exponential smoothing. If there is a clear trend, or clear seasonality, one would probably skip SES and head straight to Holt's linear trend method, or Holt-Winter's.

• Something along the lines of the following code is a good place to start.

fit1<-ses(training_set,alpha=.33, initial="optimal", h=12) fit2<-ses(training_set,alpha=.67, initial="optimal", h=12) fit3<-ses(training_set, h=24)

• Try to determine the best alpha. The "optimal" one from SES isn't necessarily the one that gives the best forecasts.

Step 6b: Holt's method

• Next one might try a few Holt's method approaches. If there's seasonality, one can use Holt's on seasonally adjusted data. Or you can skip to H-W. There are four possibilities here for the trends: {additive, not damped}, {additive, damped}, {exponential, not damped}, and

{exponential, damped}

fit4 <- holt(training_set, h=12)
fit5 <- holt(training_set, h=12, damped=TRUE)
fit6 <- holt(training_set, h=12, exponential=TRUE)
fit7 <- holt(training_set, h=12, exponential=TRUE, damped=TRUE)

Step 6c: Holt-Winter's

• Then, if there's seasonality, try Holt-Winter's. There are a few options here, as well. In particular, seasonality can be additive or multiplicative. If the seasonal pattern is changing over time, you want multiplicative.

fit8<-hw(full_data,seasonal="additive")
fit9<-hw(full_data,seasonal="multiplicative")

Step 6d: ETS

• To test our assertions of trend and seasonality, as well as generate confidence intervals, we will use the ETS (Error, Trend, Seasonal) model to define and create the forecast that minimizes AICc. These can be constrained to be only additive, only damped, etc., or you can just let the computer select everything.

• One approach: estimate using ETS, without restriction. See what kind of model gets chosen, e.g., ETS(MNM). Compare to a similar Holt-Winter's or Holt specification, e.g. HW with multiplicative seasonality. Perhaps try a partially restricted ETS, or an ETS on Box-Cox transformed data. Then tabulate the accuracy measures and pick the best model.

To be continued... We haven't done any residual testing. If the data are non-stationary, then there's more work to be done. Specifically, fitting an ARIMA model.

There is a follow-up to this assignment, where you will fit an ARIMA model to the same data series, then compare the resulting forecasts to your best forecast(s) from this assignment.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: What youre going to end up with is a fairly lengthy
Reference No:- TGS02775847

Expected delivery within 24 Hours