| Algorithm 1 R code that applies sequential Kalman filter (KF) update with known observation constants (measurement vector) and rank deficient state covariance matrix. | |
| Input | x is (ks + ka)-by-1 design based initial estimate of state vector |
| V is (ks + ka)-by-(ks + ka) design based initial estimate of covariance matrix | |
| y is ka-by-1 conformable vector of auxiliary census constants | |
| ks is number of study variables | |
| ka is number of auxiliary variablesk = ks + ka | |
| 1 | w < − matrix(0,k,1) # initialize with k-by-1 zero vector |
| 2 | I.wh < − diag(k) # initialize with k-by-k identity matrix |
| 3 | for ( i in ka:1 ) { # i = { ka, (ka − 1), ..., 1} |
| 4 | k < − ks + i |
| 5 | if ( V[k,k] < tol ) next # tol near zero (e.g., tol = 0.0001) |
| 6 | c = 2*abs( y[i] − x[k])/V[k,k] |
| 7 | if ( c > 1 ) { # divergence constraint from Equation (A17) |
| 8 | V[1:k,k] < −V[1:k,k]*c |
| 9 | V[k,1:k] < −V[k,1:k]*c |
| 10 | } # end of divergence “if statement” |
| 11 | w[1:k] < −V[1:k,k]/V[k,k] |
| 12 | I.wh[1:k,k] < −(-w[1:k] ) # subtract vector w from k-th column |
| 13 | x[1:k] < − ( I.wh[1:k,1:k] %*% x[1:k] ) + ( w[1:k]*y[i] ) |
| 14 | V[1:k,1:k] < −I.wh[1:k,1:k] %*% V[1:k,1:k] %*% t( I.wh[1:k,1:k] ) |
| 15 | } # end of i-th iteration |
| Definitions | [a:b,c] is the matrix partition, rows a to b, column c |
| <− is the replacement operator | |
| abs(z) is the absolute value of scalar z | |
| t(A) is the transpose of matrix A | |
| %*% is the matrix multiplication operator | |
| w is the k-by-1 vector of computed optimal Kalman weights | |
| I.wh is the k-by-k matrix of complementary Kalman weights | |
| Output | x is (ks + ka)-by-1 state vector after Kalman updates with ka auxiliary variables |
| V is (ks + ka)-by-(ks + ka) covariance matrix with ka auxiliary variables | |