<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Dear Will,</div>

<div> </div>

<div>you can do the following to get the values:</div>

<div> </div>

<div>install.packages("metafor")</div>

<div>
<div>library(metafor)</div>

<div> </div>

<div>dat <- dat.baskerville2012<br/>
dat</div>

<div> </div>

<div># fit random-effects model<br/>
res <- rma(smd, se^2, data=dat, method="ML", digits=3)<br/>
res</div>

<div> </div>

<div>sel <- selmodel(res, type="beta")<br/>
sel</div>

<div> </div>

<div>#calculate confidence interval for tau2<br/>
a <- confint(sel,tau2=TRUE)</div>

<div> </div>

<div>#get an overview of the list, so that you can see what you need to extract<br/>
str(a)</div>

<div> </div>

<div>#extract tau2 and tau from list<br/>
c <- as.data.frame(a[["random"]])<br/>
c</div>

<div> </div>

<div>#you can also use $ to get access<br/>
d <- as.data.frame(a$random)<br/>
d</div>

<div> </div>

<div>#now you can export the data e.g. to excel</div>

<div>install.packages("openxlsx")</div>

<div>library(openxlsx)</div>

<div> </div>

<div># Export data to an Excel file</div>

<div>write.xlsx(d, "tau2_data.xlsx", rowNames = FALSE)</div>

<div> </div>

<div>Best Regards,</div>

<div> </div>

<div>Tobias</div>
</div>

<div> 
<div> 
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Sonntag, 10. März 2024 um 05:58 Uhr<br/>
<b>Von:</b> "Will Hopkins via R-sig-meta-analysis" <r-sig-meta-analysis@r-project.org><br/>
<b>An:</b> "'R Special Interest Group for Meta-Analysis'" <r-sig-meta-analysis@r-project.org><br/>
<b>Cc:</b> "Will Hopkins" <willthekiwi@gmail.com><br/>
<b>Betreff:</b> [R-meta] Extracting values from a list of confint() objects</div>

<div name="quoted-content">With the help of ChatGPT, I have managed to extract values from a list of<br/>
rma() objects and values from a list of selmodel() objects derived from the<br/>
list of rma() objects. However, I cannot extract values from a list of<br/>
confint() objects derived from the selmodel() objects. I hope I am using the<br/>
right jargon here. If not, please be gentle, as I am still on the steep part<br/>
of the learning curve.<br/>
<br/>
<br/>
<br/>
For example, this code (mysteriously) extracts tau2 from meta_results, which<br/>
is a list of rma objects:<br/>
<br/>
tau2 <- sapply(meta_results, function(x) x$tau2).<br/>
<br/>
<br/>
<br/>
And this code (equally mysteriously) extracts the SE of tau2 from<br/>
adjusted_meta, which is a list of selmodel objects derived by applying<br/>
selmodel() to meta_results:<br/>
<br/>
seltau2se <- sapply(adjusted_meta, function(x) x$se.tau2).<br/>
<br/>
<br/>
<br/>
But I have a list I have called adjusted_confint, which is a list of confint<br/>
objects derived by applying confint to the list adjusted_meta. I don't know<br/>
how to use sapply on this list to extract the confidence limits for tau2<br/>
that are contained within this list. I have "copied blindly" the syntax of<br/>
the other sapply statements without success. Basically I don't know what to<br/>
put for the x$..., and everything I have tried fails. ChatGPT was not<br/>
helpful here. I hope a real maven can help here. Thanks.<br/>
<br/>
<br/>
<br/>
Will<br/>
<br/>
<br/>
[[alternative HTML version deleted]]<br/>
<br/>
_______________________________________________<br/>
R-sig-meta-analysis mailing list @ R-sig-meta-analysis@r-project.org<br/>
To manage your subscription to this mailing list, go to:<br/>
<a href="https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis</a></div>
</div>
</div>
</div></div></body></html>