Learn R Programming

relations (version 0.6-13)

impute: Impute relations

Description

Impute missing incidences in relations by averaging all possible completions within a specified family.

Usage

relation_impute(x, method = NULL, control = list(), ...)

Value

If x is an ensemble or more than one solution is requested using the n control argument: an ensemble of endorelations. An endorelation otherwise.

Arguments

x

an endorelation or an ensemble of endorelations.

method

character string specifying the method to be used (see Details). If NULL, it is guessed from the relation with missing objects removed.

control

named list of control arguments. Currently, only n is accepted by the any/F methods, indicating the number of solutions to be returned. Default is 1; "all" or NA will generate all possible completions. Note that n is currently ignored if x is a relation ensemble.

...

named list of control arguments, overriding the ones in control.

Details

Endorelations with missing elements (i.e., whose incidence is NA) are imputed using one of the methods described as follows.

"omit"

Missing incidences are replaced by zeros, i.e., the corresponding elements are removed from the graph.

"any/F"

The incidences are replaced by arbitrary values suitable for family F, with possible values:

G

General (unrestricted) relations.

L

Linear orders.

W

Weak orders.

O

Partial orders.

L, W, and O can optionally be complemented by /first or /last to further restrict imputed elements to be placed on top or bottom of the given ordering.

"average/F"

Computes the relation with average incidences, based on all possible completions as indicated for the any/F methods. Note that these completions are not explicitly generated to compute the averages, and that the resulting relation will typically be fuzzy.

Examples

Run this code
## create a relation with a missing object
R <- ranking(1:2, 1:3)
print(R)
R <- as.relation(R)

## find all suitable completions within L
ens <- relation_impute(R, method = "any/L", n = "all")
lapply(ens, as.ranking)
if(require("Rgraphviz")) plot(ens)

## find 3 suitable partial orders
ens <- relation_impute(R, method = "any/O", n = 3)
lapply(ens, relation_incidence)
if(require("Rgraphviz")) plot(ens)

## compute average completion
R1 <- relation_impute(R, method = "average/O")
relation_incidence(R1)

## check correctness of averaging
R2 <- mean(relation_impute(R, "any/O", n = "all"))
stopifnot(all.equal(R1, R2))

Run the code above in your browser using DataLab