简体   繁体   English

结合Amelia估算数据的多个随机森林模型

[英]Combining Multiple Random Forest Models from Amelia Imputed Data

I just created 40 imputed data sets using the Amelia package, and they are stored in a.out. 我刚刚使用Amelia包创建了40个插补数据集,它们存储在a.out中。

I then used the lapply function to create randomforest models on the data sets: 然后我使用lapply函数在数据集上创建randomforest模型:

rf.amelia.out = lapply(a.out$imputations, function(i) randomForest(y + x1+x2, data = i) )

Now I would like to combine these models to make a prediction on a bunch a.test.out, which is a list of amelia imputed data testing data. 现在我想结合这些模型来对a.test.out进行预测,这是一个amelia估算数据测试数据的列表。

I can't figure out how to combine these random forest models. 我无法弄清楚如何组合这些随机森林模型。 I've tried randomforest combine function like combine(rf.amelia.out) but that didn't work. 我已经尝试了randomforest组合功能,如combine(rf.amelia.out)但是没有用。 The problem is that rf.amelia.out is not a model object, but neither is rf.amelia.out[1] . 问题是rf.amelia.out不是模型对象,但rf.amelia.out[1]也不是。

I also tried to use zelig to automatically combine multiple models: 我还尝试使用zelig自动组合多个模型:

rf.z.out = zelig(y~x1+x2, data = a.out, model = "rf")

But I don't think zelig supports random forest models. 但我不认为zelig支持随机森林模型。

How do I access and combine the multiple random forest models so that I can make one prediction? 如何访问和组合多个随机森林模型,以便我可以进行一次预测?

Since rf.amelia.out is already a list, the combine function in randomForest loses its methods when it tries to convert it to a list again. 由于rf.amelia.out已经是一个列表,因此randomForestcombine函数在尝试再次将其转换为列表时会丢失其方法。 I recommend one of two fixes: 我建议使用以下两种方法之一:

  1. Change the combine function and then use the modified version: 更改combine功能,然后使用修改后的版本:

    body(combine)[[4]] <- substitute(rflist <- (...))

    rf.all <- combine(rf.amelia.out)

  2. Or use: 或使用:

    combine(rf.amelia.out[[1]].rf.amelia.out[[2]],...)

I think the first way is easier (and much less manual). 我认为第一种方式更容易(而且手动更少)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM