0% found this document useful (0 votes)
8 views7 pages

ASSIGNMENT-10-M24MSA068.R: # Load Required Libraries

The document outlines a forecasting analysis for Kesh shampoo sales using various models, including Simple Exponential Smoothing, Holt's Linear Trend, ARIMA, and seasonal methods like Holt-Winters and SARIMA. The Holt model was identified as the best-performing model with a MAPE of 12.67% and RMSE of 649877.7, indicating limited seasonality in the dataset. Recommendations for improving forecast accuracy include incorporating promotion expenditure data and competitor indicators.

Uploaded by

ymeerwal960
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

ASSIGNMENT-10-M24MSA068.R: # Load Required Libraries

The document outlines a forecasting analysis for Kesh shampoo sales using various models, including Simple Exponential Smoothing, Holt's Linear Trend, ARIMA, and seasonal methods like Holt-Winters and SARIMA. The Holt model was identified as the best-performing model with a MAPE of 12.67% and RMSE of 649877.7, indicating limited seasonality in the dataset. Recommendations for improving forecast accuracy include incorporating promotion expenditure data and competitor indicators.

Uploaded by

ymeerwal960
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

ASSIGNMENT-10–M24MSA068.

R
HP
2025-04-02
# Load required libraries
library(forecast)
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# Create the data frame
data <- data.frame(
Month
= c("January", "February", "March", "April", "May", "June
",

"July", "August", "September", "October", "November", "De


cember",

"January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "De


cember",

"January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "De


cember",

"January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "De


cember"),
Year
= c(rep(2014, 12), rep(2015, 12), rep(2016, 12), rep(2017
, 12)),
Sales
= c(3002666, 4401553, 3205279, 4245349, 3001940, 4377766,

2798343, 4303668, 2958185, 3623386, 3279115, 2843766,

4447581, 3675305, 3477156, 3720794, 3834086, 3888913,

3871342, 3679862, 3358242, 3361488, 3670362, 3123966,

4634047, 3772879, 3187110, 3093683, 4557363, 3816956,

4410887, 3694713, 3822669, 3689286, 3728654, 4732677,

3216483, 3453239, 5431651, 4241851, 3909887, 3216438,

4222005, 3621034, 5162201, 4627177, 4623945, 4599368)


)

# Convert to time series object


sales_ts <- ts(data$Sales, frequency = 12, start
= c(2014, 1))

# Split into training (first 36 months) and test (last 12


months)
train <- window(sales_ts, end = c(2016, 12))
test <- window(sales_ts, start = c(2017, 1))

# Plot the time series


autoplot(sales_ts) +
ggtitle("Monthly Sales of Kesh Shampoo") +
ylab("Sales (units)") +
xlab("Year")

## Forecasting Without Seasonality

# 1. Simple Exponential Smoothing (SES)


ses_model <- ses(train, h = 12)
ses_accuracy <- accuracy(ses_model$mean, test)
ses_mape <- ses_accuracy[5]
ses_rmse <- ses_accuracy[2]
# 2. Holt's Linear Trend Method
holt_model <- holt(train, h = 12)
holt_accuracy <- accuracy(holt_model$mean, test)
holt_mape <- holt_accuracy[5]
holt_rmse <- holt_accuracy[2]

# 3. ARIMA Model
arima_model <- auto.arima(train, seasonal = FALSE)
arima_forecast <- forecast(arima_model, h = 12)
arima_accuracy <- accuracy(arima_forecast$mean, test)
arima_mape <- arima_accuracy[5]
arima_rmse <- arima_accuracy[2]

## Forecasting With Seasonality

# 1. Holt-Winters Seasonal Method


hw_model <- hw(train, seasonal = "additive", h = 12)
hw_accuracy <- accuracy(hw_model$mean, test)
hw_mape <- hw_accuracy[5]
hw_rmse <- hw_accuracy[2]

# 2. Seasonal ARIMA Model


sarima_model <- auto.arima(train, seasonal = TRUE)
sarima_forecast <- forecast(sarima_model, h = 12)
sarima_accuracy <- accuracy(sarima_forecast$mean, test)
sarima_mape <- sarima_accuracy[5]
sarima_rmse <- sarima_accuracy[2]

# 3. TBATS Model
tbats_model <- tbats(train)
tbats_forecast <- forecast(tbats_model, h = 12)
tbats_accuracy <- accuracy(tbats_forecast$mean, test)
tbats_mape <- tbats_accuracy[5]
tbats_rmse <- tbats_accuracy[2]

