pmm.RdFor 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.
pmm(xtrain, xtest, ytrain, k = 1L, seed = NULL)Vector with predicted values in the training data. Can be of type logical, numeric, character, or factor.
Vector as xtrain with predicted values in the test data
Missing values are not allowed.
Vector of the observed values in the training data. Must be of
same length as xtrain. Missing values in either of xtrain or
ytrain will be dropped in a pairwise manner.
Number of nearest neighbours to sample from.
Integer random seed.
Vector of the same length as xtest with values from
xtrain.
pmm(xtrain = c(0.2, 0.2, 0.8), xtest = 0.3, ytrain = c(0, 0, 1)) # 0
#> [1] 0
pmm(xtrain = c(TRUE, FALSE, TRUE), xtest = FALSE, ytrain = c(2, 0, 1)) # 0
#> [1] 0
pmm(xtrain = c(0.2, 0.8), xtest = 0.3, ytrain = c("A", "B"), k = 2) # "A" or "B"
#> [1] "B"
pmm(xtrain = c("A", "A", "B"), xtest = "A", ytrain = c(2, 2, 4), k = 2) # 2
#> [1] 2
pmm(xtrain = factor(c("A", "B")), xtest = factor("C"), ytrain = 1:2) # 2
#> [1] 2