看起来 p 值和置信区间是作为模型对象本身的一部分存储的。该summary.elrm
功能只是为您提取和格式化一些信息。我展示了我用来解决这个问题的以下步骤,但摘要版本是分别索引到您的模型对象object$p.values
本身object$coeffs.ci
。
#Example from help page
data(utiDat)
uti.elrm <- elrm(uti/n~age+current+dia+oc+pastyr+vi+vic+vicl+vis,
interest=~dia,r=4,iter=5000,burnIn=1000,dataset=utiDat)
#Look at summary
summary(uti.elrm)
#Let's examine the structure of the summary object to see what's in there, i.e.
#what can we extract?
str(summary(uti.elrm))
#Hmm, doesn't look like anything of interest. Let's look at the source code itself
summary.elrm
#Looks like the p.values are stored in the actual model object iself and the summary function
#just formats them for us. The relevant part of the summary code for the p-value is:
#-----
#inferences = as.data.frame(cbind(round(as.numeric(object$coeffs),5),
# round(as.numeric(object$p.values), 5),
# round(as.numeric(object$p.values.se),5),
# object$mc.size)
# )
#results = data.frame(row.names = names(object$coeffs), inferences)
#names(results) = c("estimate", "p-value", "p-value_se", "mc_size")
#So, it looks like we can grab the p.values directly from "object"
> uti.elrm$p.values
dia
0.02225
#And the confidence intervals are also in the object, located here in the summary code:
#-----
#cat(object$ci.level, "% Confidence Intervals for Parameters\n",
# sep = "")
#cat("\n")
#print(object$coeffs.ci)
#So we can extract them thusly:
> uti.elrm$coeffs.ci
lower upper
dia 0.1256211 Inf