[R] metafor combining escalc effect-sizes

Michael Dewey info at aghmed.fsnet.co.uk
Sun Mar 30 15:10:20 CEST 2014


At 09:42 30/03/2014, Purssell, Ed wrote:

>Dear All
>
>I have a question about combining effect sizes generated by escalc 
>in metafor.  I realise these may be stupid things to do; but they 
>are deliberately so to explain what I mean - I don't intend doing this!
>
>
>I have 3 studies; each of which has a different measure of 
>effect/presents the data differently, so I use escalc to calculate 
>the effect size of each and combine them into a data-frame:
>
>es1<-escalc(measure="MD", m1i=10 , m2i=5 , n1i=12 , n2i=12, sd1i=2, sd2i=2)
>es2<-escalc(measure="RR", ai=10 , bi=5 , ci=12 , di=12)
>es3<-escalc(measure="RR", ai=10 , ci=5 , n1i=15 , n2i=12)
>es4<-rbind(es1, es2, es3) # combines the 3 effect sizes into a data frame
>
>attach(es4) # makes the data frame available to R

Not that it is relevant here but it is better not to do that. Just 
use the data = parameter


>es5<-rma(yi, vi, data=es4) # running the meta analysis here gives 
>the error message
>
>Error in rma(yi, vi, data = es4) :
>   Length of yi and ni vectors are not the same.

There is some glitch here which is setting the "ni" attribute of yi 
inappropriately

Try going
attr(es4$yi, "ni") <- NULL

ad then call rma.uni again

>But if I save this as a .csv and open it in R using 
>read.csv("E:/es5.csv", etc) i get a data frame that looks like this:
>
>       yi     vi
>1 5.0000 0.6667
>2 0.6931 0.4667
>3 0.4700 0.1500
>
>I can run it using
>
>rma(yi, vi, data=es4)
>
>I have three questions.
>1. Can escalc be used in this way to calculate each study effect 
>size indvidually and then rbinding them into a data-frame (assuming 
>that it is a sensible thing to do, which I realise the above probably isn't)?
>
>2. What is the meaning of the error message:
>Error in rma(yi, vi, data = es4) :
>   Length of yi and ni vectors are not the same.
>
>3. Is it right to save it as a .csv, open it and re-run it as I have done?

That gets rid of the attributes.



>Thanks very much, and to Wolfgang thanks for a great programme! I am 
>using it in my MSc teaching here for healthcare students.
>
>Edward
>
>         [[alternative HTML version deleted]]

Michael Dewey
info at aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html




More information about the R-help mailing list