pmm: Predictive Mean Matching

View source: R/pmm.R

pmmR 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. 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)

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.

Value

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

Examples

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

missRanger documentation built on Sept. 12, 2024, 7:15 a.m.