2.
ปห
The paper "Improving the On Time Delivery performance by the implementation of a Sales Inventory &
Operations Planning process" aims to address the problem of poor on-time delivery performance in a
company.
ปหรอง
The company was facing issues in meeting customer demand due to inadequate inventory management
practices, inaccurate demand forecasting, and lack of collaboration between different departments.
วิธีแก้
The paper proposes the implementation of a Sales Inventory & Operations Planning (SIOP) process as a
solution to address these issues and improve the on-time delivery performance.
The SIOP process involves integrating sales, marketing, operations, and finance departments to create a
unified planning process that can 1 optimize inventory levels, 2 improve demand forecasting accuracy,
and 3 increase collaboration between different departments.
ส่งผลต่อธุรกิจ
The poor on-time delivery performance affects the business of the company by leading to lower customer
satisfaction, increased inventory holding costs, and reduced profitability due to the need for expediting
and rush deliveries.
ต่อผปก It also affects the entrepreneur by increasing the risk of losing customers to competitors and
damaging the company's reputation in the market.
ต่อลค For customers, the problem leads to inconvenience and dissatisfaction, potentially leading to loss of
trust and loyalty towards the company.
ต่อ Part suppliers are also affected by the poor on-time delivery performance as they may need to hold
excess inventory or experience production delays, leading to increased costs and potential loss of
business.
ขอบเขต
1.5 Scope and assumptions
In this section the scope (boundaries) and assumptions of this research will be outlined:
ㆍ The research will focus on the Special Vehicles & Equipment (SV&E) market. Although the
processes and procedures in the SV&E market are comparable to the Medical market Power-
Packer serves, the scope is limited to the SV&E market because the number of components to
review is already over a hundred. However, the developed tools and procedures could also be
used in these other markets.
Power-Packer, a division of the Dutch industrial conglomerate, has a medical market
focus on hydraulic actuation systems and specialized lifting equipment used in healthcare
settings. Their hydraulic systems are used in medical equipment such as hospital beds, stretchers,
and patient lifts to provide smooth and precise movement for patient comfort and safety.
Additionally, they also provide hydraulic actuation systems and components for other industries
such as automotive, marine, and industrial applications.
To limit the scope, the indebt analysis of products will only focus on products which
caused an On Time Delivery problem in the period July 2014 - June 2015.
The in-depth analysis of the Not On Time Delivery (NOTD) causes will only be executed
for the major cause of the Not On time Delivery; the material shortage, see paragraph 3.1.4.
Production planning will be left out of scope.
Data in Oracle about for example, supplier lead times and cost prices, are assumed to be
valid. A complete validation of the accuracy of this data will be too time consuming and
therefore out of scope.
The impact of the Warehouse move from the “Hanzepoort” to the production site a few
kilometers away will be left out of scope.
ตาราง
วัตถุประสงค์?
Research goal
The goal of this research is to lay a foundation to improve the On Time Delivery (and
corresponding Overdue) performance within the SV&E market. The processes, procedures and
parameters used to streamline the logistical performance must be reviewed and improved where
possible. This includes identifying critical components, optimally assigning inventory methods to
products / components and the implementation of a Sales Inventory and Operations Planning
(SIOP) process to support decision making about inventory parameter settings.
3.
1. Product Segmentation: You can use Excel VBA to segment your products based
on certain criteria, such as sales volume, product category, etc. For example, you
can use the following VBA code to create a new worksheet that lists the products
with the highest sales volume:
Sub Product_Segmentation()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets.Add
'Assuming the sales data is in a sheet called "Sales"
Dim sales_data As Range
Set sales_data = ThisWorkbook.Worksheets("Sales").Range("A2:C1000")
'Sort the sales data by sales volume
sales_data.Sort key1:=sales_data.Columns(3), order1:=xlDescending, Header:=xlYes
'Copy the top 100 products to the new sheet
Dim top_products As Range
Set top_products = sales_data.Resize(100, 3)
top_products.Copy ws.Range("A1")
End Sub
2. Data Exploration: Excel VBA can be used to explore the data and create
visualizations. For example, you can use the following VBA code to create a line
chart of the sales data:
Sub Create_Line_Chart()
'Assuming the sales data is in a sheet called "Sales"
Dim sales_data As Range
Set sales_data = ThisWorkbook.Worksheets("Sales").Range("A2:B1000")
'Create a new chart sheet
Dim cht As Chart
Set cht = ThisWorkbook.Charts.Add
cht.ChartType = xlLine
'Add the sales data to the chart
cht.SetSourceData Source:=sales_data
'Customize the chart
cht.HasTitle = True
cht.ChartTitle.Text = "Sales Data"
cht.Axes(xlCategory).HasTitle = True
cht.Axes(xlCategory).AxisTitle.Text = "Date"
cht.Axes(xlValue).HasTitle = True
cht.Axes(xlValue).AxisTitle.Text = "Sales"
End Sub
3. Statistical Model Selection: Excel VBA can be used to fit and evaluate different
statistical models on the data. For example, you can use the following VBA code
to fit an ARIMA model on the sales data:
Sub Fit_ARIMA_Model()
'Assuming the sales data is in a sheet called "Sales"
Dim sales_data As Range
Set sales_data = ThisWorkbook.Worksheets("Sales").Range("A2:B1000")
'Fit an ARIMA model on the sales data
Dim arima_model As Object
Set arima_model = CreateObject("RStat.ARIMA")
arima_model.SetRange sales_data
arima_model.Order = "auto"
arima_model.Fit
'Print the model summary to the immediate window
Debug.Print arima_model.Summary
End Sub
-----------------------
However, I can provide a basic template for implementing some of the statistical models
used in the paper. Here is an example of how to implement the modified SBA model:
1. First, you need to create a table of your historical sales data with the following
columns:
Date: the date of each sale
Demand: the actual demand for the product on that date
Lead time: the number of days it takes to receive the product after placing an
order
2. Open Excel and create a new workbook.
3. In the first sheet, enter the historical sales data in the format mentioned above.
4. In the second sheet, create a table with the following columns:
Forecast: the forecasted demand for each period
Error: the difference between the forecasted demand and the actual demand for
each period
MAD: the mean absolute deviation of the error
MAPE: the mean absolute percentage error of the error
5. In the third sheet, create a table with the following columns:
Demand: the actual demand for each period
Lead time: the number of days it takes to receive the product after placing an
order
SS: the safety stock level for each period
LT: the reorder point for each period
Order qty: the order quantity for each period
6. Open the VBA editor by pressing Alt + F11.
7. In the VBA editor, insert a new module and paste the following code:
Sub ModSBA() Dim i As Long, n As Long Dim alpha As Double, beta As Double, gamma As
Double Dim a() As Double, b() As Double, s() As Double Dim L As Integer, p As Integer, q As
Integer Dim demand() As Double, forecast() As Double, error() As Double Dim MAD As Double,
MAPE As Double
' Read data from sheet1
n = Sheet1.Range("A1").CurrentRegion.Rows.Count - 1
ReDim demand(1 To n)
ReDim forecast(1 To n)
ReDim error(1 To n)
For i = 1 To n
demand(i) = Sheet1.Range("B2").Offset(i - 1, 0).Value
Next i
' Set model parameters
alpha = 0.4
beta = 0.2
gamma = 0.3
L = 12
p=1
q=1
' Initialize parameters
ReDim a(1 To n)
ReDim b(1 To n)
ReDim s(1 To n + L)
For i = 1 To L
s(i) = demand(i)
Next i
a(1) = demand(1)
b(1) = demand(2) - demand(1)
For i = 2 To L + 1
s(i) = (demand(i - 1) + s(i - 1)) / L
Next i
' Forecast demand
For i = L + 1 To n
a(i) = alpha * (demand(i) - s(i - L)) + (1 - alpha) * (
Note that this is a high-level overview, and the actual implementation will depend on the
specific details of your data and forecasting problem. You may also need to consult additional
resources or seek expert advice to fully implement the methods described in the paper.
Sub InsertCopiedFcRows ()
Dim 1 As Integer
Dim LastRow As Integer
Dim NumPastWeeks As Integer
Dim x As Integer
ActiveWorkbook.ActiveSheet .AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.AutoFilter.Sort.SortFields.Add
Key:=Range ("G1:G7079"), SortOn:=xlSortOnValues, Order: =xlAscending,
DataOpt1on:=x1SortNormal
With ActiveWorkbook. ActiveSheet.AutoFilter.Sort
.Header = xlles
.MatchCase = False
.Orientation = xlTopIoBottom
.SortMethod = x1Pintin
.Apply
End With
LastRow = = Cells(1, 2) .End (xlDown). . Row
i-2
Do While i <= LastRow
If Cells(i, 2) < 201851 And _{Cells(i+1, 2) <> (Cells(i, 2) +1 Or _ Cells(i +1,6) <> Cells(i,6))
Then
Actives Sheet.Cells(i,1).EntireRow.Select
Selection.Copy
Selection. Insert Shift: xlDown
NumPastWeeks = Cells(i +1, 2).Value - 201800
For x = 1 To NumPastWeeks
Cells(1 +1,x+7).ClearCon ntents
Next x
ActiveSheet.Cells(i+1,2).Value= Cells(1,2).Value + 1
ActiveSheet.Cells(1 + 1, 1).Select
Selection.ClearContents
With Selection. Interior
.Pattern - x1Solid
.FatternThemeColor -XIThemeColorAccent2
.ThemeColor - x1ThemeColorAccent2
.TintAndShade = -0.249977111117893
.PatternTintAndSh hade = 0.599993896298105
End With
End If
LastRow = Cells(1, 2).End(xlDown).Row
i = i+1
Loop
End Sub
Step 2
The second step of the plan is about choosing the best way to predict how much of a product
will be needed. Some products are hard to predict using statistics, so they are split into different
groups based on their lifecycle and expected demand. For new products, they are split into two
groups based on whether they are totally new or similar to an existing product. The different
ways to predict the demand are: using statistics, ordering based on customer orders, and using
expert opinions. The decision on which method to use depends on the type of product and how
predictable the demand is. There is a chart in the back of the paper that helps make these
decisions. Overall, products with a regular demand pattern should be predicted using statistics,
and those with a less predictable pattern should not be predicted using statistics. If there isn't
enough data available, experts should be consulted to make the best guess.
Step 3
This paper is about predicting demand for products. They will follow steps three to six for each
product. Step 2 helps determine which products to forecast. If a product is not in the selected
range, it will be excluded from the forecast. Sometimes outliers are removed from the data. The
authors suggest testing the forecasting model for at least one year of data. They recommend a
dataset containing at least five years of data for best results. If that is not possible, cross-
validation can be used instead. If a trend is noticed in the data, the Holt linear trend method
should be applied. Additive time series decomposition is used when seasonality is expected in
the demand pattern. Croston's method assumes stationarity, so additive decomposition is used
for intermittent data. The remainder component of the time series data is used for statistical
forecasting.
in the paper "LIABILITY REDUCTION THROUGH DEMAND FORECASTING IMPROVEMENT" by
Marleen Roerink at the University of Twente, "training and test set are split 80-20" means that
the available historical data for a product is divided into two parts: the training set which
contains 80% of the data and is used to build the forecasting model, and the test set which
contains 20% of the data and is used to evaluate the accuracy of the forecasting model. This
approach is commonly used in time series forecasting to prevent overfitting and to assess the
performance of the model on new, unseen data.
D'_t = (1-beta/2)*Z'_t/T'_t)
where
If D_t > 0 then
Z'_t = Z'_t-1+a*(Z_t-Z'_t-1)
T'_t = T'_t-1 + Beta*(T_t-T'_t-1)
If Dt = 0 then
Z't = Z'_t-1
T'_t = T'_t-1+B*(T_t-T'_t-1), if T_t>T'_t-1
= T'_t-1, if T_t <= T'_t-1
Work code
Sub ExponentialSmoothingAndSBA()
' Define variables
Dim ws As Worksheet
Dim alpha As Double
Dim forecast As Double
Dim i As Integer
Dim j As Integer
' Set active worksheet
Set ws = ActiveWorkbook.ActiveSheet
' Define alpha
alpha = 0.1
' Perform exponential smoothing for warm-up period of 5 periods
For i = 2 To 6
ws.Cells(i, 3).Value = ws.Cells(i - 1, 2).Value
Next i
' Perform exponential smoothing and modified SBA forecast model for remaining
periods
For i = 7 To ws.Cells(Rows.Count, 1).End(xlUp).Row
' Exponential smoothing
forecast = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1, 3).Value
ws.Cells(i, 3).Value = forecast
' Modified SBA forecast model
For j = 1 To 3
forecast = forecast + alpha * (ws.Cells(i, 2).Value - forecast)
Next j
ws.Cells(i, 4).Value = forecast
Next i
End Sub
-----------
Expo and sba without err
Sub ExponentialSmoothingAndSBA()
' Define variables
Dim ws As Worksheet
Dim alpha As Double
Dim forecast As Double
Dim i As Integer
Dim j As Integer
' Set active worksheet
Set ws = ActiveWorkbook.ActiveSheet
' Define alpha
alpha = 0.1
' Add column headers
ws.Cells(1, 2).Value = "Demand"
ws.Cells(1, 3).Value = "Exponential Smoothing"
ws.Cells(1, 4).Value = "Modified SBA Forecast"
' Initialize first exponential smoothing forecast value
ws.Cells(2, 3).Value = ws.Cells(2, 2).Value
' Perform exponential smoothing for warm-up period of 5 periods
For i = 3 To 6
ws.Cells(i, 3).Value = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1,
3).Value
Next i
' Perform exponential smoothing and modified SBA forecast model for remaining
periods
For i = 7 To 25
' Exponential smoothing
forecast = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1, 3).Value
ws.Cells(i, 3).Value = forecast
' Modified SBA forecast model
For j = 1 To 3
forecast = forecast + alpha * (ws.Cells(i, 2).Value - forecast)
Next j
ws.Cells(i, 4).Value = forecast
Next i
End Sub
With err
Sub ExponentialSmoothingAndSBA()
' Define variables
Dim ws As Worksheet
Dim alpha As Double
Dim forecast_es As Double
Dim forecast_sba As Double
Dim error_es As Double
Dim error_sba As Double
Dim i As Integer
' Set active worksheet
Set ws = ActiveWorkbook.ActiveSheet
' Define alpha
alpha = 0.1
' Add column headers
ws.Cells(1, 2).Value = "Demand"
ws.Cells(1, 3).Value = "Exponential Smoothing"
ws.Cells(1, 4).Value = "Modified SBA Forecast"
ws.Cells(1, 5).Value = "Error - Exponential Smoothing"
ws.Cells(1, 6).Value = "Error - Modified SBA Forecast"
' Initialize first exponential smoothing forecast value
ws.Cells(2, 3).Value = ws.Cells(2, 2).Value
' Perform exponential smoothing for warm-up period of 5 periods
For i = 3 To 6
forecast_es = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1, 3).Value
ws.Cells(i, 3).Value = forecast_es
error_es = ws.Cells(i, 2).Value - forecast_es
ws.Cells(i, 5).Value = error_es
Next i
' Perform exponential smoothing and modified SBA forecast model for remaining periods
For i = 7 To 25
' Exponential smoothing
forecast_es = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1, 3).Value
ws.Cells(i, 3).Value = forecast_es
error_es = ws.Cells(i, 2).Value - forecast_es
ws.Cells(i, 5).Value = error_es
' Modified SBA forecast model
forecast_sba = forecast_es
For j = 1 To 3
forecast_sba = forecast_sba + alpha * (ws.Cells(i, 2).Value - forecast_sba)
Next j
ws.Cells(i, 4).Value = forecast_sba
error_sba = ws.Cells(i, 2).Value - forecast_sba
ws.Cells(i, 6).Value = error_sba
Next i
End Sub
Company X wants to focus on its core business of software development and has
outsourced production activities to EMSs
Excess inventory at EMSs is a liability for Company X and is mainly caused by
demand forecasting errors
Company X's goal is to reduce excess inventory by improving demand
forecasting performance
The appropriate forecasting model depends on the demand pattern, which can
be classified into four categories
Most of Company X's products have an intermittent demand pattern, and some
have a lumpy demand pattern
Products with the highest value are closer to having a smooth demand pattern,
which is easier to forecast
Improving the forecasting method using a statistical model is expected to be
effective
1. Business and Entrepreneur:
Inaccurate demand forecasting leads to overproduction or underproduction of goods and
services.
Overproduction results in excess inventory, which increases storage and obsolescence costs.
Underproduction leads to stockouts, missed sales opportunities, and customer
dissatisfaction, resulting in a loss of revenue and market share.
2. Customers:
Inaccurate demand forecasting can cause stockouts or long wait times for products, leading
to customer dissatisfaction and lost sales.
Customers may also face higher prices due to the increased costs associated with excess
inventory.
3. Suppliers:
Inaccurate demand forecasting can lead to miscommunication and inefficiencies in the
supply chain.
Suppliers may receive inaccurate orders, leading to either excess or insufficient inventory
levels.
This can result in increased transportation and storage costs, as well as delays in the delivery
of goods and services.
1. Business and Entrepreneur:
• Inaccurate demand forecasting leads to overproduction or underproduction of
goods and services.
• Overproduction results in excess inventory, which increases storage and
obsolescence costs.
• Underproduction leads to stockouts, missed sales opportunities, and customer
dissatisfaction, resulting in a loss of revenue and market share.
2. Customers:
• Inaccurate demand forecasting can cause stockouts or long wait times for
products, leading to customer dissatisfaction and lost sales.
• Customers may also face higher prices due to the increased costs associated with
excess inventory.
3. Suppliers:
• Inaccurate demand forecasting can lead to miscommunication and inefficiencies
in the supply chain.
• Suppliers may receive inaccurate orders, leading to either excess or insufficient
inventory levels.
• This can result in increased transportation and storage costs, as well as delays in
the delivery of goods and services.
Sub Forecast()
Dim alpha As Double, beta As Double
alpha = 0.4
beta = 0.4
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet3")
' Calculate warm-up forecast for first 5 periods using exponential smoothing
ws.Cells(2, 3).Value = ws.Cells(2, 2).Value ' initial level
For i = 3 To 6
forecast_es = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1, 3).Value
ws.Cells(i, 3).Value = forecast_es
Next i
' Calculate forecast for remaining periods using modified SBA model
Dim Z As Double, T As Double, Zp As Double, Tp As Double
Z = ws.Cells(6, 2).Value ' initial demand
T = ws.Cells(6, 2).Value - ws.Cells(5, 2).Value ' initial trend
Zp = Z
Tp = T
For i = 7 To ws.Cells(Rows.Count, 2).End(xlUp).Row
' Exponential smoothing
If i <= 10 Then
forecast_es = alpha * ws.Cells(i, 2).Value + (1 - alpha) * ws.Cells(i - 1, 3).Value
ws.Cells(i, 3).Value = forecast_es
End If
' Modified SBA forecast model
If ws.Cells(i, 2).Value > 0 Then
Zp = Zp + alpha * (ws.Cells(i, 2).Value - Z)
Tp = Tp + beta * (ws.Cells(i, 2).Value - Z)
Z = ws.Cells(i, 2).Value
T = Tp
Else
Zp = Zp
If ws.Cells(i, 2).Value > Tp Then
Tp = Tp + beta * (ws.Cells(i, 2).Value - Tp)
Else
Tp = Tp
End If
End If
ws.Cells(i, 4).Value = Zp + Tp ' forecast value
Next i
' Calculate ME and MASE
Dim n As Integer
n = ws.Cells(Rows.Count, 2).End(xlUp).Row - 5 ' number of actual periods
Dim sum_abs_Z As Double
sum_abs_Z = 0
For i = 3 To n + 2
sum_abs_Z = sum_abs_Z + Abs(ws.Cells(i, 2).Value - ws.Cells(i - 1, 2).Value)
Next i
Dim MeanE As Double, MASE As Double
MeanE = WorksheetFunction.sum(ws.Range("E3:E" & n + 2)) / n
Dim sum_abs_ForecastError As Double
sum_abs_ForecastError = 0
For i = 4 To n + 2
sum_abs_ForecastError = sum_abs_ForecastError + Abs(ws.Cells(i, 2).Value -
ws.Cells(i, 4).Value)
Next i
MASE = sum_abs_ForecastError / ((1 / (n - 1)) * sum_abs_Z)
ws.Cells(n + 4, 2).Value = "ME:"
ws.Cells(n + 4, 3).Value = MeanE
ws.Cells(n + 4, 4).Value = "MASE:"
ws.Cells(n + 4, 5).Value = MASE
End Sub
Sub exponential_smoothing()
Dim alpha As Double, beta As Double
Dim forecast_es As Double, forecast_sba As Double
Dim error_es As Double, error_sba As Double
Dim Z As Double, T As Double, Z_prime As Double, T_prime As Double
Dim Z_last As Double, T_last As Double
Dim i As Long, j As Long, n As Long
Dim D() As Double, D_prime() As Double
' set values of alpha and beta
alpha = 0.4
beta = 0.4
' get number of data points
n = Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
' initialize arrays
ReDim D(n), D_prime(n)
' populate D array with data points
For i = 1 To n
D(i) = Range("A" & i).Value
Next i
' perform exponential smoothing and modified SBA forecast model
For i = 2 To n
If i <= 5 Then
' Exponential smoothing for warm-up period
forecast_es = alpha * D(i) + (1 - alpha) * D(i - 1)
Range("B" & i).Value = forecast_es
error_es = D(i) - forecast_es
Range("D" & i).Value = error_es
' Set forecast_sba to forecast_es for warm-up period
'forecast_sba = forecast_es
'Range("C" & i).Value = forecast_sba
'error_sba = D(i) - forecast_sba
'Range("E" & i).Value = error_sba
Else
' Exponential smoothing
'Z = D(i) - D(i - 1)
'T = Range("F" & i - 1).Value
' Z_prime = Z_last + alpha * (Z - Z_last)
' T_prime = T_last + beta * (Abs(Z) - T_last)
'forecast_es = D(i - 1) + T_last + Z_last
' Range("B" & i).Value = forecast_es
'error_es = D(i) - forecast_es
' Range("D" & i).Value = error_es
' Modified SBA forecast model
If D(i) > 0 Then
forecast_sba = forecast_es + Z_prime + T_prime
Else
If T >= T_last Then
T_prime = T_last + beta * (Abs(Z) - T_last)
Else
T_prime = T_last
End If
forecast_sba = forecast_es + Z_prime + T_prime
End If
Range("C" & i).Value = forecast_sba
error_sba = D(i) - forecast_sba
Range("E" & i).Value = error_sba
' update Z_last and T_last for next iteration
Z_last = Z_prime
T_last = T_prime
End If
Next i
End Sub
Sub exponential_smoothing()
Dim alpha As Double, beta As Double
Dim forecast_es As Double, forecast_sba As Double
Dim error_es As Double, error_sba As Double
Dim Z As Double, T As Double, Z_prime As Double, T_prime As Double
Dim Z_last As Double, T_last As Double
Dim i As Long, j As Long, n As Long
Dim D() As Double, D_prime() As Double
' set values of alpha and beta
alpha = 0.4
beta = 0.4
' get number of data points
n = Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
' initialize arrays
ReDim D(n), D_prime(n)
' populate D array with data points
For i = 1 To n
D(i) = Range("A" & i).Value
Next i
' perform exponential smoothing and modified SBA forecast model
For i = 2 To n
If i <= 5 Then
' Exponential smoothing for warm-up period
forecast_es = alpha * D(i) + (1 - alpha) * D(i - 1)
Range("B" & i).Value = forecast_es
error_es = D(i) - forecast_es
Range("D" & i).Value = error_es
ElseIf i = 6 Then
' Use the forecast from the 5th iteration in the 6th iteration
forecast_es = Range("B5").Value
If D(i) > 0 Then
forecast_sba = forecast_es + Z_prime + T_prime
Else
If T >= T_last Then
T_prime = T_last + beta * (Abs(Z) - T_last)
Else
T_prime = T_last
End If
forecast_sba = forecast_es + Z_prime + T_prime
End If
Range("B" & i).Value = forecast_sba
error_sba = D(i) - forecast_sba
Range("D" & i).Value = error_sba
Else
' Modified SBA forecast model
If D(i) > 0 Then
forecast_sba = forecast_es + Z_prime + T_prime
Else
If T >= T_last Then
T_prime = T_last + beta * (Abs(Z) - T_last)
Else
T_prime = T_last
End If
forecast_sba = forecast_es + Z_prime + T_prime
End If
Range("B" & i).Value = forecast_sba
error_sba = D(i) - forecast_sba
Range("D" & i).Value = error_sba
' update Z_last and T_last for next iteration
Z_last = Z_prime
T_last = T_prime
End If
Next i
End Sub
Sub exponential_smoothing()
Dim alpha As Double, beta As Double
Dim forecast_es As Double, forecast_sba As Double
Dim error_es As Double, error_sba As Double
Dim Z As Double, T As Double, Z_prime As Double, T_prime As Double
Dim Z_last As Double, T_last As Double
Dim i As Long, j As Long, n As Long
Dim D() As Double, D_prime() As Double
Dim sum_Z_diff As Double, sum_Zprime_diff As Double
Dim MASE As Double, MeanE As Double
' set values of alpha and beta
alpha = 0.4
beta = 0.4
' get number of data points
n = Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
' initialize arrays
ReDim D(n), D_prime(n)
' populate D array with data points
For i = 1 To n
D(i) = Range("A" & i).Value
Next i
' perform exponential smoothing and modified SBA forecast model
For i = 2 To n
If i <= 5 Then
' Exponential smoothing for warm-up period
forecast_es = alpha * D(i) + (1 - alpha) * D(i - 1)
Range("B" & i).Value = forecast_es
error_es = D(i) - forecast_es
Range("D" & i).Value = error_es
Else
' Modified SBA forecast model
If D(i) > 0 Then
Z_prime = Z_last + alpha * (Z - Z_last)
T_prime = T_last + beta * (T - T_last)
Else
Z_prime = Z_last
If T >= T_last Then
T_prime = T_last + beta * (T - T_last)
Else
T_prime = T_last
End If
End If
forecast_sba = forecast_es + Z_prime + T_prime
Range("B" & i).Value = forecast_sba
error_sba = D(i) - forecast_sba
Range("D" & i).Value = error_sba
' update Z_last, T_last, Z, T for next iteration
Z_last = Z_prime
T_last = T_prime
Z = D(i) - forecast_es
T = forecast_sba - forecast_es
' calculate MASE and ME
sum_Z_diff = sum_Z_diff + Abs(Z - D_prime(i - 1))
sum_Zprime_diff = sum_Zprime_diff + Abs(Z_prime - Z_last)
D_prime(i) = forecast_sba
End If
Next i
' calculate MASE and ME
MASE = sum_Z_diff / ((1 / (n - 1)) * sum_Zprime_diff)
MeanE = WorksheetFunction.sum(Range("D2:D" & n)) / n
' print MASE and ME
Range("E1").Value = "MASE"
Range("E2").Value = MASE
Range("F1").Value = "ME"
Range("F2").Value = MeanE
End Sub