Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Forecast spending of customer

Jimnguyen94
5 - Atom

Hi everyone,

I'm new user to R and I'm struggling with forecasting the spending of customer based on the time series data set which I attached to this post. I tried to build to models: ARM and regression. With ARM model, I was able to forecast quite accurately the spending of customers on normal day. However, in both my data set and present reality, on every first day of month, due to monthly promotion, the customers' spending is always significantly higher than that on other days. Hence, with ARM models, at the moment I have not been able to forecast the customers' spending on first day of month accurately. With regression model, the predicted number for the customers' spending on first day of month was more accurate than that predicted with ARM model. However, with an R-squared of only 50%, the fluctuation of predicted values for others days is very high. Does anyone have any ideas about which is the most suitable forecasting models I should apply here? Or is there anyway to improve my models such that I can be able to forecast most accurately the customers' spending on both first day of month and normal days? I am looking for the result showing <=1% difference between the predicted number and the real number. Many thanks! 

4 REPLIES 4
Inactive User
Not applicable

For ETS, have you tried setting the trend to multiplicative?

Jimnguyen94
5 - Atom

Hi,

I did also try to forecast with an ETS model and set the trend as multiplicative but the result did not look good at all (for both normal days and and first day of month) :(

Charity_K_Wilson
10 - Fireball

Would you mind uploading your workflow?  Under the Options tab is the option to "Export" your workflow.  It will package it up nicely so that we can look at it.  I'd love to see how you are setting up your Time Series.  I'd also like to see the Linear Regression.  

 

There may be a way to use a covariate with the Time Series.  I just don't know which variables are your target variables, and which ones are the dependent variables.

Jimnguyen94
5 - Atom

I have not been able to export the workflow but hereunder is a part of it:

For Arima model:

#Train the model
d1 <- read.csv("C:/Users/ADMIN_VP/Desktop/vietnb/ts-tdg2.csv", header = TRUE)
library(MASS)
#TDG as a time series
tdgts <- ts(d1$TDG)
n <- nrow(d1)
tdgts <- tdgts[2:(n-5)]
ts.plot(tdgts)
par(mfrow = c(1,1))
acf(tdgts)
pacf(tdgts)
library(tseries)
adf.test(tdgts)

#1st model ARIMA (1,0,0)
fittdg <- arima(tdgts, order = c(1,0,0))
fittdg # ar1 and intercept significant from 0.
#Check if residuals are white noise
acf(fittdg$residuals)
pacf(fittdg$residuals)
tsdiag(fittdg)
acf(fittdg$residuals^2) #p-value in Ljung Box not greater than 0.05
pacf(fittdg$residuals^2)
plot(fittdg$residuals^2, type = "p")
#Predict future values
tdg.pred <- predict(fittdg, n.ahead = 1)
predup <- tdg.pred$pred + 1.96*tdg.pred$se
error <- (d1$TDG[n-1]-tdg.pred$pred)/d1$TDG[n-1]*100

After testing several models I will choose the one with the lowest error and apply it to forecast the spending (here is TDG) of the customers on the next five days.

Regression models:

For regression models I have spending as the outcome and my predictors are Weekend (0 and 1), Holiday (0 and 1), First day of month (0 and 1), Promotion (0 and 1) and daily figures on the remains of customer's account (my company is telecomunication company). I firtly ran stewise in order to choose the best predictors then apply it to predict the regression function. However as I mentioned, the prediction on first day of month was more ok than that predicted by using arima but prediction on normal day does not look good to me. 

Labels