pmm {missRanger} | R Documentation |
Predictive Mean Matching
Description
For each value in the prediction vector xtest
, one of the closest k
values in the prediction vector xtrain
is randomly chosen and its observed
value in ytrain
is returned.
Usage
pmm(xtrain, xtest, ytrain, k = 1L, seed = NULL)
Arguments
xtrain |
Vector with predicted values in the training data. Can be of type logical, numeric, character, or factor. |
xtest |
Vector as |
ytrain |
Vector of the observed values in the training data. Must be of same
length as |
k |
Number of nearest neighbours to sample from. |
seed |
Integer random seed. |
Value
Vector of the same length as xtest
with values from xtrain
.
Examples
pmm(xtrain = c(0.2, 0.2, 0.8), xtest = 0.3, ytrain = c(0, 0, 1)) # 0
pmm(xtrain = c(TRUE, FALSE, TRUE), xtest = FALSE, ytrain = c(2, 0, 1)) # 0
pmm(xtrain = c(0.2, 0.8), xtest = 0.3, ytrain = c("A", "B"), k = 2) # "A" or "B"
pmm(xtrain = c("A", "A", "B"), xtest = "A", ytrain = c(2, 2, 4), k = 2) # 2
pmm(xtrain = factor(c("A", "B")), xtest = factor("C"), ytrain = 1:2) # 2
[Package missRanger version 2.5.0 Index]