Description Usage Arguments Details See Also Examples
Find out which variables can deductively be imputed with 0
Interface for deductiveZeros for objects of class editmatrix. This interface
is robust for variables in x
not occuring in E
.
Suppose x is a record under linear constraints Ax=b and x≥q0. In certain cases some missing values can be imputed uniquely with zeros. For example, in the case that x_1+x_2=x_3, if x_2 is missing and x_1=x_3≥q 0, then x_2 is uniquely determined to be 0. This function returns a boolean vector indicating which of the missing values are uniquely determined to be zero.
1 2 3 4 5 6 7 8 9 | deductiveZeros(E, x, ...)
## S3 method for class 'editmatrix'
deductiveZeros(E, x, ...)
## S3 method for class 'matrix'
deductiveZeros(E, x, b, adapt = logical(length(x)),
nonneg = rep(TRUE, length(x)), roundNearZeros = TRUE,
tol = sqrt(.Machine$double.eps), ...)
|
E |
|
x |
named numeric vector. Naming is optional if |
... |
extra parameters to pass to |
b |
Equality constraint constant vector |
adapt |
logical vector. Extra values to adapt, order must be the same as in |
nonneg |
logical vector of length(x). Determines which x-values have to obey nonnegativity constraints. |
roundNearZeros |
Round near zero values of |
tol |
tolerance used for zero-rounding. |
There is some added flexibility. Users my define 'extra missings' by specifying the adapt
vector.
By default it is assumed that all values must obey the nonnegativity constraint. However this
can be determined by specifying nonneg
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # a simple example"
E <- editmatrix(c(
"x1 + x2 + x3 == xt",
"x1 >= 0", "x2>=0","x3>=0", "xt>=0"))
x <- c(x1=10,x2=NA,x3=5,xt=15)
# with deductiveZeros we get:
( I <- deductiveZeros(E,x) )
x[I] <- 0
any(violatedEdits(E,x))
# This example is taken from De Waal et al (2011) (Examples 9.1-9.2)
E <- editmatrix(c(
"x1 + x2 == x3",
"x2 == x4",
"x5 + x6 + x7 == x8",
"x3 + x8 == x9",
"x9 - x10 == x11",
"x6 >= 0",
"x7 >= 0"
))
x <- c(
x1 = 145,
x2 = NA,
x3 = 155,
x4 = NA,
x5 = 86,
x6 = NA,
x7 = NA,
x8 = 86,
x9 = NA,
x10 = 217,
x11 = NA)
# determine zeros:
I <- deductiveZeros(E,x)
# impute:
x[I] <- 0
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.