accuracy of the modified unbiased forecast using the Mean Absolute Deviation (MAD) method

I'm supposed to be getting the answer 3.17 but I keep getting 86. What am I doing wrong with this code?

 #load package
library(Metrics)
library(tidyverse)
library(DescTools)
library(ggpubr)
library(InventoryAccountingWeek_1_exercise_1.7)
#define observed and predicted values
head(InventoryAccountingWeek_1_exercise_1_7)
Month <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
Forecast <- c(115, 121, 117, 104, 109, 123, 113, 115, 92, 102, 101, 108)
Demand <- c(101, 113, 99, 90, 94, 109, 106, 100, 87, 89, 92, 96)
#calculate mean absolute error between vectors
mae(Forecast, Demand)
#1. What is the mean forecast error?
# 12
# The forecast is biased because it isn't zero.
# subtract the mean forecast error from each month's forecast to make it unbiased.
# Mean-absolute deviation (MAD)
mad(Forecast)
mad(Demand)
Forecast+Demand
# define data
data <- data.frame(Demand, Forecast)
#calculate MAD for columns in data frame
sapply(data, mad)
# Calculate the accuracy of unbiased forecast using MAD
mean <- c((Forecast)/12)
mean
mean(data)
110/12
mae(Forecast, Demand)
#subtract the mae from demand for each month
accuracy <- c(101-12, 113-12, 99-12, 90-12, 94-12, 109-12, 106-12, 100-12, 87-12, 89-12, 92-12, 96-12)
accuracy
#calculate the forecast error by subtracting the demand from the unbiased forecast.
mean(accuracy) (edited)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.