[R] predict missing values with svm

Friedrich Leisch friedrich.leisch at stat.uni-muenchen.de
Mon Sep 28 16:30:38 CEST 2009


>>>>> On Mon, 28 Sep 2009 16:12:11 +0200,
>>>>> Andreas Wittmann (AW) wrote:

That is a bug in predict.svm, I will inform David Meyer, the author of
the function.

Best,
Fritz

  > 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