我想计算逻辑回归的预测概率。因变量是伪变量。 predict()
函数不允许我得到标准误差,我需要计算标准误差来计算预测值的置信区间。
library(lme4)
# Create function
cham <- glmer(mentionedpresorpreslastname ~ poly(presvoteshare,3)+
preselyear + all_approvalS +
samepartyapprovals + samepartyaspotus +
membervoteshareS +
republican + minorityparty +
congservedattimeofpr + leadership +
bachdegree + (1|memberidnum),
data=bothpres, model=binomial("logit"))
#Create new data for prediction
pp1 <- with(bothpres, data.frame(samepartyaspotus = 1,
presvoteshare = mean(presvoteshare), preselyear = 0,
all_approvalS = mean(all_approvalS),
samepartyapprovals=mean(samepartyapprovals),
membervoteshareS = mean(membervoteshareS), republican = 0,
minorityparty = 0,
congservedattimeofpr=mean(congservedattimeofpr),
leadership = 0, bachdegree=mean(bachdegree)))
predictions1 <- as.data.frame(predict(cham, pp1, se.fit="TRUE",
type="link", re.form=~0))
Predictions1返回单个值,并且
警告信息:
在predict.merMod(cham,pp1,se.fit =“ TRUE”,类型=“ link”,re.form =〜0)中:忽略未使用的参数