使用Predict.Plot预测概率

时间:2012-09-10 20:15:44

标签: r

我在R中运行以下逻辑回归模型,其中一个重要的预测变量是our_bid,这是一个数值和连续变量,范围从0.30到0.80。当我尝试使用效果包绘制模型的概率曲线时,我期望我可以基于our_bid从0.00到2.00预测响应变量。尽管我的数据集中没有这些值,但我认为我可以使用该模型预测our_bid当前值之外的值。

mod1 = glm(factor(won_ping) ~ our_bid +
  age_of_oldest_driver2 + 
  credit_type2 + 
  coverage_type2 +
  home_owner2 +
  state2 +
  currently_insured2 +
  hour_of_day4 +
  vehicle_driver_score,
  data=dat, family=binomial(link="logit"))

Predict.Plot(mod1, pred.var = "our_bid", our_bid = 250, age_of_oldest_driver2 = "22 to 25",      
             credit_type2 = "FAIR", coverage_type2 = "BASIC", home_owner2 = "1",      
             state2 = "top", currently_insured2 = "1", hour_of_day4 = "1pm to 7pm",      
             vehicle_driver_score = "0", plot.args = "list(xlim=c(0,100))", type = "response")

这导致以下图表,其未给出从0到1.00的所有预测值。我不确定为什么我无法使用统计模型来预测该变量(our_bid)中值的界限。

enter image description here

1 个答案:

答案 0 :(得分:2)

我认为不需要上面的rms包,Predict.Plot功能不在rms或任何标准包中。

如果您指的是Predict.Plot包中的TeachingDemos函数,那么在xlim部分中指定plot.args只会设置窗口的宽度,并且不会对预测执行任何操作。如果您阅读Predict.Plot帮助页面的详细信息部分,您将看到如果要指定预测范围,则需要为预测变量指定2个值(否则它只使用用于拟合模型的数据)。所以看起来你想要our_bid=c(0,100)或类似的东西。如果您以可重现的格式提供一些数据,那么我们可以测试并提供更好的建议。

相关问题