Description Usage Arguments Details Value Examples
Form all pairs of rows in X
and compute Mahalanobis
distances based on v
.
1 2 |
X |
data frame |
u |
input of interest |
v |
other inputs |
mahalanobisConstantTerm |
Weights are (1 / (mahalanobisConstantTerm + Mahalanobis distance)) |
numForTransitionStart |
number of rows to use as the start points of transitions (defaulting to 'NULL', we use all rows) |
numForTransitionEnd |
number of rows to use as potential end points of transitions (defaulting to 'NULL', we use all rows) |
onlyIncludeNearestN |
for each transition start, we only include as transition end points the nearest 'onlyIncludeNearestN' rows (defaulting to 'NULL', we use all rows) |
To help with computational constraints, you have the option
to not form pairs between all rows of X
but instead
of specify a certain number (numForTransitionStart
)
to randomly be selected as rows from which transitions
start, and another number (numForTransitionEnd
) to
be randomly selected as where transitions end. We then form
all pairs between transition-start rows and transition-end
rows.
In order to get a smaller data frame for later
manipulations (and maybe just because it's a good idea),
you can also specify onlyIncludeNearestN
, in which
case we return only the nearest onlyIncludeNearestN
transition ends for each transition start (instead of all
pairs).
a data frame with the inputs v
from the first of
each pair, u
from each half (with ".B" appended to
the second), and the Mahalanobis distances between the
pairs.
1 2 3 4 5 6 7 8 9 10 | v <- rnorm(100)
u <- v + 0.3*rnorm(100)
qplot(v,u)
X = data.frame(v=v,u=u)
pairsDF <- GetPairs(X, "v", "u")
pairsDFRow1 <- subset(pairsDF, OriginalRowNumber==1)
# When we subset to one "original row number", all of the v's are the same:
print(pairsDFRow1$v)
# ... and u's corresponding to closer v.B (the v in the second element of the pair) have higher weight:
qplot(u.B, Weight, data=pairsDFRow1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.