R 根据数据框中相同变量的其他值,使用样条曲线进行logistic回归时预测logit的变化
我运行了以下模型:R 根据数据框中相同变量的其他值,使用样条曲线进行logistic回归时预测logit的变化,r,spline,logits,R,Spline,Logits,我运行了以下模型: log <- svyglm(compo ~ bs(edadc,degree=1, knots =c(-1,8)) + numenf5 + BMIc + BMIc2 + fried, dclus,family = quasibinomial) log应Ben Bolker的要求,这里有一个可复制的示例: library(survey) library(splines) data(api) apiclus2$dep<-ifelse(apiclus2$ap
log <- svyglm(compo ~ bs(edadc,degree=1, knots =c(-1,8)) +
numenf5 + BMIc + BMIc2 + fried,
dclus,family = quasibinomial)
log应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
图书馆(调查)
库(样条曲线)
数据(api)
请给我们两美元好吗?也许可以玩玩下面的例子?
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
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