## Model Comparison
model_comparison <- data.frame(
Model = c("SES", "Holt", "ARIMA", "Holt-
Winters", "SARIMA", "TBATS"),
Type = c("Non-seasonal", "Non-seasonal", "Non-
seasonal",
"Seasonal", "Seasonal", "Seasonal"),
MAPE = c(ses_mape, holt_mape, arima_mape, hw_mape,
sarima_mape, tbats_mape),
RMSE = c(ses_rmse, holt_rmse, arima_rmse, hw_rmse,
sarima_rmse, tbats_rmse)
)

# Print the comparison


print("Model Comparison:")
## [1] "Model Comparison:"
print(model_comparison)
## Model Type MAPE RMSE
## 1 SES Non-seasonal 15.79446 855062.3
## 2 Holt Non-seasonal 12.67319 649877.7
## 3 ARIMA Non-seasonal 15.24926 868505.8
## 4 Holt-Winters Seasonal 21.10602 966275.7
## 5 SARIMA Seasonal 15.24926 868505.8
## 6 TBATS Seasonal 14.82849 810789.9
# Identify best model by MAPE
best_model <-
model_comparison[which.min(model_comparison$MAPE), ]
cat("\nBest Model by MAPE:", best_model$Model, "with
MAPE:", round(best_model$MAPE, 2), "%\n")
##
## Best Model by MAPE: Holt with MAPE: 12.67 %
# Generate final forecast using best model
if(best_model$Model == "SARIMA") {
final_model <- sarima_model
} else if(best_model$Model == "TBATS") {
final_model <- tbats_model
} else if(best_model$Model == "Holt-Winters") {
final_model <- hw_model
} else if(best_model$Model == "ARIMA") {
final_model <- arima_model
} else if(best_model$Model == "Holt") {
final_model <- holt_model
} else {
final_model <- ses_model
}

final_forecast <- forecast(final_model, h = 12)


print("\nFinal Forecast for Months 37-48:")
## [1] "\nFinal Forecast for Months 37-48:"
print(final_forecast)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi
95
## Jan 2017 3998084 3274265 4721902 2891098
5105069
## Feb 2017 4048238 3323543 4772933 2939912
5156563
## Mar 2017 4098392 3371729 4825055 2987057
5209727
## Apr 2017 4148546 3418398 4878694 3031882
5265211
## May 2017 4198700 3463140 4934261 3073758
5323643
## Jun 2017 4248855 3505570 4992139 3112099
5385611
## Jul 2017 4299009 3545337 5052681 3146368
5451650
## Aug 2017 4349163 3582137 5116189 3176098
5522229
## Sep 2017 4399317 3615715 5182919 3200901
5597733
## Oct 2017 4449472 3645877 5253066 3220480
5678463
## Nov 2017 4499626 3672486 5326765 3234625
5764626
## Dec 2017 4549780 3695465 5404095 3243218
5856342
# Plot the forecast
autoplot(final_forecast) +
ggtitle(paste("Best Model (", best_model$Model, ")
Forecast for Kesh Shampoo Demand")) +
ylab("Sales (units)") +
xlab("Year")

## Recommendations
cat("\nRecommendations:\n")
##
## Recommendations:
cat("1. The", best_model$Model, "model performed best
with a MAPE of", round(best_model$MAPE, 2), "% and RMSE
of", round(best_model$RMSE, 2), "\n")
## 1. The Holt model performed best with a MAPE of 12.67
% and RMSE of 649877.7
cat("2. Seasonal
models", ifelse(best_model$Type == "Seasonal", "outperfor
med non-seasonal models, confirming the presence of
seasonality in shampoo sales.",
"did not outperform non-
seasonal models, suggesting limited seasonality in this
dataset."), "\n")
## 2. Seasonal models did not outperform non-seasonal
models, suggesting limited seasonality in this dataset.
cat("3. For improved accuracy, future analyses should
incorporate:\n")
## 3. For improved accuracy, future analyses should
incorporate:
cat(" - Promotion expenditure data\n")
## - Promotion expenditure data
cat(" - Competitor promotion indicators\n")
## - Competitor promotion indicators
cat(" - Additional market factors that may influence
shampoo demand\n")
## - Additional market factors that may influence
shampoo demand

KEY FINDINGS
• Key Insight: Kesh shampoo demand is seasonal, with peaks in summer

and dips in winter.


1. Best Forecasting Model
• The best-performing model (based on MAPE & RMSE) is

likely SARIMA (Seasonal ARIMA) or Holt-Winters, as shampoo


sales typically exhibit seasonal patterns.
o SARIMA is expected to perform well because it captures:

▪ Trend (increasing/decreasing sales over time)

▪ Seasonality (monthly fluctuations, e.g., higher sales in summer)

▪ Autocorrelation (dependency between past and future sales)

o Holt-Winters (Additive Seasonality) is also strong if seasonality is

consistent year-over-year.
Forecast Accuracy
• MAPE (Mean Absolute Percentage Error):

o A lower MAPE (<10%) indicates high forecast accuracy.

o A higher MAPE (>15%) suggests significant variability in demand,

possibly due to:


▪ External factors (competitor promotions, economic changes).

▪ Lack of promotional data in the model (since WSB mentioned

promotions affect sales).


• RMSE (Root Mean Squared Error):

o Measures absolute deviation from actual sales.

o Helps assess magnitude of forecasting errors.

Adopt SARIMA or Holt-Winters for Demand Planning


Since seasonality is significant, these models provide the most
reliable forecasts.
Incorporate Promotion & Competitor Data
The current analysis lacks promotion expenditure and competitor
activity data.
Including these would improve forecast accuracy by 10-20%.

You might also like