Solved – How to test whether covariates are significant with “xreg=” and “auto.arima()” (Error message)

arimaerror messagepredictorrtime series

I have 10 separate time series with one response variable (#users) and 4 predictor (dummy) variables (discount, feature_update, non_feature_update, bugfix). One exemplary time series looks like this:

date;max_players;discount;feature_update;non_feature_update;bugfix
    2016-08-25;550787;0;0;0;0
    2016-08-26;544806;0;0;0;0
    2016-08-27;536004;0;0;0;0
    2016-08-28;546000;0;0;0;0
    2016-09-01;515410;0;0;0;0
    2016-09-02;515410;0;0;0;0
    2016-09-03;557799;0;0;0;0
    2016-09-04;573314;0;0;0;0
    2016-09-05;574341;0;0;0;0
    2016-09-06;572226;0;0;0;0
    2016-09-07;530141;0;0;0;0
    2016-09-08;544146;0;0;0;0
    2016-09-09;525664;0;0;1;0
    2016-09-10;571421;0;0;0;0
    2016-09-11;600316;0;0;0;0
    2016-09-12;596331;0;0;0;0
    2016-09-13;539819;0;0;0;0
    2016-09-14;528193;0;0;0;1
    2016-09-15;530805;0;0;0;0
    2016-09-16;530380;0;0;1;0
    2016-09-17;588619;0;0;0;0
    2016-09-18;638360;0;0;0;0
    2016-09-19;637515;0;0;0;0
    2016-09-20;564818;0;0;0;0
    2016-09-21;558376;0;0;1;0
    2016-09-22;553994;0;0;0;0
    2016-09-23;555269;0;0;0;0
    2016-09-24;601253;0;0;0;0
    2016-09-25;613028;0;0;0;0
    2016-09-26;609126;0;0;0;0
    2016-09-27;540141;0;0;0;0
    2016-09-28;538047;0;0;1;0
    2016-09-29;544434;0;0;0;0
    2016-09-30;548141;0;0;0;0
    2016-10-01;590230;0;0;0;0
    2016-10-02;613097;0;0;0;0
    2016-10-03;598950;0;0;0;0
    2016-10-04;559436;0;0;0;0
    2016-10-05;552031;0;0;0;0
    2016-10-06;556320;0;1;0;0
    2016-10-07;554221;0;0;0;0
    2016-10-09;646334;0;0;0;0
    2016-10-10;628981;0;0;1;0
    2016-10-11;584079;0;0;1;0
    2016-10-12;573494;0;0;1;0
    2016-10-13;590436;0;0;1;0
    2016-10-14;584281;0;0;0;0
    2016-10-15;632559;0;0;0;0
    2016-10-16;661985;0;0;0;0
    2016-10-17;646283;0;0;0;0
    2016-10-18;565030;0;0;0;0
    2016-10-19;552751;0;0;0;0
    2016-10-20;564004;0;0;0;0
    2016-10-21;561903;0;0;0;0
    2016-10-22;623083;0;0;0;0
    2016-10-23;647299;0;0;0;0
    2016-10-24;624196;0;0;0;0
    2016-10-25;564167;0;0;1;0
    2016-10-26;548445;0;0;0;0
    2016-10-27;543803;0;0;0;0
    2016-10-28;550837;0;0;0;1
    2016-10-29;591304;0;0;0;0
    2016-10-30;612910;0;0;0;0
    2016-10-31;613226;0;0;0;0
    2016-11-04;596301;0;0;0;0
    2016-11-05;599240;0;0;0;0
    2016-11-06;627124;0;0;0;0
    2016-11-07;611584;0;0;0;0
    2016-11-08;532334;0;0;0;0
    2016-11-09;539366;0;0;0;0
    2016-11-10;526953;0;0;0;0
    2016-11-11;539705;0;0;0;0
    2016-11-12;598838;0;0;0;0
    2016-11-13;626360;0;0;0;0
    2016-11-14;609295;0;0;0;0
    2016-11-15;541529;0;0;0;0
    2016-11-16;546602;0;0;0;0
    2016-11-17;529147;0;0;0;0
    2016-11-18;528129;0;0;0;0
    2016-11-19;595119;0;0;0;0
    2016-11-20;617652;0;0;0;0
    2016-11-21;601809;0;0;0;0
    2016-11-22;541586;0;0;0;0
    2016-11-23;547539;1;0;0;0
    2016-11-24;555683;1;0;0;0
    2016-11-25;558932;1;0;0;0
    2016-11-26;611117;1;0;0;0
    2016-11-27;625876;1;0;0;0
    2016-11-28;608906;1;1;0;0
    2016-11-29;540550;1;0;0;1
    2016-11-30;578490;0;0;0;0
    2016-12-01;575494;0;0;0;0
    2016-12-02;574372;0;0;0;0
    2016-12-03;632999;0;0;0;0
    2016-12-04;662460;0;0;0;0
    2016-12-05;637935;0;0;0;0
    2016-12-06;562748;0;0;0;0
    2016-12-07;569392;0;0;1;0
    2016-12-08;567637;0;0;1;0
    2016-12-09;521844;0;0;0;0
    2016-12-10;575434;0;0;0;0
    2016-12-11;603615;0;0;0;0
    2016-12-12;582266;0;0;0;0
    2016-12-13;515906;0;1;0;0
    2016-12-14;510000;0;0;0;1
    2016-12-15;512679;0;0;0;0
    2016-12-16;513677;0;0;0;0
    2016-12-17;558715;0;0;0;0
    2016-12-18;586213;0;0;0;0
    2016-12-19;567955;0;0;0;0
    2016-12-20;549755;0;0;0;0
    2016-12-21;548122;0;0;0;0
    2016-12-22;557662;1;0;0;0
    2016-12-23;556800;1;0;0;0
    2016-12-24;556800;1;0;0;0
    2016-12-25;556800;1;0;0;0
    2016-12-26;556800;1;0;0;0
    2016-12-27;556800;1;0;0;0
    2016-12-28;464514;1;0;0;0
    2016-12-29;600307;1;0;0;0
    2016-12-30;608579;1;0;0;0
    2016-12-31;617489;1;0;0;0
    2017-01-01;527325;1;0;0;0
    2017-01-02;586605;0;0;0;0
    2017-01-03;533340;0;0;0;0
    2017-01-04;615247;0;0;0;0
    2017-01-05;614587;0;0;0;0
    2017-01-06;620470;0;0;0;0
    2017-01-07;652854;0;0;0;0
    2017-01-08;672549;0;0;0;0
    2017-01-09;658198;0;0;0;0
    2017-01-10;590818;0;0;0;0
    2017-01-11;593498;0;0;0;0
    2017-01-12;583741;0;0;1;0
    2017-01-13;592038;0;0;0;0
    2017-01-14;643886;0;0;0;0
    2017-01-15;688978;0;0;0;0
    2017-01-16;663907;0;0;0;0
    2017-01-17;640165;0;0;0;0
    2017-01-18;614374;0;0;0;0
    2017-01-21;654320;0;0;0;0
    2017-01-22;682619;0;0;0;0
    2017-01-23;792739;0;0;0;0
    2017-01-24;730879;0;0;0;0
    2017-01-25;707397;0;0;0;0
    2017-01-26;720396;0;0;0;0
    2017-01-27;684720;0;0;0;0
    2017-01-28;735876;0;0;0;0
    2017-01-29;786654;0;0;0;0
    2017-01-30;814616;0;0;0;0
    2017-01-31;701556;0;0;0;0
    2017-02-02;681715;0;0;0;0
    2017-02-03;679929;0;0;1;0
    2017-02-04;704161;0;0;0;0
    2017-02-05;742866;0;0;0;0
    2017-02-06;723039;0;0;0;0
    2017-02-07;652628;0;0;0;0
    2017-02-08;645809;0;0;0;0
    2017-02-10;663594;0;0;0;0
    2017-02-11;705889;0;0;0;0
    2017-02-12;744468;0;0;0;0
    2017-02-13;734782;0;0;0;0
    2017-02-14;649498;0;0;1;0
    2017-02-15;608329;0;0;0;0
    2017-02-16;631995;0;0;0;1
    2017-02-17;632130;0;0;0;0
    2017-02-18;692524;0;0;0;0
    2017-02-19;704709;0;0;0;0
    2017-02-20;714208;0;0;0;0
    2017-02-21;673810;0;0;0;0
    2017-02-22;651005;0;0;0;0
    2017-02-23;669172;0;0;0;0
    2017-02-24;633032;0;0;0;0
    2017-02-25;686376;0;0;0;0
    2017-02-26;716121;0;0;0;0
    2017-02-27;691565;0;0;0;0
    2017-02-28;628780;0;0;0;0
    2017-03-01;638415;0;0;0;0
    2017-03-02;626142;0;0;0;0
    2017-03-03;613269;0;0;0;0
    2017-03-04;686031;0;0;0;0
    2017-03-05;715449;0;0;0;0
    2017-03-06;670904;0;0;0;0
    2017-03-07;615829;0;0;0;0
    2017-03-08;657426;0;0;0;0
    2017-03-09;621064;0;0;0;0
    2017-03-10;610761;0;0;0;0
    2017-03-11;680655;0;0;0;0
    2017-03-12;717597;0;0;0;0
    2017-03-13;702023;0;0;0;0
    2017-03-14;620293;0;0;0;0
    2017-03-15;623902;0;0;1;0
    2017-03-16;617890;0;0;0;0
    2017-03-17;672521;0;0;1;0
    2017-03-18;723042;0;0;0;0
    2017-03-19;742356;0;0;0;0
    2017-03-20;736773;0;0;0;1
    2017-03-22;632408;0;0;0;0
    2017-03-23;644436;0;0;0;0
    2017-03-24;632808;0;0;1;0
    2017-03-25;707789;0;0;0;0
    2017-03-26;718526;0;0;0;0
    2017-03-27;726242;0;0;0;0
    2017-03-28;646662;0;0;0;0
    2017-03-29;628450;0;1;0;0
    2017-03-30;635783;0;0;0;0
    2017-03-31;634066;0;0;0;0
    2017-04-01;691424;0;0;0;0
    2017-04-02;709841;0;0;0;0
    2017-04-03;685747;0;0;0;0
    2017-04-04;610638;0;0;0;0
    2017-04-05;591525;0;0;0;0
    2017-04-06;603084;0;0;0;0
    2017-04-07;606153;0;0;0;0
    2017-04-08;671237;0;0;0;0
    2017-04-09;695028;0;0;0;0
    2017-04-10;653292;0;0;0;0
    2017-04-11;623083;0;0;0;0
    2017-04-12;611705;0;0;1;0
    2017-04-13;621878;0;0;0;0
    2017-04-14;632507;0;0;0;0
    2017-04-15;678017;0;0;0;0
    2017-04-16;662140;0;0;0;0
    2017-04-17;643858;0;0;0;0
    2017-04-18;648328;0;0;0;0
    2017-04-19;622811;0;0;0;0
    2017-04-20;619212;0;0;1;0
    2017-04-21;626863;0;0;0;0
    2017-04-22;695991;0;0;0;0
    2017-04-23;708468;0;0;0;0
    2017-04-24;678710;0;0;0;0
    2017-04-25;604982;0;0;1;0
    2017-04-26;596141;0;0;0;0
    2017-04-27;583886;0;0;0;0
    2017-04-28;588990;0;0;0;0
    2017-04-29;656297;0;0;0;0
    2017-04-30;657033;0;0;0;0
    2017-05-01;658518;0;0;0;0
    2017-05-02;624256;0;0;0;1
    2017-05-03;580736;0;0;0;1
    2017-05-04;581236;0;0;0;0
    2017-05-05;571557;0;0;0;0
    2017-05-06;625281;0;0;0;0
    2017-05-07;646923;0;0;0;0
    2017-05-08;651658;0;0;0;0
    2017-05-09;602298;0;0;0;0
    2017-05-10;581682;0;0;0;0
    2017-05-11;574345;0;0;0;0
    2017-05-12;572559;0;0;1;0
    2017-05-13;629636;0;0;0;0
    2017-05-14;637449;0;0;0;0
    2017-05-15;598319;0;0;0;0
    2017-05-16;545741;0;0;0;0
    2017-05-17;543021;0;0;0;0
    2017-05-18;531927;0;0;1;0
    2017-05-19;552581;0;0;0;0
    2017-05-20;584163;0;0;0;0
    2017-05-21;609379;0;0;0;0
    2017-05-22;589513;0;0;0;0
    2017-05-23;546107;0;0;1;0
    2017-05-24;558359;0;0;0;1
    2017-05-25;692966;0;0;0;0
    2017-05-26;648271;0;0;0;1
    2017-05-27;644099;0;0;0;0
    2017-05-28;634579;0;0;0;0
    2017-05-29;658696;0;0;0;0
    2017-05-30;623180;0;0;0;1
    2017-05-31;596527;0;0;0;0
    2017-06-01;610675;0;0;0;0
    2017-06-02;587333;0;0;0;0
    2017-06-03;594458;0;0;0;0
    2017-06-04;596892;0;0;0;0
    2017-06-05;614621;0;0;0;0
    2017-06-06;607887;0;0;0;1
    2017-06-07;589592;0;0;0;0
    2017-06-08;588571;0;0;0;1
    2017-06-10;559019;0;0;0;0
    2017-06-11;550924;0;0;0;0
    2017-06-12;568688;0;0;0;0
    2017-06-13;559171;0;1;0;0
    2017-06-14;556769;0;0;0;0
    2017-06-15;553916;0;0;0;0
    2017-06-16;569006;0;1;0;0
    2017-06-17;547096;0;0;0;0
    2017-06-18;542343;0;0;0;0
    2017-06-19;560055;0;0;0;1
    2017-06-20;540780;0;0;0;1
    2017-06-23;534468;1;0;0;0
    2017-06-24;512874;1;0;0;0
    2017-06-25;511465;1;0;0;0
    2017-06-26;553576;1;0;0;0
    2017-06-27;552073;1;0;0;1
    2017-06-28;546514;1;0;0;0
    2017-06-29;543096;1;0;0;0
    2017-06-30;537716;1;0;0;0

Due to a previous post you helped me to understand that I should build a regression with arma errors "https://robjhyndman.com/hyndsight/arimax/" or a transfer function model. My goal is to make a statement whether one of the exogenous dummy variables has an significant impact on the time series or not.

I started to work on a R script that is inspired by How to setup xreg argument in auto.arima() in R?. I use auto.arima() to approx. a model of the series by including the xreg= argument. xreg= contains a matrix of the exogenous variables.

The script looks as follows:

#load forecast package
library(forecast)

#load one dataset per game ("g")
g <- read.csv("C:[...].csv", header = TRUE, sep = ";")

#generate time series objects for "number of users" and predictor variables

user = ts(g$max_players) #y

discount <- ts(g$discount) #x1

feature_update <- ts(g$feature_update) #x2

non_feature_update <- ts(g$non_feature_update) #x3

bugfix <- ts(g$bugfix) #x4

#build a matrix "X" containing "xi"

X <- matrix(c(discount, feature_update, non_feature_update, bugfix), nrow = length(discount))


#check "user" for seasonality by generating ACF and PACF graph

tsdisplay(user, main = "User TS (Observed)")

#generate auto.arima model and take seasonality into account.

user_mod <- auto.arima(user, seasonal = TRUE, xreg = X)

#print model description
user_mod

#visualize observed and model values

plot(user, col = "red", type = "p", main = "Model vs. Actual")
lines(fitted(user_mod))

#check residuals

tsdiag(user_mod, gof.lag = 20) #make sure that Ljung-Box p-value is bigger than 95% conf+
                                #make sure that ACF residuals are within 95% conf.

#apply Ljung-Box Test to the residuals for 50 lags
Box.test(user_mod$residuals, lag = 50, type = "Ljung-Box")

I tested the script for 5 of my ts which always resulted in the same error:

Error in auto.arima(user, seasonal = TRUE, xreg = X) :
No suitable ARIMA model found

My questions are:

  1. Is the error caused by a mistake in the script (technical), a misunderstanding of the concept (theory) or does the error mean that there is no significant impact of x on y.
  2. How could I alter the script to come to a solution that shows for each x whether it is significant or not?

Best Answer

It seems that I was able to solve the issue by adding the nrow= and ncol= parameter to the matix() function. The rows need to have the lenght of the ts and each exogenous variable equals one column:

X <- matrix(c(discount, feature_update, non_feature_update, bugfix), nrow = 295, ncol = 4)

This change in combination with colrename() led to the following exemplary result for auto.arima( [...], xreg = X):

Series: user 
Regression with ARIMA(5,1,0) errors 

Coefficients:
          ar1      ar2      ar3      ar4      ar5   discount  feature_update  non_feature     bugfix
      -0.0548  -0.5245  -0.3129  -0.2969  -0.4131  -368.7454       -447.6808    -104.3459  -172.6037
s.e.   0.0532   0.0513   0.0562   0.0510   0.0538  1126.3988        676.8783     584.7867   636.2311

sigma^2 estimated as 28067576:  log likelihood=-2934.58
AIC=5889.16   AICc=5889.94   BIC=5926

Training set error measures:
                   ME     RMSE      MAE        MPE     MAPE      MASE       ACF1
Training set 240.7161 5207.315 3833.528 -0.1999951 6.955508 0.7603703 0.01612563

Regardless of the result's quality I get the covariates as part of the model.

Related Question