我运行了以下模型:
log <- svyglm(compo ~ bs(edadc,degree=1, knots =c(-1,8)) +
numenf5 + BMIc + BMIc2 + fried,
dclus,family = quasibinomial)
[当我尝试计算edadc = 0的logit时,我写的时候得到了不同的结果:
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引入正值时,将发生链接的不同计算。
应本·博克的要求,这里有一个可复制的示例:
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