Hi Andreas,
Andreas Wittmann wrote:
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....
ind <- is.na(iris[,5]) & !apply(iris[,-5], 1, function(x) any(is.na(x))
predict(model, iris[ind,-5])
Best,
Jim
Many thanks if anyone could tell me what i do wrong and what is the
problem here.
best regards
Andreas
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.