Learn R Programming

missRanger (version 2.6.1)

pmm: 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. Note that xtrain and xtest must be both either numeric, logical, or factor-valued. ytest can be of any type.

Usage

pmm(xtrain, xtest, ytrain, k = 1L, seed = NULL)

Value

Vector of the same length as xtest with values from xtrain.

Arguments

xtrain

Vector with predicted values in the training data. Must be numeric, logical, or factor-valued.

xtest

Vector as xtrain with predicted values in the test data. Missing values are not allowed.

ytrain

Vector of the observed values in the training data. Must be of same length as xtrain.

k

Number of nearest neighbours (donors) to sample from.

seed

Integer random seed.

Examples

Run this code
pmm(xtrain = c(0.2, 0.3, 0.8), xtest = c(0.7, 0.2), ytrain = 1:3, k = 1)  # c(3, 1)

Run the code above in your browser using DataLab