forecasting in hcsc

75
Forecasting in HCSC

Upload: others

Post on 21-Apr-2022

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Forecasting in HCSC

Forecasting in HCSC

Page 2: Forecasting in HCSC

Type of preditions

Predictions

Nu

mb

er o

f pa

tients

…relationship respect to other variables

…the historical data of the variable

Page 3: Forecasting in HCSC

Formulating relationship

between decision variables

Page 4: Forecasting in HCSC

• Pearson r Coefficient: measure the strength of the linear

association between continuous variables.

• Spearman rho Coefficient: is used to estimate the degree of

association between two ordinal variables measuring the

concordance or discordance.

• Kendall Coefficient: measures the strength of dependence

between two nominal variables with same scale.

Bivariate Analysis

Correlation

Coefficient (r)

Correlation coefficient varies from -1 (Negative Correlation) to +1 (Positive Correlation)

If Correlation coefficient is 0, there is NO Correlation or association

Page 5: Forecasting in HCSC

• Pearson r Coefficient: measure the strength of the linear

association between continuous variables.

Bivariate Analysis

Correlation

Coefficient (r)

Correlation coefficient varies from -1 (Negative Correlation) to +1 (Positive Correlation)

If Correlation coefficient is 0, there is NO Correlation or association

𝑟𝑥𝑦 =σ𝑖=1𝑛 (𝑥𝑖 − ҧ𝑥) ∙ (𝑦𝑖 − ത𝑦)

σ𝑖=1𝑛 (𝑥𝑖 − ҧ𝑥) ∙ σ𝑖=1

𝑛 (𝑦𝑖 − ത𝑦)

Example in Excel…(Pills

consumption_dataset)

Page 6: Forecasting in HCSC

YX

People will take more flu pills when the temperature growths?

Response variable or dependent variable

Independent variable

Page 7: Forecasting in HCSC

Strong a positive relationship

Strong a positive relationship

REAL STATISTICS Add ins…

Page 8: Forecasting in HCSC

Y X

… …

Is there any clear relationship…?

Page 9: Forecasting in HCSC

Regression analysis…

Page 10: Forecasting in HCSC

• Linear Regression: establishes a relationship between

dependent variable and one or more independent variables

using a best fit straight line (continuous).

• Logistics Regression: explain the relationship between

dependent binary variable and one or more (continuous)

independent variables.

• Nonlinear Regression: the relationship between the

dependent and independent parameters are not linear.

• Ordinal Regression: explains the relationship between a

dependent variable and independent variables (ordinal).

Multivariate Analysis

Regression

Analysis

Y= dependent variable

ß0 = Y intercept

ß1 = slope coefficient

X= independent variable

Page 11: Forecasting in HCSC

𝑌 = 𝛽0 + 𝛽1𝑋

Regression equation

(useful for predictions)

Least-squares method

Page 12: Forecasting in HCSC

YX

People will take more flu pills when the temperature growths?

Let's find the regression

equation…predictions…

Response variable or dependent variable

Independent variable

Page 13: Forecasting in HCSC

Strong and positive relationship…

Page 14: Forecasting in HCSC

H0: 𝑌 = 𝛽0 + 𝛽1𝑋 …𝛽1 ≈ 0H1: 𝑌 = 𝛽0 + 𝛽1𝑋 …𝛽1 ≠ 0

Result: Reject H0…regression is SIG

Rule:

If p-value <= Alpha (α) ThenReject H0

ElseAccept H0

Page 15: Forecasting in HCSC

Equation: 𝑌 = −36.3612 + 3.7379𝑋Both coefficients contribute significantly

to explain the Y´s variability

Pill_consumption = -36.3612 + 3.7379 x MAX-Temperature

Page 16: Forecasting in HCSC

Residual graphs

Page 17: Forecasting in HCSC

