def arma_predictor_model(x, y, m, n):
"""
Return matrix and vector relating (*m*, *n*) ARMA model to the
input *x* and output *y*. In other words, construct the max(*m*,
*n*) - 1 by (*m* - 1 + *n* - 1) matrix A such that
y[k] + a_1 y[k - 1] + ... + a_m y[k - m] = b_1 x[k - 1] + ... + b_n x[k - n]
and the vector b corresponds to y[k] for k >= max(*m*, *n*).
"""
assert len(x) == len(y)
k = max(m, n)
A1 = SP.linalg.toeplitz(-y[k:-1], r=-y[(k - m):k][::-1])
A2 = SP.linalg.toeplitz(x[k:-1], r=x[(k - n):k][::-1])
A = NP.hstack((A1, A2))
b = y[k+1:]
return A, b
评论列表
文章目录