对于一个项目,我想用R中的“鲁棒”包进行稳健的回归 . 数据包括X轴和Y轴上某些突变的普遍性,因此我使用了二项式族 . 问题是,每当我尝试计算置信区间时,我都会收到错误:

predict.glmRob中的错误(mod,newdata = dfPred,type =“response”):尝试应用非功能

这是我运行的R代码:

mod      <- glmRob(pop2 ~ pop1, data=df, family=binomial)
xweights <- seq(0, 0.2, 0.001)
dfPred   <- data.frame(pop1 = xweights)
yweights <- predict(mod, newdata=dfPred, type="response")

这些是数据:

pop2           pop1
1   0.0000000000    0.006656805
2   0.0023738872    0.027366864
3   0.0071216617    0.054733728
4   0.0029673591    0.030325444
5   0.0094955490    0.175295858
6   0.0000000000    0.022189349
7   0.0005934718    0.019970414
8   0.0000000000    0.011834320
9   0.0011869436    0.023668639
10  0.0053412463    0.159763314
11  0.0005934718    0.070266272
12  0.0000000000    0.014792899
13  0.0077151335    0.154585799
14  0.0005934718    0.003698225
15  0.0011869436    0.062130178
16  0.0017804154    0.025147929
17  0.0071216617    0.053254438
18  0.0136498516    0.196745562

我发现有人帮我从模型中提取置信区间,但是我得到的置信区间从0到1不会出现在非鲁棒的glm中或选择其他族时 .

mod          <- glmRob(pop2 ~ pop1, data=df, family=binomial)
yweights     <- fitted.values(mod)
coefficients <- coef(mod)
se           <- coef(summary(mod))[,2]
intercept    <- as.numeric(coefficients[1] + c(-2*se[1], 0, 2*se[1]))
slope        <- as.numeric(coefficients[2] + c(-2*se[2], 0, 2*se[2]))
lci          <- intercept[1]+slope[1]*df$pop1
    uci          <- intercept[3]+slope[3]*df$pop1

有谁知道如何解决这个问题?