[R-meta] convert rma.mv() output to data.frame
Dear Wolfgang, Many thanks for your reply. The linked post in your email provides a method using 'capture.output()' in basr R but it only works with intercept-only models no matter how large the random term is, it creates an appropriate datafram to fit it in. I just wonder how to extend that to correlated random effects models? Why l want this? Because each time it takes me a lot of time to prepare presentable tables out of rma.mv() models esp. after spending days figuring out what model works well. At lease when it is a dataframe I can clean it up. But right now, I should literally copy-paste for a good chunk of time. Many thanks, Simon On Wed, Oct 6, 2021, 4:25 PM Viechtbauer, Wolfgang (SP) <
wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Hi Simon, Please make a note of it when your question has been raised elsewhere so people can see what kind of answers have already been provided: https://stackoverflow.com/questions/69459062/convert-part-of-a-statistical-functions-output-into-a-data-frame This aside, I don't really understand how you want to make a data frame out of a combination of text and numbers of varying length. How many 'variables' is that data frame supposed to have? How many rows? What are the variables / rows supposed to contain? Or are you just after something like this? data.frame(component=c("tau2", "rho"), value=c(res$tau2, res$rho)) Best, Wolfgang
-----Original Message----- From: Simon Harmel [mailto:sim.harmel at gmail.com] Sent: Wednesday, 06 October, 2021 22:47 To: R meta Cc: Viechtbauer, Wolfgang (SP) Subject: convert rma.mv() output to data.frame Dear Wolfgang and list members, I am wondering if it is possible to convert the "Variance Components" part of the output of an rma.mv() object to data.frame (example below)? Many thanks, Simon library(metafor) dat <- dat.konstantopoulos2011 res <- rma.mv(yi, vi, random = ~ factor(school) | district, data=dat) #Variance Components: Can we convert this part to a data.frame? #outer factor: district (nlvls = 11) #inner factor: factor(school) (nlvls = 11) # estim sqrt fixed #tau^2 0.0978 0.3127 no #rho 0.6653 no #Test for Heterogeneity: #Q(df = 55) = 578.8640, p-val < .0001