使用bayesglm时,我在预测功能方面遇到了一些问题.我读过一些帖子,说当样本数据的数量超过样本数据时,可能会出现这个问题,但是我使用相同的数据来拟合和预测函数.预测与常规glm一起工作正常,但不适用于bayesglm.例:
control <- y ~ x1 + x2
# this works fine:
glmObject <- glm(control, myData, family = binomial())
predicted1 <- predict.glm(glmObject , myData, type = "response")
# this gives an error:
bayesglmObject <- bayesglm(control, myData, family = binomial())
predicted2 <- predict.bayesglm(bayesglmObject , myData, type = "response")
Error in X[, piv, drop = FALSE] : subscript out of bounds
# Edit... I just discovered this works.
# Should I be concerned about using these results?
# Not sure why is …Run Code Online (Sandbox Code Playgroud) 看来该mi软件包在过去几年的某个时候进行了相当大的重写。
以下教程详细概述了“旧”的做事方式:http://thomasleeper.com/Rcourse/Tutorials/mi.html
“新”的做事方式(坚持 Leeper 的模拟演示)看起来像这样:
#load mi
library(mi)
#set seed
set.seed(10)
#simulate some data (with some observations missing)
x1 <- runif(100, 0, 5)
x2 <- rnorm(100)
y <- 2*x1 + 20*x2 + rnorm(100)
mydf <- cbind.data.frame(x1, x2, y)
mydf$x1[sample(1:nrow(mydf), 20, FALSE)] <- NA
mydf$x2[sample(1:nrow(mydf), 10, FALSE)] <- NA
# Convert to a missing_data.frame
mydf_mdf <- missing_data.frame(mydf)
# impute
mydf_imp <- mi(mydf_mdf)
Run Code Online (Sandbox Code Playgroud)
尽管函数名称已更改,但这实际上与“旧”的处理方式非常相似。
最大的变化(从我的角度来看)是替换了以下“旧”功能
lm.mi(formula, mi.object, ...)
glm.mi(formula, mi.object, family = gaussian, ...)
bayesglm.mi(formula, mi.object, family = gaussian, …
我正在使用bayesglm逻辑回归问题.它是150行和2000个变量的数据集.我试图做变量选择,通常看glmnet在caret::rfe.然而,没有一种方法bayesglm.
反正有手动定义方法rfe吗?