Description Usage Arguments Examples
using tree model to impute na values in a data
1 2 | imputeData(data, impVars, modelVars, seed = 1, treeMethod = c("rpart",
"ctree"), treeParams = list(), method = c("sample", "pred")[1])
|
data |
data.frame |
impVars |
variables needed imputed |
modelVars |
variables used in cart tree model |
treeParams |
parameters control aspects of cart tree. |
method |
impute methods, could be sample and pred. when using sample, the na values will be imputed from the raw data in the terminal node of a tree model. when using pred, the na values will be imputed by the predicted value of cart tree model. |
1 2 3 4 5 6 7 8 | mt<-mtcars
set.seed(123)
mt[cbind(sample(1:30,10,rep=F),sample(1:3,10,rep=T))]<-NA
imputeData(mt,impVars=names(mt)[1:3],modelVars=names(mt),treeParams=list(maxdepth=5,minbucket=7,minsplit=20,cp=0.01),method='sample')->mtImpSample
imputeData(mt,impVars=names(mt)[1:3],modelVars=names(mt),treeParams=list(maxdepth=5,minbucket=7,minsplit=20,cp=0.01),method='pred')->mtImpPred
plot(mtcars$mpg,mtImpSample$mpg)
plot(mtcars$mpg,mtImpPred$mpg)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.