deductiveZeros: Find out which variables can deductively be imputed with 0

Description Usage Arguments Details See Also Examples

Description

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.

Usage

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), ...)

Arguments

E

editmatrix or Equality constraint matrix.

x

named numeric vector. Naming is optional if E is an equality constraint matrix.

...

extra parameters to pass to deductiveZeros,matrix

b

Equality constraint constant vector

adapt

logical vector. Extra values to adapt, order must be the same as in x

nonneg

logical vector of length(x). Determines which x-values have to obey nonnegativity constraints.

roundNearZeros

Round near zero values of A before determining the sign?

tol

tolerance used for zero-rounding.

Details

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.

See Also

deduImpute, solSpace

Examples

 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

deducorrect documentation built on May 2, 2019, 3:47 p.m.