使用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 fails when I specify the dataset
predicted3 <- predict(bayesglmObject, type = "response")
无法弄清楚如何使用bayesglm 对象进行预测。有任何想法吗?谢谢!