# How to calculate fitted values from time series transfer function model using R (TSA package)?

I have two questions related to transfer functions. The first is a general question regarding how to compute values of $Y_t$ from a rational transfer polynomial function of the form popularized by Box and Jenkins. The second is related to the arimax() function in the TSA package in R. It is my understanding that the rational transfer function can be expressed as (ignoring any noise terms):

$Y_t = \frac{\omega(B)^sB^d}{\delta(B)^r}X_t$

Lets first make it easy and assume r = 1, s = 0 and d = 0. Then the equation should simplify to:

$Y_t = \frac{\omega_0}{(1-\delta_1B^1)}X_t$ (equation 1)

My first intuition would be to multiply both sides by ${(1-\delta_1 B^1)}$ then re-arrange to solve for $Y_t$:

$Y_t = \omega_oX_t+\delta_1 Y_{t-1}$ (equation 2)

However, I've seen here and here (pg. 286) that you can express the transfer function as so:

$Y_t = \frac{\omega_0}{(1-\delta_1B^1)}X_t = \omega_o(1+\delta_1 B^1)X_t$

This would yield a different equation for $Y_t$:

$Y_t = \omega_oX_t+\delta_1\omega_o X_{t-1}$ (equation 3)

So is equation 2 the correct way to calculate $Y_t$ or is it equation 3? If $d \neq 0$, say r = 0, s = 1 and d = 1, could you re-write the equation 1 as:

$Y_t = \frac{\omega_0}{(1-\delta_1B^1)}X_{t-1}$

and then solve for $Y_t$ by one of the equations above?

Finally, for a related R question. Assuming one of the two ways above is correct for solving for $Y_t$, I would like to check the fitted values that are calculated using the arimax() function in the TSA package. I will use the Box and Jenkins sales and lead data, and use their transfer function. The arimax() function is taken from this post and gives correct coefficients:

 >library(astsa)
>library(TSA)

>d.sale <- diff(BJsales) #first difference
>center.d.sale <- d.sale - mean(d.sale) # mean centered, first difference

>mod <- arimax(center.d.sale,
order=c(0,0,1),
include.mean=TRUE,
fixed=c(NA,NA,NA,0,0,0,NA),
transfer=list(c(1,3)),
method="ML")

>mod
Coefficients:
ma1  intercept  T1-AR1  T1-MA0  T1-MA1  T1-MA2  T1-MA3
-0.4500    -0.0055  0.7253       0       0       0  4.7008
s.e.   0.0772     0.0107  0.0048       0       0       0  0.0613

>fitted(mod)[1:5]
[1]         NA         NA         NA  0.1264714  1.3631528


Now, I would like to calculate by hand the fitted values of mod. Assuming equation 1 above is correct $Y_t$ (center.d.sale) equals (again ignoring noise):

$Y_t = \omega_3X_{t-3}+\delta_1 Y_{t-1}$

If $\omega_3 = 4.7008$ and $\delta_1 = 0.7253$ then the first calculated value ($Y_4$) should be:

 >4.7008*center.d.lead[1] + 0.7253*center.d.sale[3]
-0.4922764


This is clearly not the same as the fitted value:

 >fitted(mod)[4]
0.1264714


Even including the intercept, the values aren't the same. Do you know how arimax() calculates the fitted values, or if my equation is wrong, the proper way to calculate the fitted values from the transfer function coefficients?

The way you translate equation 1 is to multiply (not divide) $(1-\delta_1B^1)$ on both sides.

$Y_t \times {(1-\delta_1B^1)} = {\omega_0}X_t$ which translates to

${(Y_t -\delta_1 B^1Y_t)} = {\omega_0}X_t$

${Y_t = {\omega_0}X_t + \delta_1 B^1Y_t}$

converting the backshift notation, $B^1Y_t = Y_{t-1}$ which leads to the following final equation:

${Y_t = {\omega_0}X_t + \delta_1Y_{t-1}}$

Equation 2 is the correct way to translate Equation 1. The reference that you cite is another way, but I find equation 2 more intuitive and straight forward and can be generalized for any model.

If r=0, s=1, d=1 then yes you could write the equation as follows

$Y_t = \frac{\omega_0}{(1-\delta_1B^1)}B^1X_{t}$ which translates to

$Y_t = \frac{\omega_0}{(1-\delta_1B^1)}X_{t-1}$

According to this website by Rob Hyndman, TSA package "is poorly writ­ten and I would not rec­om­mend using it." So please use a better software such as SAS/SPSS for transfer function modeling.

• I realized my typo after posting. I meant to say "multiply" not "divide", as that is what I did to obtain Equation 2. I will update the post. I would prefer to use R for my transfer function modeling as I don't have a SAS/SPSS license. Do you know of any other packages in R that computes transfer functions? There is the tfm1() and trm2() functions in package MTS, but this seems even more limited than the TSA package. – ken Nov 5 '15 at 14:20
• Yes, MTS is more limited, unfortunately transfer function modeling is a gap in Open source R software. – forecaster Nov 5 '15 at 16:47