align_arc: Match/align arhetypes

Description Usage Arguments Details Value Examples

View source: R/align_arc.R

Description

align_arc() matches archetypes in arc2 to arc1 by solving a bipartite matching problem on euclidian distances between archetypes.

gen_permut() used for exhaustive search generates a matrix of all possible permutations of n elements. Each row is a different permutation.

Usage

1
2
3
align_arc(arc1, arc2, type = c("lpsolve", "exhaustive")[1])

gen_permut(n)

Arguments

arc1

reference matrix of archetype positions dim(dimensions, archetypes)

arc2

matrix of archetype positions dim(dimensions, archetypes) to be aligned with arc1

type

method for finding matching vertices. Linear programming (lpsolve) or exhaustive search (do not use for more than 10 vertices)

n

number of element to permute

Details

gen_permut() function is taken from https://stackoverflow.com/questions/11095992/generating-all-distinct-permutations-of-a-list-in-r

Value

align_arc() list containing: total distance between archetypes in arc1 and arc2 (dist), integer vector specifying indices of archetypes in arc2 that match archetypes in arc1 (ind)

gen_permut() a matrix of all possible gen_permut (in rows)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Generate data
set.seed(4355)
archetypes = generate_arc(arc_coord = list(c(5, 0), c(-10, 15), c(-30, -20)),
                          mean = 0, sd = 1)
data = generate_data(archetypes$XC, N_examples = 1e4, jiiter = 0.04, size = 0.9)
dim(data)
# fit polytopes to 2 subsamples of the data
arc_data = fit_pch_bootstrap(data, n = 2, sample_prop = 0.65, seed = 2543,
                        order_type = "align", noc = as.integer(6),
                        delta = 0, type = "s")
# align archetypes
align_arc(arc_data$pch_fits$XC[[1]], arc_data$pch_fits$XC[[2]])

vitkl/ParetoTI documentation built on Feb. 11, 2020, 1:36 a.m.