Assumptions (simple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution

❑ No-autocorrelation (residuals)

Page 18: Forecasting in HCSC

Assumptions (simple-reg.):

❑ Linear relationship (OK)

❑ Y ~ Normal Distribution

❑ No-autocorrelation (residuals)

Clear linear relationship…

Page 19: Forecasting in HCSC

Assumptions (simple-reg.):

❑ Linear relationship (OK)

❑ Y ~ Normal Distribution (OK)

❑ No-autocorrelation (residuals)

Anderson-Darling Test:

H0: the observed variable fits to a Normal DistributionH1: the observed variable does not fit to a Normal Distribution

P-value > 0.05 (user-defined parameter) …ThenAccept H0 (the dependent variable follows a Normal Distribution)

Page 20: Forecasting in HCSC

Assumptions (simple-reg.):

❑ Linear relationship (OK)

❑ Y ~ Normal Distribution (OK)

❑ No-autocorrelation (residuals) (OK)

1.5 < D-stat < 2.5

The assumption is met

𝑑 =σ𝑖=2𝑛 (𝑒𝑖 − 𝑒𝑖−1)

2

σ𝑖=1𝑛 𝑒𝑖

2

No auto-correlation (residuals)

Page 21: Forecasting in HCSC

Multiple regression…

Page 22: Forecasting in HCSC

Multiple regression:

𝑌 = 𝛽𝑋 + 𝜀Model:

𝑌 =

𝑌1𝑌2...𝑌𝑛

𝑋 =

1 𝑋11 𝑋12 … 𝑋1𝑏1 𝑋21 𝑋22 … 𝑋2𝑏..

.

1

.

.

.

𝑋𝑛1

.

.

.

𝑋𝑛2

.

.

.

.

.

.

𝑋𝑛𝑝

𝛽 =

𝛽0𝛽1...𝛽𝑏

𝜀 =

𝜀1𝜀2...𝜀𝑛

?

http://www.stat.ucla.edu/~hqxu/stat105/pdf/ch12.pdf

Page 23: Forecasting in HCSC

Multiple regression:

𝑌 = 𝛽𝑋 + 𝜀Model:

𝑌 =

𝑌1𝑌2...𝑌𝑛

𝑋 =

1 𝑋11 𝑋12 … 𝑋1𝑏1 𝑋21 𝑋22 … 𝑋2𝑏..

.

1

.

.

.

𝑋𝑛1

.

.

.

𝑋𝑛2

.

.

.

.

.

.

𝑋𝑛𝑝

𝛽 =

𝛽0𝛽1...𝛽𝑏

𝜀 =

𝜀1𝜀2...𝜀𝑛

መ𝛽 = (𝑋𝑇𝑋)−1𝑋𝑇𝑌Seeking the coefficients…

𝑌 = 𝑋 መ𝛽

Page 24: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution

❑ No multicollinearity in the data (X-matrix)

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)

Page 25: Forecasting in HCSC

YX2X1Linear relationship…

Page 26: Forecasting in HCSC

YX2X1Linear relationship…

Page 27: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution (YES--- α = 0.01)

❑ No multicollinearity in the data (X-matrix)

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)

Page 28: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution

❑ No multicollinearity in the data (X-matrix)

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)No significant correlation between

independent variables…OK

Page 29: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution

❑ No multicollinearity in the data (X-matrix)

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)

The variance are significantly different…

Page 30: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution

❑ No multicollinearity in the data (X-matrix)

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)

The variance are significantly different…

Z-score transformation = (x – μ) / σ

Page 31: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)

Page 32: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals – normality as well)

Variance are now equal…OK

Page 33: Forecasting in HCSC

Assumptions (multiple-reg.):

❑ Linear relationship

❑ Y ~ Normal Distribution

❑ No multicollinearity in the data (X-matrix)

❑ Homoscedasticity (X-matrix)

❑ No-autocorrelation (residuals)

You might assume that is OK…

Page 34: Forecasting in HCSC

multiple-reg (REAL STATS-Add ins):

Page 35: Forecasting in HCSC

multiple-reg:

Setting the Xs and Y

Setting the confidence level of the regression analysis

Run the whole Regression Analysis

Auto-correlation analysis…

Page 36: Forecasting in HCSC

multiple-reg:

The two independent variables explain 76% of the variance in the

dependent variable

The regression equation presents a standard error of 16 patients…

The regression is significant…meani

ng: you can use the regression equation for predictions…

Page 37: Forecasting in HCSC

multiple-reg:

Only the intercept and the relative humidity have a

significant influence on the

number of patients…

Page 38: Forecasting in HCSC

multiple-reg:

Equation (daily):Number of patients = 61.7 + 12.67*RelHumi – 5.1*MAX-temp

Page 39: Forecasting in HCSC

multiple-reg:

Equation (daily):Number of patients = 61.7 + 12.67*RelHumi – 5.1*MAX-temp

IMPORTANT: This equation works only with z-scores of independent variables…

Page 40: Forecasting in HCSC

multiple-reg:

Equation (daily):Number of patients = 61.7 + 12.67*RelHumi – 5.1*MAX-temp

IMPORTANT: This equation works only with z-scores of independent variables…

Prediction example…predict the number of patients in a day where the maximum temperature was 25 Celsius and we had 50% relative humidity…

Z-score transformation = (x – μ) / σ

𝑍𝑚𝑎𝑥𝑇𝑒𝑚 =𝟐𝟓 − 21.57

