# AR(1) Process first term

I'm trying to generate a very simple AR(1) Process with Mathematica using the ARProcess[] function. The process must have the following format:

$Y_t = \alpha + \beta Y_{t−1} + ϵ_t$

However, after reading the Mathematica help file and some posts about ARProcess[] at MMA.SE, I couldn't find a way to correctly generate the process. I seems that the ARProcess[] function cannot deal with the $\alpha$ term of the process.

For instance, consider the process described below:

$Y_t = 10 + .6Y_{t−1} + ϵ_t$ , where $ϵ_t$ is Normally distributed with mean $0$ and variance $4$ (i.e., $ϵ_t \sim N(0,2)$).

If I use ARProcess[{.6},4] I get

Mean[ARProcess[{.6}, 4][t]]
Variance[ARProcess[{.6}, 4][t]]


Out[1]= 0

Out[2]= 6.25

which are consistent with an AR(1) process of the form $Y_t = 0 + .6Y_{t−1} + ϵ_t$

I would like to be able to, though the ARProcess[] function, calculate the mean and the variance of the process $Y_t = 10 + .6Y_{t−1} + ϵ_t$ in order to get a Mean of $25$ and a Variance of $6.25$.

Is there any way to achieve this in Mathematica?

• @Fred it does't work... what you've suggested works like an AR(2) Process of the form $Y_t=0+10 Y_{t-1} + .6 Y_{t-2} + \epsilon_t$, which is not stationary and, as such, the mean cannot be computed. – Rod May 20 '13 at 1:26
• Sorry, I'm deleting the comment and will delete this one later. – Fred Kline May 20 '13 at 1:44
• Don't worry @Fred... I think it's somehow a bug in Mathematica... – Rod May 20 '13 at 1:47
• One other thought, is there a way to get the $10$ into the function? – Fred Kline May 20 '13 at 2:04
• Ahah... That's exactly what I'm trying to figure out! I think it's not possible and, as such, it could be a bug in Mathematica... – Rod May 20 '13 at 2:05

The command ARProcess requires that the input term $e_t$ be a zero mean white noise with a specified variance. What you are trying to do is to have your input term be $10+e_t$ which is clearly not zero mean.

What you can do is to change variables. In your case, if you define a new process $z_t=y_t - 25$ then it will be the same as the $y_t$ process. To see this, consider the "new" problem:

$z_t = 0.6 z_{t-1} + \epsilon_t$

Substituting the definition of $z_t$ gives

$(y_t -25) = 0.6 (y_{t-1}-25) + \epsilon_t$

which, when rearranged is

$y_t = 0.6 y_{t-1} + 10 + \epsilon_t$.

which is the same as your orignal problem. This kind of thing is called "shifting the process". So the way to handle this is to work in the $z$ variable, get whatever answer you are looking for, and then at the very end shift back to $y$ via $y_t=z_t+25$.

Accordingly, you can use

varz = Variance[ARProcess[{.6}, 4][t]]


to get the variance of the $z$ process and

meanz = Mean[ARProcess[{.6}, 4][t]]


to get the mean of the $z$ process. Your original $y$ process has the same variance varz, and mean 25+meanz.

• I explicitly wrote that $\epsilon_t \sim N(0,2)$, i.e., $\epsilon_t$ has $0$-mean (and not 10!). The AR(1) process has mean equal to $25$ and can accept an $\alpha$-term (in this case, 10) per definition. The problem is exactly that: the ARProcess[] doesn't accept this $\alpha$-term. BTW, the $\alpha$-term has no influence on the $\epsilon_t$ mean... – Rod May 20 '13 at 11:38
• The above shows you how to use the Mathematica command ARProcess to act like an AR(1) process with nonzero mean. You cannot enter (as far as I know) a nonzero-mean input into ARProcess. But the point is: you don't need to. You can do the same thing by redefining your terms -- as shown above. There is no bug. – bill s May 20 '13 at 11:49
• So what is the point in using Mean[ARProcess[]] if the result will be always zero? I mean, if the ARProcess[] function cannot deal with an $\alpha$-term, its much better to develop an AR function by yourself instead of using Mathematica's ARProcess[]... – Rod May 20 '13 at 12:25
• You said "You cannot enter (as far as I know) a nonzero-mean input into ARProcess"... so, this must be a bug, don't you think? Imagine two different processes: 1) $Y_t=10+Y_{t-1}+\epsilon_t$ and 2) $Y_t=0+Y_{t-1}+\epsilon_t$; they are clearly different but if you try to estimate both processes with EstimatedProcess[data, ARProcess[1]] you will get exactly the same result, which is not consistent with one of the processes... so I'm getting wrong results if I use Mathematica-ARProcess... – Rod May 20 '13 at 13:16
• I don't think the documentation is clear about removing the mean... the shift operator E in the Details uses 1 instead of an $a_0$-term. In the Applications part there is a single example (daily exchange rates of the euro to the dollar) where it removes the mean and then add it back for forecasting... I don't think an example is clear enough for defining the function... – Rod May 20 '13 at 14:09