Description Usage Arguments Value Note on inequality restrictions See Also Examples

Apply the successive projection algorithm to adjust each record in
`dat`

to satisfy a set of linear (in)equality constraints.

1 2 | ```
match_restrictions(dat, restrictions, adjust, weight = rep(1, ncol(dat)),
remove_tag = TRUE, ...)
``` |

`dat` |
A |

`restrictions` |
An object of class |

`adjust` |
(optional) A |

`weight` |
A weight vector of length |

`remove_tag` |
if a value position indicator is present, remove it? |

`...` |
arguments passed to |

`dat`

, with values adapted.

All inequality restrictions of the form *a.x < b* are treated as *a.x ≤q b*.
The idea is to project the original record *x* onto the boundary defined by
the (in)equations. Projection on a boundary defined by a strict inequation is
illdefined sice the value *b* in the restriction *a.x < b* is strictly
outside the valid region.

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 | ```
# a very simple adjustment example
v <- validate::validator(
x + y == 10,
x > 0,
y > 0
)
# x and y will be adjusted by the same amount
match_restrictions(data.frame(x=4,y=5), v)
# One of the inequalies violated
match_restrictions(data.frame(x=-1,y=5), v)
# Weighted distances: 'heavy' variables change less
match_restrictions(data.frame(x=4,y=5), v, weight=c(100,1))
# if w=1/x0, the ratio between coefficients of x0 stay the same (to first order)
x0 <- data.frame(x=4,y=5)
x1 <- match_restrictions(x0, v, weight=1/as.matrix(x0))
x0[,1]/x0[,2]
x1[,1] / x1[2]
# example of tag usage
v <- validate::validator(x + y == 1, x>0,y>0)
d <- data.frame(x=NA,y=0.5)
d <- tag_missing(d)
# impute
d[1,1] <- 1
# only the tagged values will be altered. The tag is
# removed afterwards.
match_restrictions(d,v)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.