18.88= 0.79

𝑍𝑟𝑒𝑣𝐻𝑢𝑚 =𝟓𝟎 − 53.29

74.37= −0.4

Number of patients = 61.7 + 12.67*(-0.4) – 5.1*(0.79) = 52.6 ≈ 53 patients

Page 41: Forecasting in HCSC

Time series analysis…

Page 42: Forecasting in HCSC

Type of preditions

Predictions

Nu

mb

er o

f pa

tients

…relationship respect to other variables

…the historical data of the variable

Page 43: Forecasting in HCSC

Time series:

Page 44: Forecasting in HCSC

Time series:

Page 45: Forecasting in HCSC

Time series:

Type of Series

Stationary

Non-stationary

Page 46: Forecasting in HCSC

Time series:

Constant trend

Page 47: Forecasting in HCSC

Time series:

homogeneousvariance

Page 48: Forecasting in HCSC

Time series:

Autocovariance

Page 49: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑Moving Average (MA)

❑Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

The more useful for realistic datasets

Page 50: Forecasting in HCSC

Time series:

Page 51: Forecasting in HCSC

Time series:

Autocovariance

Clearly a non-stationary series…

Page 52: Forecasting in HCSC

Time series:

Page 53: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Page 54: Forecasting in HCSC

Time series:

❑ Moving Average (MA)

User-defined parameter(s): n

Page 55: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

Two(2) moving periods…

Forecasting one next period only

Range of observed variables, syringe consumption, over time…

Print the results starting from the indicated cell…

Page 56: Forecasting in HCSC

Time series:

Page 57: Forecasting in HCSC

Time series: The algorithm performance indicators…

Methods for non-stationary time series:

❑ Moving Average (MA)❑ Errors…

𝑴𝑨𝑬 =𝟏

𝒏

𝒕=𝟏

𝒏

𝑨𝒕 − 𝑭𝒕Mean Absolute Error(MAE)

Mean Squared Error(MSE) 𝑴𝑺𝑬 =𝟏

𝒏

𝒕=𝟏

𝒏

𝑨𝒕 − 𝑭𝒕𝟐

Optimum

≈ 𝟎

Mean Absolute Percentage

Error(MAPE)

𝑴𝑺𝑬 =𝟏𝟎𝟎

𝒏

𝒊=𝟏

𝒏𝑨𝒕 − 𝑭𝒕𝑨𝒕

≈ 𝟎

𝒆𝒕 = 𝑨𝒕 − 𝑭𝒕

≈ 𝟎

Error = 27 – 24 = 3

Page 58: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)…3 moving periods…

MA-3 performance is worst compared to MA-2…

Learning: One can make more accurate predictions using MA-2

Page 59: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Page 60: Forecasting in HCSC

Time series:

The weights should be defined in a column…

Two(2) moving periods

Page 61: Forecasting in HCSC

Time series:

Page 62: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Page 63: Forecasting in HCSC

Time series:

How do we optimize this user-defined parameter in order to reach the best possible MAE?

How do we optimize this user-defined parameter in order to reach the best possible MAE?

Let alpha as “zero”…it will be optimize

Page 64: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Best MAE so far…!

Page 65: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Real Stat assumes:

b1 = 0F1 = emptyBetter results…

Two(2) user-defined parameters:Alpha and Beta

Page 66: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Let it as zeroLet it as zero

Optimizing the MAE…

Page 67: Forecasting in HCSC

Time series:

Very similar to the SES…due to there is no trend (+ or -) within the dataset…DES would performs better when data exhibits certain trend…

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Page 68: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Three parameters…alpha, beta and gamma

Seasonality is new

Seasonality: it is traditionally defined by the number of observations within a year…

Page 69: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

There are 12 observations every year

Page 70: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

12 observations during each revised year…

Page 71: Forecasting in HCSC

Time series: Forecasting start right after the first “s” cycle (13th

observation)

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Better that SES and DES

Page 72: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

The forecasting equation is formed by the multiplication of the series components…

Page 73: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Best performance reached

Page 74: Forecasting in HCSC

Time series:

Methods for non-stationary time series:

❑ Moving Average (MA)

❑ Weighted Moving Average (WMA)

❑ Simple Exponential Smoothing (SES)

❑ Double Exponential Smoothing (DES) (Holt´s Method)

❑ Holt Winter´s Additive (HWA)

❑ Holt Winter´s Multiplicative (HWM)

Page 75: Forecasting in HCSC

Thanks...

Erasmus+ KA2 Strategic Partnership2017-1-1FI01-KA203-034721Healthcare Logistics Education and Learning Pahtway