Issue: Cannot forecast sales accurately using quantile regression in R. I am using rq function from "quantreg" package which is giving me warning "Result might have Non unique solutions"
Aim: I am trying to forecast hourly sales of a store using quantile regression.
Below are the columns in my source table for forecasting.
- transaction_date : sales date (input)
- hr1 to hr24 : column with hourly sales info. (24 columns) (input)
- totala : total of 24 column hr1 to hr24 (not using currently)
- location, department, sales_type: forecasting will be done for each location, sales_type and department. (used to select data)
- f1 to f24 : columns I want to forecast for each hour (24 columns) (output)
Packages Used: forecast, quantreg, Metrics
Code: I have extracted date features from transaction_date eg. weekend, week of month and also holidays (1 if it is holiday 0 for regular days).
attach(train_data) Y <- cbind(hr) X <- cbind(transation_date, Years, Months, Days, WeekDay, WeekofYear, Weekend, WeekofMonth, holidays) quantreg.all <- rq(Y ~ X, tau = seq(0.05, 0.95, by = 0.05)) prediction_train <- data.frame(predict(quantreg.all))
I have 19 models in prediction_train for each tau from 0.05 to 0.95, I select best model based on rmse value and than forecast using that tau.
transaction_date is Date type, quantreg.all is rqs class and rest are numeric.
Note: Stores are not open 24 hours, hence many hour columns will be 0 (time when store was close). Currently for most of such hours rq is predicting 0 or some negative values.
Weather does not have major impact on sales.