## Stata 15 help for mf_toeplitzsolve

```
Title

[M-5] toeplitzsolve() -- Solve linear systems using Toeplitz matrix

Syntax

real matrix toeplitzsolve(real colvector c1, |real matrix Y)

real matrix toeplitzscale(real colvector c1, real matrix Y)

real matrix _toeplitzscale(real colvector c1, real matrix Y, real
colvector v, real scalar ldet)

real matrix toeplitzchprod(real colvector c1, real matrix Z)

Description

toeplitzsolve(c1, |Y) solves T*B = Y for B, where T = Toeplitz(c1,c1').
If Y is missing _toeplitzsolve() solves the Yule-Walker equations, where
Y = c1[|2\n|].

toeplitzscale(c1, Y) computes solvelower(R,Y) using the Durbin-Levinson
algorithm.  Here T = Toeplitz(c1,c1') = R*R', R = cholesky(T).

_toeplitzscale(c1, Y, v, ldet) computes solvelower(L,Y) using the
Durbin-Levinson algorithm.  Here T = Toeplitz(c1,c1') = L*D*L', D =
diag(v), and L is lower triangular with 1's on the diagonal.

toeplitzchprod(c1, Z) computes R*Z, where R = cholesky(T) and T =
Toeplitz(c1, c1') = R*R'.

Remarks

toeplitzsolve(), toeplitzscale(), and _toeplitzchprod() are designed
specifically for time-series applications.  The column vector c1 is the
autocovariance of the process.  Elements c1[h] = cov(Y[t,j],Y[t+h-1,j]),
h = 1, ..., n-t+1, so c1[1] = var(y[t]).  Here n = length(c1) = rows(Y).

The Yule-Walker estimates of an autoregressive process are found by P =
toeplitzsolve(c1), where it is preferred that c1 be the autocorrelation
function, that is, c1[1] = 1.  toeplitzsolve() is also useful in
computing time-series forecasts; see Beran (1994, sec. 8.7).

E = _topelitzscale(c1,Y,v,ldet) is the r x c1 matrix of residuals of the
one-step predictions of Y, where columns of Y are generated from the
autoregressive process with covariance T = Toeplitz(c1,c1'); see Palma
(2007, sec. 4.1.2).  Specifically, E[t,j] = Y[t,j] -
M[t,1\t,t-1]*Y[|1,j\t-1,j|], where M = cholinv(L), but carried out
efficiently using the Durbin-Levinson algorithm.  The rows of -M contain
the autoregressive parameters of the process.  The vector v contains the
variances of the residuals and ldet is the log determinate of T.  These
are all the quantities necessary to compute the log likelihood of Y
coming from a zero mean time-series process with covariance T.

Z = topelitzscale(c1,Y) computes Z = E:/sqrt(v), where E and v are from a
call to _toeplitzscale().

If Z = rnormal(r,c1,0,1), then Y = toeplitzchprod(c1,Z) is a set of c1
independent zero mean processes of length r with covariances T =
Toeplitz(c1,c1').  Typically, c1 = 1.  R = cholesky(T) is carried out
efficiently using Shur's algorithm (Stewart 1997).

See [M-5] arfimaacf() for generating the autocovariance function, c1, for
an autoregressive (fractionally integrated) moving-average process.

Conformability

toeplitzsolve(c1, |Y):
c1:  r x 1
Y:  r x c1
result:  r x c1 or  r x 1

toeplitzscale(c1, Y):
c1:  r x 1
Y:  r x c1
result:  r x c1

_toeplitzscale(c1, Y, v, ldet):
c1:  r x 1
Y:  r x c1
v:  r x 1
ldet:  1 x 1
result:  r x c1

toeplitzchprod(c1, Z):
c1:  r x 1
Z:  r x c1
result:  r x c1

Diagnostics

None.

Source code

toeplitzsolve.mata

References

Beran, J. 1994. Statistics for Long-Memory Processes. Chapman & Hall/CRC.

Palma, W. 2007. Long-Memory Time Series: Theory and Methods. Wiley.

Stewart, M. 1997. Cholesky factorization of semi-definite Toeplitz
matrices.  Linear Algebra and its Applications 254: 497-525.

```