Implementation of equation 21 in the paper.
Arguments
- z
Z as a matrix
- x
X as a matrix
- digits
When non-NULL, output values close to whole numbers will be rounded using
digitsas input toRoundWhole.
Details
Generalized inverse is computed by ginv.
In practise, the computations can be speeded up using reduced versions of X and Z. See ReduceX.
Examples
# Same data as in the paper
z <- RegSDCdata("sec7z")
x <- RegSDCdata("sec7x")
Z2Yhat(z, x)
#> freq
#> row1_col1 4.173913
#> row2_col1 4.521739
#> row3_col1 12.000000
#> row4_col1 13.304348
#> row1_col2 9.826087
#> row2_col2 10.173913
#> row3_col2 22.000000
#> row4_col2 19.000000
#> row1_col3 32.000000
#> row2_col3 8.304348
#> row3_col3 6.695652
#> row4_col3 16.000000
#> row1_col4 30.000000
#> row2_col4 8.000000
#> row3_col4 -2.695652
#> row4_col4 7.695652
# With y known, yHat can be computed in other ways
y <- RegSDCdata("sec7y") # Now z is t(x) %*% y
fitted(lm(y ~ x - 1))
#> row1_col1 row2_col1 row3_col1 row4_col1 row1_col2 row2_col2 row3_col2 row4_col2
#> 4.173913 4.521739 12.000000 13.304348 9.826087 10.173913 22.000000 19.000000
#> row1_col3 row2_col3 row3_col3 row4_col3 row1_col4 row2_col4 row3_col4 row4_col4
#> 32.000000 8.304348 6.695652 16.000000 30.000000 8.000000 -2.695652 7.695652
IpsoExtra(y, x, FALSE, resScale = 0)
#> freq
#> row1_col1 4.173913
#> row2_col1 4.521739
#> row3_col1 12.000000
#> row4_col1 13.304348
#> row1_col2 9.826087
#> row2_col2 10.173913
#> row3_col2 22.000000
#> row4_col2 19.000000
#> row1_col3 32.000000
#> row2_col3 8.304348
#> row3_col3 6.695652
#> row4_col3 16.000000
#> row1_col4 30.000000
#> row2_col4 8.000000
#> row3_col4 -2.695652
#> row4_col4 7.695652
