[R-SIG-Finance] ARIMA, xreg and intercepts

Brecknock, Peter Peter.Brecknock at bp.com
Thu Nov 12 16:58:59 CET 2009


Brian

I have attached some code that I hope illustrates my issue.

y=c(-0.626,0.183,-0.835,1.595,0.329,-0.820,0.487,0.738,0.575,-0.305)
a=c(-0.896,0.184,1.587,-1.130,-0.080,0.132,0.707,-0.239,1.984,-0.138)
b=c(2.090,-1.199,1.589,1.954,0.004,-2.451,0.477,-0.596,0.792,0.289)
c=c(-0.383,-1.959,-0.841,1.903,0.622,1.990,-0.305,-0.090,-0.184,-1.198)

# No intercept fitted
fit = arima(y, order=c(1,1,0), xreg=cbind(a,b,c))

# Q1 - How would I fit an intercept along with explanatory variables
using the order=c(1,1,0) approach?

# My attempt ....
intercept = 1:length(y)
fit1 = arima(y, order=c(1,1,0), xreg=cbind(intercept, a, b, c))

# Q2 - What is the equivalent code to Q1 that would use order=c(1,0,0)?

# My attempt .... (gives different results to fit1)
data = ts.intersect(ts(diff(y)),ts(a),ts(b),ts(c))
fit2 = arima(data[,1], order=c(1,0,0), xreg=data[,c(2:4)])

# Q3 - Assume intercept non-significant. At that point would it make
sense to fit the following no intercept model?

fit = arima(y, order=c(1,1,0), xreg=cbind(a,b,c))


It's funny that it is considered impolite to (inadvertently) attach a
claim of confidentiality to a public mailing list but that it is not
considered impolite to publically rebuke someone for doing it! ;-)
 
Kind regards

Pete


-----Original Message-----
From: Brian G. Peterson [mailto:brian at braverock.com] 
Sent: Thursday, November 12, 2009 8:35 AM
To: Brecknock, Peter
Cc: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] ARIMA, xreg and intercepts

Rather than reposting, you might get more of a response if you followed 
the posting guide:

http://www.r-project.org/posting-guide.html

and provided a reproducible example.

It seems that from your pseudocode, you could test your own hypothesis, 
but you didn't provide data, so I can't check.  If your hypothesized 
behavior did not materialize, as seems likely, then providing the steps 
that you tried, what you expected/wanted to happen, and what happened 
instead would assist someone else who felt like helping you out.

Also, it is considered impolite to attach claims of confidentiality to a

public mailing list.

Regards,

  - Brian

Brecknock, Peter wrote:
> Re-posting from Monday .......
>
> Hi All
>
> David Stoffer describes some challenges with R's output when fitting
> ARIMA models for different orders (see Issue 2 at
> http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm). R doesn't fit an
> intercept in the model if there is any differencing. David describes a
> workaround using the xreg parameter to force R to calculate an
> intercept.
>
> Assume I have a variable y and 3 explanatory variables a, b and c. 
>
> No intercept would be produced for the model .... fit = arima(y,
> order=c(1,1,0), xreg=c(a,b,c)) 
>
> 1. If I wish to force an intercept to be output is the following
> correct?
>
> intercept = 1:length(y) 
> fit1 = arima(y, order=c(1,1,0), xreg=c(intercept, a, b, c)) 
>
> 2. If 1 is correct, is the following code equivalent?
>
> data = ts.intersect(diff(y),intercept, a,b,c)
> fit2 = arima(data[,1], order=c(1,0,0), xreg=[,c(2:5)]) 
>
> 3. If I fit 2 and find the intercept is not significant would it then
be
> correct to use the following?
>
> fit = arima(y, order=c(1,1,0), xreg=c(a,b,c)) 
>
>
> Thanks for your help
>
> Kind regards
>
> Pete
>   


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list