[Rd] Wish for arima function: add a data argument and a formula-type for regressors

Olivier Renaud Olivier.Renaud at unige.ch
Tue May 16 09:47:47 CEST 2017


Using arima on data that are in a data frame, especially when adding 
xreg, would be much easier if the arima function contained

1) a "data=" argument

2) the possibility to include the covariate(s) in a formula style.

Ideally the call could be something like

 > arima(symptome, order=c(1,0,0), xreg=~trait01*mesure0, data=anxiete)

( or arima(symptome~trait01*mesure0, order=c(1,0,0), data=anxiete)       )

instead of present:

 > anxiete$interact = anxiete$trait01*anxiete$mesure0
 > arima(anxiete$symptome, order=c(1,0,0), xreg=anxiete[, c("trait01", 
"mesure0", "interact")])

Background: Especially in psychology, so-called single case analyses 
consist often in a the interaction effect of treatment and usual 
training effect, with typically arma type of error, resulting in the 
above model. Typically, all the needed data are in a data.frame .

An additional advantage concerns the names of the coefficient in the 
output: if only one regressor:

>arima(anxiete$symptome, order=c(1,0,0), xreg=anxiete[, c("trait01")]) [...]
          ar1  intercept  anxiete[, c("trait01")]
       0.5649    33.8623                  -8.1225
s.e.  0.1073     0.5969                   0.8052

but the name convention changes with several regressors:

>arima(anxiete$symptome, order=c(1,0,0), xreg=anxiete[, c("trait01", 
"mesure0", "interact")]) [...]
          ar1  intercept  trait01  mesure0  interact
       0.2715    34.1363  -5.5777   0.0075   -0.1809
s.e.  0.1211     0.6685   0.9009   0.0342    0.0490

Prof. Olivier Renaud                  http://www.unige.ch/fapse/mad/
Methodology & Data Analysis - Psychology Dept - University of Geneva
UniMail, Office 4138  -  40, Bd du Pont d'Arve   -  CH-1211 Geneva 4

	[[alternative HTML version deleted]]

More information about the R-devel mailing list