Вы находитесь на странице: 1из 2

Assignment 4

Due Date: Aug 25, 2017


Consider the problem of "Forecasting Demand for Food at Apollo Hospitals" discussed in the
class. The Apollo Hospitals, Bangalore, is a 250-bed hospital. The hospital provides treatment
to 230 in-patients on an average. Food and beverages (F&B) are served to these patients as
per their choice, provided they are approved by the dieticians. On a regular basis, the hospital
prepares food items that are more than 20% in excess of the quantity that is estimated based
on the previous experience. However, it is observed that the wastage is more than 50-60% on
some of the days. Thus the objective is to accurately estimate the required quantity of F&B
items. This will reduce the overall wastage of F&B items.
Thus the order details of different food items served between October 1, 2012 and January
23, 2013, are gathered. The idea is to model the demand for each food item and use the
model to estimate the demand for each food item 2 days ahead as well as 1 day ahead.
Answer the following questions:
1. Develop an appropriate forecasting model for each of the food items. Comment on
the performance of each model.
2. It is suggested that demand for each food item is related to occupancy. Is there any
statistical evidence for this claim?
3. Does inclusion of the occupancy into the forecasting model improve the
performance of the models.
4. Suggest suitable action for Apollo Hospital going forward for a proper estimation of
demand for each food item.

Hint: You may start with the following code. This may require some modification. Also you have to
replicate the code for other food items.
d=read.csv("Apollo.csv",header=T)
attach(d)
# Modeling Idly Demand
Idly=ts(Idly)
Idly_Train=window(Idly,start=1,end=108)
Idly_Test=window(Idly,start=109,end=115)
# Modeling on Training Data
# Plot
plot(Idly_Train,col="red",lwd=2)
# Check whether white noise
Box.test(Idly_Train)
Box.test(Idly_Train,type="Lj")
# ACF and PACF Plot
par(mfrow=c(1,2))
Acf(Idly_Train,main="",col="red",lwd=2)
Pacf(Idly_Train,main="",col="red",lwd=2)
# Stationarity Check
# Formal Tests
adf.test(Idly_Train, alternative = "stationary")
kpss.test(Idly_Train)

# ARIMA Model
fit=auto.arima(Idly_Train)

# Diagnostic Tests
res=residuals(fit)
par(mfrow=c(1,2))
Acf(res,main="ACF",col="red",lwd=2)
Pacf(res,main="PACF",col="red",lwd=2)

# Formal Checks
Box.test(res,fitdf=1,lag=10)
Box.test(res,fitdf=1,lag=10,type="Lj")

# Forecasting
Idly_for<-forecast(fit,h=7)

#Accuracy
accuracy(Idly_for,Idly_Test)

# Plot of Forecast Values


plot(forecast(fit,h=7),col="red",lwd=2,main="")
lines(fitted(fit),lwd=2,col="black")
lines(Idly_Test,lwd=2,col="green")

# Time Series Regression


BKFST_OCCUP=ts(BKFST_OCCUP)
BKFST_OCCUP_Train=window(BKFST_OCCUP,start=1,end=108)
BKFST_OCCUP_Test=window(BKFST_OCCUP,start=109,end=115)

# Auto Arima
fit=auto.arima(Idly_Train,xreg=BKFST_OCCUP_Train)

# Forecasting
Idly_for=forecast(fit,xreg=BKFST_OCCUP_Test,h=7)

#Accuracy
accuracy(Idly_for,Idly_Test)

Note: An alternative approach to fit a Time Series model is to divide the data into a training
set and a test set (with sufficient number of observations of course, say around 20%). Then
one should build a number of models based on the training data and obtain the test error
(say, MAPE) for each one of them. The model with minimum test error is the recommended
model. This was briefly suggested in the class. To fit the models manually, you should use
Arima() function. However, for answering the questions above, you use auto.arima()
function based on 108 observations to get the optimal model, then use the model to forecast
for next seven days. See how your model is performing for the next seven days based on point
and interval forecasts and the actual observations. Finally refit your model on the entire data
set and provide one-step or two-step ahead forecasts.

Вам также может понравиться