2

我运行了以下模型:

log <- svyglm(compo ~ bs(edadc,degree=1, knots =c(-1,8)) + 
  numenf5 + BMIc + BMIc2 + fried, 
  dclus,family = quasibinomial)

当我尝试计算 edadc=0 的 logits 时,我会得到不同的结果:

newdata2 <- with(compoc, 
  data.frame(edadc = rep(seq(from = -1, to = 0))))
newdata2$BMIc<-0                                      
newdata2$BMIc2<-0  
newdata2$numenf5<-2 
newdata2$fried<-"R"
newdata2 <- cbind(newdata2, predict(log, newdata2, 
      type = "link",se= TRUE))

 edadc BMIc BMIc2 numenf5 fried       link        SE
1    -1    0     0       2     R -0.8689483 0.1319695
2     0    0     0       2     R -0.2217048 0.1569442

当我写:

newdata2 <- with(compoc, 
 data.frame(edadc = rep(seq(from = -1, to = 1))))
newdata2$BMIc<-0                                      
newdata2$BMIc2<-0  
newdata2$numenf5<-2 
newdata2$fried<-"R"
newdata2 <- cbind(newdata2, predict(log, 
    newdata2, type = "link",se= TRUE))

 edadc BMIc BMIc2 numenf5 fried       link        SE
1    -1    0     0       2     R -0.8689483 0.1319695
2     0    0     0       2     R -0.5453266 0.1021396
3     1    0     0       2     R -0.2217048 0.1569442

当我在 newdata2 中为 edadc 引入正值时,会发生不同的链接计算。

4

1 回答 1

0

应 Ben Bolker 的要求,这里有一个可重现的示例:

library(survey)
library(splines)
data(api)
apiclus2$dep<-ifelse(apiclus2$api00<=800, 1, 0)
apiclus2$ellc<-apiclus2$ell-15
dclus <- svydesign(id=~dnum,data=apiclus2)
log<-svyglm(dep ~  bs(ellc,degree=1, knots =c(-1,8)) , dclus,family = quasibinomial)
summary(log)
newdata <- data.frame(ellc = 0)
newdata <- cbind(newdata, predict(log, newdata, type = "link",se= TRUE))
#link for ellc=0-->2.029313
newdata2 <- data.frame(ellc = rep(seq(from = -15, to = 51)))
newdata2 <- cbind(newdata2, predict(log, newdata = newdata2, type = "link",se= TRUE))
#link for ellc=0-->1.53011523
newdata2 <- data.frame(ellc = rep(seq(from = -15, to = 0)))
newdata2 <- cbind(newdata2, predict(log, newdata = newdata2, type = "link",se= TRUE))
#link for ellc=0-->2.02931340
newdata2 <- data.frame(ellc = rep(seq(from = -15, to = 1)))
newdata2 <- cbind(newdata2, predict(log, newdata = newdata2, type = "link",se= TRUE))
#link for ellc=0-->1.74851443   
于 2020-06-02T08:35:50.210 回答