如何从elrm摘要输出中提取系数

如何从elrm摘要输出中提取系数,r,extraction,statistics-bootstrap,R,Extraction,Statistics Bootstrap,我使用包elrm 我将其与普通逻辑回归进行比较 我能够在普通的逻辑回归上进行引导,我感兴趣的统计数据是估计系数和p值 但是,我无法运行elrm引导,因为我无法从输出中提取所需的系数 根据我的数据,总结将打印出: Results: estimate p-value p-value_se mc_size M 0.15116 0.06594 0.00443 49000 95% Confidence Intervals for Parameters lower u

我使用包
elrm

我将其与普通逻辑回归进行比较

我能够在普通的逻辑回归上进行引导,我感兴趣的统计数据是估计系数和p值

但是,我无法运行elrm引导,因为我无法从输出中提取所需的系数

根据我的数据,总结将打印出:

Results:
   estimate p-value p-value_se mc_size
M  0.15116 0.06594    0.00443   49000

95% Confidence Intervals for Parameters

     lower     upper
M 0.00156155 0.3647232
我想提取M估计值和p值,这样我可以在引导时提取这些统计数据。我尝试了一系列不同的组合来尝试提取这些值,但它们都不起作用

summary(model)$coefficient 
summary(model)$Results
summary(model)$estimate
所有这些都只是再次吐出了总结

是否有人知道是否可以从elrm摘要中提取

任何帮助都将不胜感激

库(elrm)
library(elrm)
data(drugDat)
drug.elrm <- elrm(formula=recovered/n~sex+treatment,interest=~sex+treatment,r=4, 
    iter=100000,burnIn=1000,dataset=drugDat)

> summary.elrm(drug.elrm)

Call:
[[1]]
elrm(formula = recovered/n ~ sex + treatment, interest = ~sex + 
    treatment, r = 4, iter = 1e+05, dataset = drugDat, burnIn = 1000)


Results:
          estimate p-value p-value_se mc_size
joint           NA 0.14886    0.00173   99000
sex        0.27092 0.69385    0.01204    2649
treatment  0.76739 0.07226    0.00314   13160

95% Confidence Intervals for Parameters

               lower    upper
sex       -0.6217756 1.212499
treatment -0.1216884 1.852346

# If you look at the summary function, it simply outputs formatted results to
# the screen. So instead, we can just work with the original drug.elrm object

names(drug.elrm)
# shows you everything in this object

# to see the p-values
drug.elrm$p.values.se
      joint         sex   treatment 
0.001734482 0.012039701 0.003143006 

# to get the p-value for joint
drug.elrm$p.values.se[[1]]

# now for the CI
drug.elrm$coeffs.ci
               lower    upper
sex       -0.6217756 1.212499
treatment -0.1216884 1.852346

> drug.elrm$coeffs.ci[[1]]
[1] -0.6217756 -0.1216884
> drug.elrm$coeffs.ci[[1]][1]
[1] -0.6217756
> 
数据(药物数据) drug.elrm摘要.elrm(drug.elrm) 电话: [[1]] elrm(公式=康复/n~性别+治疗,兴趣=~性别+ 治疗,r=4,iter=1e+05,数据集=drugDat,burnIn=1000) 结果: 估计p值p值使用mc大小 接头NA 0.14886 0.00173 99000 性别0.27092 0.69385 0.01204 2649 处理0.76739 0.07226 0.00314 13160 参数的95%置信区间 上下 性别-0.6217756 1.212499 处理-0.1216884 1.852346 #如果您查看summary函数,它只是将格式化的结果输出到 #屏幕。因此,我们可以只使用原始的drug.elrm对象 姓名(drug.elrm) #显示此对象中的所有内容 #要查看p值 药品。elrm$p.values.se 联合性治疗 0.001734482 0.012039701 0.003143006 #获取接头的p值的步骤 drug.elrm$p.values.se[[1]] #现在是CI 药物。elrm$coeffs.ci 上下 性别-0.6217756 1.212499 处理-0.1216884 1.852346 >drug.elrm$coeffs.ci[[1]] [1] -0.6217756 -0.1216884 >drug.elrm$coefs.ci[[1]][1] [1] -0.6217756 >
看起来p值和置信区间是作为模型对象本身的一部分存储的。
summary.elrm
函数只是为您提取并格式化一些信息。我在下面展示了我用来解决这个问题的步骤,但是摘要版本是分别为
object$p.values
object$coefs.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
#帮助页面中的示例
数据(utiDat)
uti.elrm uti.elrm$p.values
迪亚
0.02225
#置信区间也在对象中,位于汇总代码中:
#-----
#cat(对象$ci.level,“%参数置信区间”\n“,
#sep=“”)
#猫(“\n”)
#打印(对象$coefs.ci)
#所以我们可以这样提取它们:
>uti.elrm$coeffs.ci
上下
直径0.1256211 Inf

+1-看起来我们在这里使用了非常类似的调试策略。