This function, not intended for end-users, implements the following recursions needed in computing scores with respect to regression coefficients: $$D a^{(1)}_{t+1} = D a^{(1)}_{t} + D a^{(2)}_{t} - k^{(1)}_t x_t - k^{(1)}_t D a^{(1)}_{t}$$ $$D a^{(2)}_{t+1} = a^{(2)}_{t} - k^{(2)}_t x_t - k^{(2)}_t Da^{(1)}_{t}$$ where \(a^{(1)}_{t}\), \(a^{(2)}_{t}\) are the one-step-ahead Kalman filtered state variables, and \(k^{(1)}_{t}\), \(k^{(2)}_{t}\) the respective Kalman gain elements. The symbol $D$ represent the partial derivative with respect to the regression coefficients and $x_t$ is the vector of regressors. All variables are passed by reference and, so, no output is needed.
da(k1, k2, X, A1, A2)It does not return anything as it writes on the A1 and A2 matrices passed as reference.
numeric vector of n elements with the Kalman gain sequence for the first state variable;
numeric vector of n elements with the Kalman gain sequence for the second state variable;
numeric matrix of dimension \(n\times k\) with the regressors;
numeric matrix of dimension \(n\times k\) that, after calling the function will contain the sequence of gradients \(D a^{(1)}_t\); the first row must be of zero values;
numeric matrix of dimension \(n\times k\) that, after calling the function will contain the sequence of gradients \(D a^{(2)}_t\); the first row must be of zero values;