[R] predict missing values with svm

Andreas Wittmann andreas_wittmann at gmx.de
Mon Sep 28 16:12:11 CEST 2009


Dear R-Users,

i want to use the function svm of the e1071 package to predict missing data

############################################################

data(iris)

## create missing completely at random data
for (i in 1:5)
{
  mcar <- rbinom(dim(iris)[1], size=1, prob=0.1)
  iris[mcar == 1, i] <- NA
}

ok <- complete.cases(iris)

model <- svm(Species ~ ., data=iris[ok,])

## try to predict the missing values for Species
## neither
pred <- predict(model, iris[5])
## nor
pred <- predict(model, iris[!ok, -5])
## seems to work....

Many thanks if anyone could tell me what i do wrong and what is the 
problem here.

best regards

Andreas




More information about the R-help mailing list