Re: [R] funnel plot asymmetry

2016-08-01 Thread Viechtbauer Wolfgang (STAT)
The 'meta' and 'metafor' packages provide this. See also the meta-analysis task 
view: https://cran.r-project.org/web/views/MetaAnalysis.html (especially: 
"Investigating small study bias").

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of christos
> tb
> Sent: Monday, August 01, 2016 09:09
> To: r-help@r-project.org
> Subject: [R] funnel plot asymmetry
> 
> Hi, I am conducting a meta analysis of continuous data and I cant find
> the
> code to curry out Egger’s test, for testing the funnel plot asymmetry.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] t-test for regression estimate

2016-06-28 Thread Viechtbauer Wolfgang (STAT)
But the second column in coef(summary(ols1)) gives you the SE, so why not use 
that? Otherwise, you may want to look into the 'multcomp' package and its 
glht() function.

Best,
Wolfgang

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Steven
> Yen
> Sent: Tuesday, June 28, 2016 18:27
> To: R-help
> Subject: [R] t-test for regression estimate
> 
> test option for linearHypothesis in library(car) include "Chisq" and
> "F". I prefer a simple t-test so that I can retrieve the standard error.
> Any options other than linearHypothesis to test the linear hypothesis
> (with 1 restriction/degree of freedom)?
> 
>  > summary(ols1)
> 
> Coefficients:
>  Estimate Std. Error t value Pr(>|t|)
> (Intercept) -0.200130.09199  -2.176   0.0298 *
> age  0.040540.01721   2.355   0.0187 *
> suburb   0.019110.05838   0.327   0.7435
> smcity  -0.299690.19175  -1.563   0.1184
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
>  > linearHypothesis(ols1,"suburb")
> Linear hypothesis test
> 
> Hypothesis:
> suburb = 0
> 
> Model 1: restricted model
> Model 2: polideo ~ age + suburb + smcity
> 
>Res.DfRSS Df Sum of Sq  F Pr(>F)
> 1888 650.10
> 2887 650.02  1  0.078534 0.1072 0.7435
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Mean effect size in meta-analysis using Metafor

2015-12-21 Thread Viechtbauer Wolfgang (STAT)
Try this:

When fitting the model based on the subset data, fix the variance components to 
the values from the model with the categorical moderator. So, in your rma.mv() 
call, use:

sigma2=c(0.065, 0.113)

(ideally, use values that are less rounded). The overall effect size estimate 
from this model should then be identical to the intercept from the model with 
the categorical moderator, indicating that the discrepancy is exactly due to 
the fact described under the link provided by Michael.

If not, there is something else going on.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Carlijn .
> Sent: Monday, December 21, 2015 14:35
> To: Michael Dewey; r-help@r-project.org
> Subject: Re: [R] Mean effect size in meta-analysis using Metafor
> 
> Dear Michael,
> 
> Thanks for your reaction. The estimates in the example in the link are
> not exactly identical, but almost. However, in my case, there is a
> substantial difference between the estimates of the overall effect.
> 
> For example: I want to estimate the effect size of different mental
> health disorders. I start with estimating the effect size of substance
> use disorder (SUD), using a three-level random effects model.
> 
> In the first approach I have fitted an intercept only model with a subset
> of the data including only data on SUD. The overall effect size of SUD is
> d = 0.185 (SE = 0.085), p = .033.
> 
> Using the second approach, I have included a categorical moderator
> 'disorder' (SUD, DBD, ADHD). The reference group is SUD and I have added
> the predictors DBD (i.e., DBD is coded with '1', and SUD and ADHD with
> '0') and ADHD (i.e., ADHD is coded with '1' and SUD and DBD with '0').
> The mean effect size of SUD (intercept) is d = 0.300 (SE = 0.104), p =
> .005.
> 
> To conclude, there is a substantial difference between the estimated
> effect sizes (d = 0.185 versus d = 0.300).
> 
> Approach 1:
> > summary(sud, digits=3)
> Multivariate Meta-Analysis Model (k = 49; method: REML)
>   logLik  Deviance   AIC   BIC  AICc
>  -11.80823.61629.61635.23030.161
> 
> Variance Components:
>estim   sqrt  nlvls  fixed  factor
> sigma^2.1  0.042  0.206 49 no   y
> sigma^2.2  0.050  0.223 13 no  ID
> 
> Test for Heterogeneity:
> Q(df = 48) = 409.874, p-val < .001
> 
> Model Results:
> 
> estimate   se tval pvalci.lbci.ub
>0.1850.0852.1890.0330.0150.356*
> 
> Approach 2:
> > summary(external, digits=3)
> Multivariate Meta-Analysis Model (k = 123; method: REML)
>   logLik  Deviance   AIC   BIC  AICc
>  -58.470   116.940   126.940   140.878   127.467
> 
> Variance Components:
>estim   sqrt  nlvls  fixed  factor
> sigma^2.1  0.065  0.256123 no   y
> sigma^2.2  0.113  0.336 17 no  ID
> 
> Test for Residual Heterogeneity:
> QE(df = 120) = 846.602, p-val < .001
> 
> Test of Moderators (coefficient(s) 2,3):
> QM(df = 2) = 0.956, p-val = 0.387
> 
> Model Results:
> 
>   estimate  se  tval pvalci.lb  ci.ub
> intrcpt  0.300   0.104 2.8740.0050.093  0.506  **
> DBD  0.114   0.084 1.3540.178   -0.053  0.281
> ADHD 0.087   0.104 0.8360.405   -0.119  0.293
> 
> > Subject: Re: [R] Mean effect size in meta-analysis using Metafor
> > To: wibbelt...@hotmail.com; r-help@r-project.org
> > From: li...@dewey.myzen.co.uk
> > Date: Sat, 12 Dec 2015 16:12:58 +
> >
> > Dear Carlijn
> >
> > I wonder whether
> >
> > http://www.metafor-
> project.org/doku.php/tips:comp_two_independent_estimates
> >
> > answers your question? If you had given us an example of your fitting
> > procedure we might know for sure.
> >
> > On 12/12/2015 15:35, Carlijn . wrote:
> > >
> > >
> > > Hi all,
> > >
> > > I have a question about doing a meta-analysis, in particular a three-
> level
> > > meta-analysis using Metafor.
> > >
> > > I have estimated the mean overall effect size of males by using two
> different
> > > ways:
> > >
> > > 1. moderator analysis (male = 0, female = 1) using the whole data set
> > >
> > > 2. intercept-only model with a subset of the data (only males)
> > >
> > > The mean effect size estimated by using the categorical moderator
> analysis
> > > (1) differs considerably from the overall mean effect size estimated
> in an
> > > intercept-only model using a subset of the data (2).
> > >
> > > Can someone explain this? Which method gives a better estimation of
> the
> > > effect?
> > >
> > > Thank you in advance!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] R: forest plot metafor

2015-12-12 Thread Viechtbauer Wolfgang (STAT)
No, this is not possible. But you can just add the weights yourself. One 
difficulty here is that you want the weights to the right of the estimates and 
corresponding CIs and those are always placed at the right of the figure. One 
possibility would be to make the right margin large and then use mtext() to 
place the weights in that margin. An example:

library(metafor)
data(dat.bcg)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, data=dat, method="FE")
wi <- formatC(weights(res), format="f", digits=1, width=4)
par(mar=c(5,4,4,6))
forest(res, xlim=c(-7,8), digits=c(2,0))
mtext(wi, side=4, at=13:1, line=4, las=2, adj=1)
par(xpd=TRUE)
abline(h=c(0,14))
par(xpd=FALSE)

Adjust as needed for your data.

Best,
Wolfgang

From: R-help [r-help-boun...@r-project.org] On Behalf Of Mario Petretta 
[petre...@unina.it]
Sent: Saturday, December 12, 2015 3:57 PM
To: r-help@r-project.org
Subject: [R] R:  forest plot metafor

Many thanks to Professor Michael Dewey for his time.

I apologize for the error about the claim to obtain weights from escalc and I 
realise that the weights are a function of the fit, not the data.

weights(res) is OK to extract the weights from the fitted object and to put 
them in the data  frame.

However, I again ask:

Using:

 forest(res, showweights=TRUE)

it is possible to directly order the columns, simply placing the weights after 
effect size and CI?

Sincerely

Mario Petretta
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor package

2015-12-08 Thread Viechtbauer Wolfgang (STAT)
Hi John,

Please keep r-help copied on the reply.

What's the 'previous model'? How do you get estimates within subgroups that 
'includes the overall effect'? I really cannot follow you here.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: John Peterson [mailto:john.peterson@gmail.com]
> Sent: Monday, December 07, 2015 22:14
> To: Viechtbauer Wolfgang (STAT)
> Subject: Re: [R] metafor package
> 
> Hi Dr. Viechtbauer,
> Thank you very much for your reply. I tried your advice and was able to
> make a forest plot with only the estimates for each subgroup.For the
> estiamte for each subgroup, similar to the previous model, I random
> effects model within each subgroup. However, I now find the result for
> the estiamte within subgroup to be different thant the result for the
> previous model. I have tried analyzing this in STATA and I get the same
> result as the model which includes the overall effect. Any advice on what
> may be wrong here? Thanks greatly,
> John
> 
> On 7 December 2015 at 04:02, Viechtbauer Wolfgang (STAT)
> <wolfgang.viechtba...@maastrichtuniversity.nl> wrote:
> The code you posted is totally mangled up, but it's just what can be
> found here:
> 
> http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups
> 
> If you don't want an overall estimate, just pass the estimates and
> corresponding sampling variances to the forest() function (and not the
> model object). Use the 'rows' argument to specify where the estimates
> will be placed and adjust 'ylim' so give you enough space to leave gaps
> for headings and the subgroup estimates. Then fit models within the
> subgroups (the 'subset' argument is useful here) and use addpoly() to add
> the subgroup estimates in the appropriate rows. With text(), you can add
> headings as needed.
> 
> If you use weights() on each subgroup model object, you can get the
> subgroup weights (that add up to 100% within each subgroup). It's
> probably easiest to just add those values with text() in an appropriate
> place to the plot.
> 
> Best,
> Wolfgang
> 
> --
> Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
> Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
> Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com
> 
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of John
> > Peterson
> > Sent: Monday, December 07, 2015 01:39
> > To: r-help@r-project.org
> > Subject: [R] metafor package
> >
> > Hi Everyone,
> >
> > I am conducting a meta-analysis using the metafor package. I am
> > interested
> > in obtaining an estimate by subgroup only without showing an overall
> > effect. This is directly from the metafor website. How would i modify
> > this
> > code to only show subgroup effects? Further, I want to show weights by
> > subgroup. The option showweights=TRUE does not display weights by
> > subgroup
> > but by the weight of each study in comparison to all studies (and not
> the
> > subgroup). You help would be appreciated.

[snip garbled code]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor package

2015-12-08 Thread Viechtbauer Wolfgang (STAT)
The first and second argument of forest() (or more precisely, forest.default()) 
are for the estimates and the corresponding sampling variances, respectively. 
So, if you do forest(rr, se, ...), then the function will interpret the 
standard errors as if they are variances. So, you should do forest(rr, sei=se, 
...).

And just in case: In all likelihood, those SEs are for the *log-transformed* 
risk ratios, so you should also pass log-transformed risk ratios to the 
function (and then use 'atransf=exp' so results are shown with back-transformed 
x-axis labels and annotations).

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: John Peterson [mailto:john.peterson@gmail.com]
> Sent: Tuesday, December 08, 2015 14:25
> To: Viechtbauer Wolfgang (STAT)
> Cc: R-help@r-project.org
> Subject: Re: [R] metafor package
> 
> Hi Dr. Viechtbauer,
> 
> The code provided in the metafor projects website for subgroup includes
> fitting a random effects model on the entire dataset and fitting a random
> effects model within subgroups. When I exactly follow this code, my
> estimates and confidence intervals for estimate within each subgroup
> matches with what I get in STATA so it seems to be the correct estimate
> (and CI). However, I don't want to present an overall effect and I want
> to present only the effect within each subgroup. In my second attempt, I
> did not run a random effects model within the entire dataset and only ran
> the models within each subgroup. I generated a variable corresponding to
> the estimate(risk ratio) and standard error  which I plugged in the
> forest() function (i.e. forest(rr, se, .).  When I run this code, the
> estimate I get for each subgroup is slightly different than the estimate
> I get for each subgroup in comparison to when I also included the random
> effects model for the overall effect. (i.e. my first attempt). Is this
> the right approach? I was not clear when you said passing the estimates
> and sampling variances to the forest() function. I created a variable
> corresponding to the estimate and standard error and plugged those in the
> forest() function. I am not sure if this is the right approach. Thanks,
> 
> John
> 
> On 8 December 2015 at 03:47, Viechtbauer Wolfgang (STAT)
> <wolfgang.viechtba...@maastrichtuniversity.nl> wrote:
> Hi John,
> 
> Please keep r-help copied on the reply.
> 
> What's the 'previous model'? How do you get estimates within subgroups
> that 'includes the overall effect'? I really cannot follow you here.
> 
> Best,
> Wolfgang
> 
> --
> Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
> Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
> Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com
> 
> > -Original Message-
> > From: John Peterson [mailto:john.peterson@gmail.com]
> > Sent: Monday, December 07, 2015 22:14
> > To: Viechtbauer Wolfgang (STAT)
> > Subject: Re: [R] metafor package
> >
> > Hi Dr. Viechtbauer,
> > Thank you very much for your reply. I tried your advice and was able to
> > make a forest plot with only the estimates for each subgroup.For the
> > estiamte for each subgroup, similar to the previous model, I random
> > effects model within each subgroup. However, I now find the result for
> > the estiamte within subgroup to be different thant the result for the
> > previous model. I have tried analyzing this in STATA and I get the same
> > result as the model which includes the overall effect. Any advice on
> what
> > may be wrong here? Thanks greatly,
> > John
> >
> > On 7 December 2015 at 04:02, Viechtbauer Wolfgang (STAT)
> > <wolfgang.viechtba...@maastrichtuniversity.nl> wrote:
> > The code you posted is totally mangled up, but it's just what can be
> > found here:
> >
> > http://www.metafor-
> project.org/doku.php/plots:forest_plot_with_subgroups
> >
> > If you don't want an overall estimate, just pass the estimates and
> > corresponding sampling variances to the forest() function (and not the
> > model object). Use the 'rows' argument to specify where the estimates
> > will be placed and adjust 'ylim' so give you enough space to leave gaps
> > for headings and the subgroup estimates. Then fit models within the
> > subgroups (the 'subset' argument is useful here) and use addpoly() to
> add
> > the subgroup estimates in the appropriate rows. With text(), you can
> add
&

Re: [R] metafor package

2015-12-07 Thread Viechtbauer Wolfgang (STAT)
The code you posted is totally mangled up, but it's just what can be found here:

http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups

If you don't want an overall estimate, just pass the estimates and 
corresponding sampling variances to the forest() function (and not the model 
object). Use the 'rows' argument to specify where the estimates will be placed 
and adjust 'ylim' so give you enough space to leave gaps for headings and the 
subgroup estimates. Then fit models within the subgroups (the 'subset' argument 
is useful here) and use addpoly() to add the subgroup estimates in the 
appropriate rows. With text(), you can add headings as needed.

If you use weights() on each subgroup model object, you can get the subgroup 
weights (that add up to 100% within each subgroup). It's probably easiest to 
just add those values with text() in an appropriate place to the plot.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of John
> Peterson
> Sent: Monday, December 07, 2015 01:39
> To: r-help@r-project.org
> Subject: [R] metafor package
> 
> Hi Everyone,
> 
> I am conducting a meta-analysis using the metafor package. I am
> interested
> in obtaining an estimate by subgroup only without showing an overall
> effect. This is directly from the metafor website. How would i modify
> this
> code to only show subgroup effects? Further, I want to show weights by
> subgroup. The option showweights=TRUE does not display weights by
> subgroup
> but by the weight of each study in comparison to all studies (and not the
> subgroup). You help would be appreciated.
> 
> library  devel/library/base/html/library.html>(metafor)
>  ### to save as png filepng
>  devel/library/grDevices/html/png.html>(filename="forest_plot_with_subgrou
> ps.png",
> res=95, width=680, height=680, type="cairo")
>  ### decrease margins so the full space is usedpar
>  devel/library/graphics/html/par.html>(mar=c
> (4,4,1,2))
>  ### load BCG vaccine datadata
>  devel/library/utils/html/data.html>(dat.bcg)
>  ### fit random-effects model (use slab argument to define study labels)
> res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data
>  devel/library/utils/html/data.html>=dat.bcg,
> measure="RR",
>slab=paste
>  devel/library/base/html/paste.html>(author,
> year, sep=", "), method="REML")
>  ### set up forest plot (with 2x2 table counts added; rows argument is
> used### to specify exactly in which rows the outcomes will be plotted)
> forest(res, xlim=c
> (-16,
> 6), at=log  devel/library/base/html/log.html>(c
> (.05,
> .25, 1, 4)), atransf=exp
> ,
>ilab=cbind
>  devel/library/base/html/cbind.html>(dat.bcg$tpos,
> dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg),
>ilab.xpos=c
> (-9.5,-8,-
> 6,-4.5),
> cex=.75, ylim=c
> (-1,
> 27),
>order  devel/library/base/html/order.html>=order
>  devel/library/base/html/order.html>(dat.bcg$alloc),
> rows=c  devel/library/base/html/c.html>(3:4,9:15,20:23),
>xlab="Relative Risk", mlab="RE Model for All Studies", psize=1)
>  ### set font expansion factor (as in forest() above) and use bold
> italic### font and save original settings in object 'op'
> op <- par  devel/library/graphics/html/par.html>(cex=.75,
> font=4)
>  ### add text for the subgroupstext
> (-
> 16,
> c  devel/library/base/html/c.html>(24,16,5),
> pos=4, c  devel/library/base/html/c.html>("Systematic
> Allocation",
>"Random Allocation",
>"Alternate Allocation"))
>  ### switch to bold fontpar
>  devel/library/graphics/html/par.html>(font=2)
>  ### add column headings to the plottext
> (c
> 

Re: [R] metafor - Meta-Analysis of rare events / beta-binomial regression

2015-11-27 Thread Viechtbauer Wolfgang (STAT)
I would say the issue of how to deal with 'double-zero' studies is far from 
settled. For example, under the (non-central) hypergeometric model, studies 
with no events have a flat likelihood, so they are automatically excluded. That 
may go against our intuition (for various reasons, some of them are aptly 
described on page 1098 in Kuss, 2015), but from a likelhood perspective, it is 
correct. And since the Mantel-Haenszel and Peto's method are also based on the 
hypergeometric model, they should also exclude double-zero studies. Now I am 
not so sure if we are ready to completely scrap these methods altogether simply 
because they exclude double-zero studies.

However, for 2x2 table data, I am all in favor of using methods that make more 
realistic distributional assumptions than the 'standard' approach that assumes 
that the sampling distribution of the log(odds ratio) is normal and has a known 
sampling variance. That's why metafor includes rma.glmm() for fitting 
appropriate unconditional mixed-effects logistic and the conditional 
mixed-effects logistic (i.e., hypergeometric) model to such data. And for 
fixed-effects models, there are also rma.mh() and rma.peto() for the 
Mantel-Haenszel and Peto's method.

I may also eventually include the beta-binomial model, but I need to give this 
some more thought. If you already want to start using this model, you will find 
implementions thereof in VGAM, aods3, and gamlss.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Markus
> Kösters
> Sent: Friday, November 27, 2015 14:38
> To: 'Michael Dewey'; r-help@r-project.org
> Subject: Re: [R] metafor - Meta-Analysis of rare events / beta-binomial
> regression
> 
> Dear Michael,
> 
> Thank you very much for your input, that is very much appreciated. I have
> not considered that method, because it's rather outlawed in general. But
> it is also included in Kuss and if I understood correctly, the collapsing
> method (and the Cochrane method) both performed not too bad under FEM
> assumption and had weaknesses in REM. I usually prefer a REM approach,
> but in this case that may not be that important.
> I will also read the mmeta paper and documentation.
> 
> Thanks a lot!
> 
> Markus
> 
> -Ursprüngliche Nachricht-
> Von: Michael Dewey [mailto:li...@dewey.myzen.co.uk]
> Gesendet: Freitag, 27. November 2015 13:32
> An: Markus Kösters; r-help@r-project.org
> Betreff: Re: [R] metafor - Meta-Analysis of rare events / beta-binomial
> regression
> 
> Dear Markus
> 
> This is not a direct answer to your question, I will leave that to
> Wolfgang but two thoughts:
> 
> 1 - if all the studies have very sparse data @article{bradburn07,
> author = {Bradburn, M J and Deeks, J J and Berlin, J A and Localio, A
> R},
> title = {Much ado about nothing: a comparison of the performance of
>meta--analytical methods with rare events},
> journal = {Statistics in Medicine},
> year = {2007},
> volume = {26},
> pages = {53--77},
> keywords = {meta-analysis, fixed effects, random effects} } suggests,
> surprisingly, that just collapsing the tables may be adequate
> 
> 2 - there is a CRAN package mmeta which uses beta-binomial in a Bayesian
> perspective. I did not find the documentation very explicit but there is
> a paper in JSS.
> 
> On 26/11/2015 13:39, Markus Kösters wrote:
> > Dear all,
> >
> > I am currently writing a protocol for a meta-analysis which will
> > analyze suicidal events. Recently, O. Kuss has (DOI 10.1002/sim.6383)
> > published a paper that suggest using beta-binomial regression methods
> > to incorporate double-zero studies. He states that  Methods that
> > ignore information from double-zero studies or use continuity
> > corrections should no longer be used.  It seems obvious to me that
> > excluding studies with zero events will bias the results and I am
> > willing to follow his advice. However, I am not a a biometrician, I
> > have to admit that I am at a loss if and how it is possible to fit
> > such model within the metafor package. Can someone help me or should I
> > use the Yusuf Peto odds ratio method as suggested in the Cochrane
> handbook?
> >
> > Many thanks in advance,
> >
> > Markus
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] How to calculate the shared area of 2 plots?

2015-10-31 Thread Viechtbauer Wolfgang (STAT)
Something like this?

http://stats.stackexchange.com/questions/12209/percentage-of-overlapping-regions-of-two-normal-distributions

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

From: R-help [r-help-boun...@r-project.org] On Behalf Of Jackson Rodrigues 
[jacksonmrodrig...@gmail.com]
Sent: Saturday, October 31, 2015 5:18 PM
To: r-help@r-project.org
Subject: [R] How to calculate the shared area of 2 plots?

Dear all,

I have 2 data sets (A and B) with normal distributions. When I plot them
together, they overlay/share one part of plot.
I want to extract from each A and B that shared area.
Actually I want to sum A+B and then to compare the result with the
individual shared area of A and B to know how much (in %) each one
represents. (Am I clear?)

The folowing codes do not represent exactly my data, however the final
result (plot) is very similar to what I get in the end with my data.
I can provide my original data if necessary.

A<-seq(-4,4,.01)
B<-seq(-4,4,.01)

densities<-dnorm(A, 0,1)
densities2<-dnorm(B, 0,1)

plot(A,densities, type="l", col="red")
lines(B+2,densities2, type="l")

I am very grateful for any support, help, advise  and etc ... :)


best wishes

Jackson
--

Jackson M. Rodrigues
Department of Palynology and Climate Dynamics
Albrecht-von-Haller-Institute for Plant Sciences
Georg-August-University Göttingen
Untere Karspuele 2
37073 Göttingen/Germany
Tel.:   0049 (0) 176 8186 4994

*"In order to succeed, we must first believe that we can."*
*Nikos Kazantzakis*

[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor and forest(); not showing 'ilab' and text

2015-08-31 Thread Viechtbauer Wolfgang (STAT)
Have you read help(rma.mv)? It describes in detail what "random = ~ 1 | author" 
does. Also, I think you may find some of these useful:

http://www.metafor-project.org/doku.php/analyses#multivariate_multilevel_meta-analysis_models

Especially: http://www.metafor-project.org/doku.php/analyses:konstantopoulos2011

Using "random = ~ 1 | author" is likely to be insufficient. You also need to 
add random effects at the observation level.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

> -Original Message-
> From: Marco Colagrossi [mailto:marco.colagro...@gmail.com]
> Sent: Monday, August 31, 2015 18:37
> To: Michael Dewey
> Cc: Viechtbauer Wolfgang (STAT); r-help@r-project.org
> Subject: Re: [R] Metafor and forest(); not showing 'ilab' and text
> 
> The solution that you proposed works perfectly, thank you very much.
> 
> I'll wait for Wolfgang answer as I'm having few doubts about the models.
> 
> Thanks
> 
> On 31 August 2015 at 18:34, Michael Dewey <li...@dewey.myzen.co.uk>
> wrote:
> > Comments in line
> >
> > On 31/08/2015 16:08, Marco Colagrossi wrote:
> >>
> >> Thanks for your help,
> >>
> >> I got the mistake I was making and I managed to find a solution
> >> regarding those graphs; I don't want to abuse of your patience but I
> >> have three further questions:
> >>
> >> 1. Always regarding the forest plots, it is possible to make a
> >> cross-subset? I try to explain my self better; I have one dummy
> >> variable called pub and another variable called SIMiv that can take
> >> the values of "share", "loan", "number" and "duration". How can I
> >> subset my sample so that the forest shows only (for example) studies
> >> when the dummy takes the value of 1 and the SIMiv variable takes the
> >> values of "share" and "loan"?
> >> Something like this:
> >> forest(pc, var, ci95m, ci95p, slab = authoryear2, psize=1,
> >> subset=(pub==1, SIMiv=("share", "loan", "duration"))
> >>
> >
> > Do you not want something like
> > (pub == 1) & (SIMIv %in% c("share", "loan", "duration"))
> >
> >
> >> 2. I have few doubts regarding the multilevel modeling;
> >>  rma.mv(pc, var, random = ~ 1 | author, data=codebook)
> >> if I'm correct this should be a multilevel model nested at
> "author"
> >> level; what I cannot understand If it is a varying intercept
> >> (Y=A+BjX), a varying slope (Y=Aj+BX) or a varying intercept
> >> model (Y=Aj+BjX). Are there the formulas for it somewhere? So far I
> >> only found the formulas for the estimators included in the metafor
> >> package.
> >>
> >
> > I think it a random intercept but Wolfgang may correct me there.
> >
> >
> >> 3. metareg1 <- rma.mv(pc, var, random = ~ 1 | author, mods = ~ pub +
> >> SIMiv, data=codebook)
> >> Again, if I'm correct this should be a multilevel meta regression
> >> (correct me if I'm wrong); I have the same doubts as before.
> >>
> >> Thank you again
> >>
> >> Marco
> >>
> >> On 25 August 2015 at 19:24, Michael Dewey <li...@dewey.myzen.co.uk>
> wrote:
> >>>
> >>> Dear Marco
> >>>
> >>> When you change xlim it increases the width of the forest plot in the
> >>> sense
> >>> you describe. It does not push your text out of the way to make space
> for
> >>> it
> >>> but instead overprints it. You may like to use alim to truncate your
> >>> confidence interval whiskers to fit within the space you see or make
> your
> >>> labels shorter.
> >>>
> >>>
> >>> On 25/08/2015 17:25, Marco Colagrossi wrote:
> >>>>
> >>>>
> >>>> I think I've not explained myself well. When I say "the width of the
> >>>> forest plot" I mean the region above the observed outcome, the
> >>>> "actual" forest plot, not the plot as a whole. Even if I change
> values
> >>>> for Xlim, cex or ilab.xpos the width of that particular region
> within
> >>>> the plot doesn't change.
> >>>>
> >>>> Best,
> >>>>
> >>>> Mar

Re: [R] Metafor and forest(); not showing 'ilab' and text

2015-08-25 Thread Viechtbauer Wolfgang (STAT)
The 'xlim' argument does not change the actual width of the plotting device. 
For that, you need to use the 'width' argument with whatever device you are 
actually using. You can then use the 'xlim' argument to create appropriate 
spacing to the left/right of the part of the plot that shows the estimates and 
their CIs. Within that space, you can then add additional columns with the 
'ilab' argument. It's up to you to find an appropriate combination of plotting 
device width, character/symbol expansion factor ('cex' argument), 'xlim' 
values, and 'ilab.xpos' values to create a nice looking plot that has no 
overlapping text and no excessive white space. An example is this:

http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups 

Note that it took me dozens of iterations to create that plot. You just have to 
start experimenting.

Best,
Wolfgang

 -Original Message-
 From: Marco Colagrossi [mailto:marco.colagro...@gmail.com]
 Sent: Tuesday, August 25, 2015 17:59
 To: Viechtbauer Wolfgang (STAT)
 Cc: r-help@r-project.org; Michael Dewey
 Subject: Re: [R] Metafor and forest(); not showing 'ilab' and text
 
 Thanks again for your help. I'm sorry to bother you but I don't get
 how to widen the forest plot; if I try to change the values of xlim or
 the ilab.xpos values the width of the forest plot region does not
 change, but only moves on the graphs. What I'm I missing?
 
 
 forest(pc, var, ci95m, ci95p, slab = authoryear, psize=1,
 subset=(pub==1),
xlim = c(-16, 6),
ilab = data.frame(SIMdv, SIMiv),
ilab.xpos = c(-7.5, -5.5), cex = 0.75)
 op - par(cex=.75, font=2)
   text(c(-7.5, -5.5), 54, c(DV, IV))
   text(-16,54, Author(s) and Year, pos=4)
   text(6,  54, Outcome [95% CI], pos=2)
 par(op)
  par(usr)[1:2]
 [1] -16   6
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor and forest(); not showing 'ilab' and text

2015-08-25 Thread Viechtbauer Wolfgang (STAT)
Further comments in line as well.

 -Original Message-
 From: Michael Dewey [mailto:li...@dewey.myzen.co.uk]
 Sent: Tuesday, August 25, 2015 13:23
 To: Marco Colagrossi; Viechtbauer Wolfgang (STAT)
 Cc: r-help@r-project.org
 Subject: Re: [R] Metafor and forest(); not showing 'ilab' and text
 
 Hello Marco
 
 Comments in line again
 
 On 24/08/2015 18:49, Marco Colagrossi wrote:
  I tried to upload the file once again. I tweaked it a bit, now my code
 is:
 
  forest(pc, var, ci95m, ci95p, slab = authoryear, psize=1,
 subset=(pub==1),
  xlim = c(-16, 6),
  ilab = cbind(SIMdv, SIMiv),
  ilab.xpos = c(-7.5, -5.5), cex = 0.75)
  op - par(cex=.75, font=2)
 text(c(-7.5, -5.5), 54, c(DV, IV))
 text(-16,54, Author(s) and Year, pos=4)
 text(6,  54, Outcome [95% CI], pos=2)
  par(op)
 
  I managed to show both the Ilab argument and the text above. I still
  have 3 issues:
  - now the forest plot is too narrow - that is, pretty unreadable;
 
 You need to re-read Wolfgang's advice again. The forest function tells
 you what values of xlim it used and you can then adjust them to suit.
 This will take a few attempts in my experience.
 
  - I cannot still export it properly, as shown in the enclosed .png
 
 It looked correctly exported to me. One comment, do you really need the
 complete citation of each study? Most of the forest plots I see as a
 reviewer just use the first author name and the year. This would
 potentially give you a lot more space.

Also, if you have lots of outcomes, you may need to increase the height of the 
plotting device to make everything fit (or you need to reduce the font size 
even further, but things will become illegible eventually).

  - SIMdv, SIMiv are shown as number while on mine .csv are actually
  text variable.

Those variables are apparently coded as factors, so use data.frame() instead of 
cbind() to avoid the coercion to integer codes.

  regarding the rma.mv package, I set it up this way (preliminarily)
 
 
 I will leave this one to Wolfgang to answer.
 
  multi - rma.mv(pc, var, random = ~ 1 | author, data=codebook)
 
  I'm trying to compare the results with this equation, which is what -
  I think, correct me if I'm wrong -  in econometrics we call
  author-fixed effect, that is, model which are constant across
  individuals (the random\fix notation is a bit tricky):
 
  author_fix - rma(pc, var, mods = ~ I(author), data=codebook,
 method=ML)
 
  What I was wondering if that the two equation above mentioned also
  correct for heteroskedasticity which I need since my studies have
  different sample and specifications.

I cannot comment on model choices. But yes, the functions properly account for 
the fact that the sampling variances are heteroskedastic.

  Thanks for your help, your patience and your time, and many
  compliments for the package, is guiding me through the use of R for
  the first time - as you might have guessed.
 
  Marco
 
 
  On 24 August 2015 at 16:50, Viechtbauer Wolfgang (STAT)
  wolfgang.viechtba...@maastrichtuniversity.nl wrote:
  I cannot reproduce the issue with 'ilab' not being shown when using
 'subset'. My guess is that the values for 'ilab.xpos' specified are
 actually outside of the plotting region. After you have drawn the forest
 plot, try:
 
  par(usr)[1:2]
 
  to see what the default limits actually are. Then use 'xlim' to adjust
 the limits to your taste. And then use appropriate values for
 'ilab.xpos', so they are inside those limits.
 
  Moreover, the graph is showed correctly only within the zoom in
  Rstudio but if I save it it is showed as enclosed.
 
  Nothing was enclosed (or it was stripped).
 
  Moreover, how would you suggest to handle (graphically) the
  multiple-cases-per-study thing? It's a 'good' way to average the
 cases
  among different studies in the graphs?
 
  Maybe add some space between groupings (i.e., studies). The example
 given here can provide some clues how one could go about this:
 http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups
 But drawing a plot like this requires a lot of hand-tweaking.
 
  Best,
  Wolfgang
 
  --
  Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry
 and
  Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200
 MD
  Maastricht, The Netherlands | +31 (43) 388-4170 |
 http://www.wvbauer.com
 
  -Original Message-
  From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Marco
  Colagrossi
  Sent: Monday, August 24, 2015 16:04
  To: r-help@r-project.org
  Subject: [R] Metafor and forest(); not showing 'ilab' and text
 
  Hello folks,
 
  I have a couple of issues with the metafor package, specifically with
  the forest graphs.
  I am currently conducting a Meta-Analysis in economics throughout the
  metafor package.
 
  My meta-analysis has the specific of having different cases from
  single studies, and this proven

Re: [R] Metafor and forest(); not showing 'ilab' and text

2015-08-24 Thread Viechtbauer Wolfgang (STAT)
I cannot reproduce the issue with 'ilab' not being shown when using 'subset'. 
My guess is that the values for 'ilab.xpos' specified are actually outside of 
the plotting region. After you have drawn the forest plot, try:

par(usr)[1:2]

to see what the default limits actually are. Then use 'xlim' to adjust the 
limits to your taste. And then use appropriate values for 'ilab.xpos', so they 
are inside those limits.

 Moreover, the graph is showed correctly only within the zoom in
 Rstudio but if I save it it is showed as enclosed.

Nothing was enclosed (or it was stripped).

 Moreover, how would you suggest to handle (graphically) the
 multiple-cases-per-study thing? It's a 'good' way to average the cases
 among different studies in the graphs?

Maybe add some space between groupings (i.e., studies). The example given here 
can provide some clues how one could go about this: 
http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups But 
drawing a plot like this requires a lot of hand-tweaking.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Marco
 Colagrossi
 Sent: Monday, August 24, 2015 16:04
 To: r-help@r-project.org
 Subject: [R] Metafor and forest(); not showing 'ilab' and text
 
 Hello folks,
 
 I have a couple of issues with the metafor package, specifically with
 the forest graphs.
 I am currently conducting a Meta-Analysis in economics throughout the
 metafor package.
 
 My meta-analysis has the specific of having different cases from
 single studies, and this proven to be challenging especially when
 trying to plot graphically the results I'm obtaining.
 
 Here's the code:
 
 forest(pc, var, ci95m, ci95p, slab = authoryear, psize=1,
 subset=(pub==1),
ilab = cbind(ys, f_dim, SIMdv, SIMiv),
ilab.xpos = c(-9.5, -8, -6, -4.5), cex = 0.75)
 par(font=2)
   text(c(-9.5,-8,-6,-4.5), 26, c(Years, Firm(s) Dimension, DV,
 IV))
   text(-16,26, Author(s) and Year, pos=4)
   text(6,  26, Observed Outcome [95% CI], pos=2)
 par(op)
 
 'pc' is the 'effect size', 'var' the variance, 'ci95m  ci95p' the CI,
 'pub' if the paper has been published or not. the pub subset was the
 first idea I had in order to split my sample that otherwise would have
 been to big. The issue with this solution is that forest() displays
 only the slap argument and the forest with the confidence interval,
 completely ignoring the lab argument and the text I'm trying to add.
 Moreover, the graph is showed correctly only within the zoom in
 Rstudio but if I save it it is showed as enclosed.
 
 What I'm doing wrong? I tried both to look at the package
 documentation and online but I can't figure it out.
 
 Moreover, how would you suggest to handle (graphically) the
 multiple-cases-per-study thing? It's a 'good' way to average the cases
 among different studies in the graphs?
 In my meta-analysis I'm using a multilevel model as shown in
 Gelman-Hill but graphically (and in tables) I'm struggling.
 
 Thanks for your help and patience
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Altering Forest plot in Metafor package

2015-07-14 Thread Viechtbauer Wolfgang (STAT)
Use the 'alim' argument (or the 'at' argument) to restrict the axis limits, so 
that CI bounds below/above are indicated with an arrow. And play around with 
the 'xlim' argument to make better use of the space in the plotting region. And 
the 'ilab' argument allows you to add columns with additional information to 
the plot. Please read help(forest.rma) carefully and especially try out all of 
the examples. They illustrate the use of these arguments.

Best,
Wolfgang

From: R-help [r-help-boun...@r-project.org] On Behalf Of Fosulli 
[fosu...@tcd.ie]
Sent: Tuesday, July 14, 2015 6:42 PM
To: r-help@r-project.org
Subject: [R] Altering Forest plot in Metafor package

Dear All,

I'm having trouble tweaking a forest plot made using the R meta-analysis
package metafor. My main problem is that I have two studies which have very
large Confidence intervals and as such my forest plot is very wide, and not
neat. As I would like to add more descriptive columns into the plot too, I
was wondering if there was a way to cut the confidence interval in the graph
and add arrows to suggest that it continues on, while keeping the OR values
correct so that the reader can view the CI clearly.
http://r.789695.n4.nabble.com/file/n4709857/SNIP.png  I hope I am clear in
what I am asking, but here is an example of what I am hoping is possible in
Metafor  http://r.789695.n4.nabble.com/file/n4709857/arrows.png

--
View this message in context: 
http://r.789695.n4.nabble.com/Altering-Forest-plot-in-Metafor-package-tp4709857.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Looking up the code for a function

2015-05-06 Thread Viechtbauer Wolfgang (STAT)
Probably these are non-exported functions. Try:

getAnywhere(function name)

Or if you know which package a function comes from:

package name:::function name

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Neuropsychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ronald
 Kölpin
 Sent: Wednesday, May 06, 2015 17:00
 To: r-help@r-project.org
 Subject: [R] Looking up the code for a function
 
 Hi all,
 
 I am trying to find out how a certain functionality is implemented in R
 respectively what a certain found does exactly.
 
 Specifically I am interested in multivariate kernel density estimation.
 I found the ks package and its kde function. Usually, my preferred
 way to look under the hood of any function is to simply type the
 functions name without any brackets or arguments, in this case just:
 kde. And this works fine for kde itself. But kde calls other functions,
 such as kde.grid.3d or kde.points and typing those function names just
 yields Error: Object '[function name]' not found. These functions
 aren't defined within kde either (as far as I can see).
 
 So here is my question: Am I doing something wrong? Is there a way to
 look up the code of these functions?
 
 (I already tried google but found only the usual documentation
 (vignettes) and articles referencing the function kde or the package ks).
 
 Thanks a lot in advance
 and kind regards
 
 RK
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor - rma.mv function - variance components

2015-04-21 Thread Viechtbauer Wolfgang (STAT)
This is correct (for getting likelihood ratio tests). Manually setting a 
component to 0 is also the same as just leaving out the corresponding random 
effect. So, you could also do:

model2 - rma.mv(y, v, random = list(~ 1 | y, ~ 1 | ID), data=dat)
model3 - rma.mv(y, v, random = ~ 1 | y, data=dat)
model4 - rma.mv(y, v, random = ~ 1 | ID, data=dat)
anova(model2,model3)
anova(model2,model4)

That should give you identical results.

At the moment, rma.mv() does not compute SEs for the variance components. It 
may at some point in the future, but it is unclear what one would do with those 
SEs. Wald-type tests (z-tests) should generally be avoided when testing 
variance components.

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Neuropsychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Carlijn
 Wibbelink
 Sent: Tuesday, April 21, 2015 10:43
 To: li...@dewey.myzen.co.uk; r-help@r-project.org
 Subject: Re: [R] Metafor - rma.mv function - variance components
 
 Thank you for your reaction, it worked.
 However, I'm wondering if this is the right way to test whether there is
 significant variation on one of the two levels. The results of the anova
 tests do not correspond to the results of the Z-test in metaSEM. (In
 metaSEM only one of the variances is significant, but when I use the
 anova test in metafor, both variances are significant). But maybe I made
 a mistake. This is my syntax:
 model2 - rma.mv(y, v, random = list(~ 1 | y, ~ 1 | ID), data=dat)
 model3 - rma.mv(y, v, random = list(~ 1 | y, ~ 1 | ID), sigma2=c(NA,0),
 data=dat)
 model4 - rma.mv(y, v, random = list(~ 1 | y, ~ 1 | ID), sigma2=c(0,NA),
 data=dat)
 anova(model2,model3)
 anova(model2,model4)
 
 Is it possible to receive the standard errors of the variances in metafor
 (and do a Z-test)?
 
  To: wibbelt...@hotmail.com; r-help@r-project.org
  Subject: Re: [R] Metafor - rma.mv function - variance components
  From: li...@dewey.myzen.co.uk
  Date: Mon, 20 Apr 2015 20:24:48 +
 
  Carlijn Wibbelink wibbelt...@hotmail.com wrote :
 
  Dear Carlijn
  I think that if you set sigma2 to a vector of length 2 it will be
 possible.
 
   Hi all,
  
   I have a question about metafor and the rma.mv function. I have
 fitted a
   multivariate model (effect sizes are nested within studies) and I've
 found two
   variances:
  
   Variance Components:
 estimsqrt nlvls  fixed  factor
   sigma^2.1  0.0257  0.1602 72 no   y
   sigma^2.2  0.0694  0.2635 10 no  ID
  
   I want to test whether there is significant variantion between the
 effect sizes
   within studies (sigma^2.1: 0.0257) and/or between studies (sigma^2.2:
 0.0694).
   In metaSEM you can fix for example the variance within studies
 (sigma^2.1) to
   zero to test whether there is a significant difference in fit between
 the models
   (and if so, then there is significant heterogeneity between the
 effect sizes
   within studies). I was wondering if this is also possible in metafor.
 If I fix
   sigma2 to zero, then both variances are fixed to zero. However, I
 want to fix
   only one variance to zero.
   I hope that someone can help me. Thank you in advance!
  
 [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org
   mailing list -- To UNSUBSCRIBE and more, see
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
   and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 'metafor' - standardized mean difference in pre-post design studies

2015-04-14 Thread Viechtbauer Wolfgang (STAT)
 Hi, I have a quesite on meta-analysis with 'metafor'.
 I would like to calculate the standardized mean difference (SMD), as
 Hedges' g, in pre-post design studies.
 I have data on baseline (sample size, mean and SD in both the
 experimental
 and the control group) and at end of treatment (same as before).
 The 'metafor' site report a calculation based on Morris (2008).
 However, I would like to calculate the SMD as in Comprehensive
 Meta-analysis according to Borenstein:
 
 d = (mean.pre - mean.post) / SD_within
 
 SD_within = SD.diff / square root (2(1-r)

Note that this assumes that the SDs are the same at baseline and at the end of 
the treatment. Also, it is not how d values for pre-post designs are typically 
computed. There are several articles that describe various approaches, in 
particular:

Becker, B. J. (1988). Synthesizing standardized mean-change measures. British 
Journal of Mathematical and Statistical Psychology, 41(2), 257-278.

Gibbons, R. D., Hedeker, D. R.,  Davis, J. M. (1993). Estimation of effect 
size from a series of experiments involving paired comparisons. Journal of 
Educational Statistics, 18(3), 271-279.

Morris, S. B. (2000). Distribution of the standardized mean change effect size 
for meta-analysis on repeated measures. British Journal of Mathematical and 
Statistical Psychology, 53(1), 17-29.

Morris, S. B.,  DeShon, R. P. (2002). Combining effect size estimates in 
meta-analysis with repeated measures and independent-groups designs. 
Psychological Methods, 7(1), 105-125.

Morris, S. B. (2008). Estimating effect sizes from pretest-posttest-control 
group designs. Organizational Research Methods, 11(2), 364-386.

The two approaches that have been most thoroughly studied and described are:

d = (mean.pre - mean.post) / SD.diff

(standardization by the change score SD) and

d = (mean.pre - mean.post) / SD.pre

(standardization by the pre-test SD; one could also use the post-test SD).

The method described in the book is a bit of a juxtaposition, where SD.diff is 
'corrected' by 1/sqrt(2*(1-r)), which is identical to SD.pre (or SD.post) when 
SD.pre = SD.post. But that's never exactly the case. Plus I am not aware of any 
proper derivations of the large-sample distribution of d computed in this 
manner.

 r = correlation between pairs of observation (often it is not reported,
 and suggestion is to use r = 0.70)

Suggested where? I hope this is not a general if you don't know the 
correlation, just use .70 suggestion, because that would be nonsense. If you 
don't know r for the sample, then you could try to make a reasonable guess that 
is informed by the characteristic or attribute that is being measured (some 
things are much more stable than other things) and the timelag between baseline 
and the follow-up measurement. Also, if some treatment happens between baseline 
and follow-up -- and some people are more likely to respond to the treatment 
than others -- then this is likely to reduce the correlation to some extent, 
depending on how much variability there is in treatment responses. These are at 
least some of the considerations that should go into making a proper guess 
about r.

 The variance of d (Vd) is calculated as (1/n + d^2/2n)2(1-r), where n =
 number of pairs

As mentioned above, I am not aware of any derivation of that equation. One can 
show that 2(1-r)/n + d^2/2n is an estimate of the asymptotic sampling variance 
of d when d is computed as (mean.pre - mean.post) / SD.pre (or with SD.post). 
So, when d is computed in the manner above, it is a bit like (mean.pre - 
mean.post) / SD.pre -- except for the way that SD.pre is actually estimated. 
So, if anything, the equation should look more like the one above and not the 
one in the book. I have actually communicated with Michael and Larry (Hedges) 
about this and Michael indicated that changes may need to be made to CMA.

 To derive Hedges' g from d, the correction 'J' is used:
 
 J = 1 - (3/4df - 1), where df = degrees of freedom, which in two
 independent groups is n1+n2-2
 
 Essentially, J = 1 - (3/4*((n1+n2)-2) - 1)
 
 Ultimately, g = J x d, and variance of g (Vg) = J^2 x Vd
 
 I had some hint by Wolfgang Viechtbauer, but I'm stucked on here
 (essentially, because my poor programming abilities)
 I was stuck on applying the Viechtbauer's hint to my dataset.
 Probably I'm doing something wrong. However, what I get it is not what I
 found with Comprehensive Meta-Analysis.
 In CMA I've found g = -0.49 (95%CI: -0.64 to -0.33).

You won't get the same thing, as CMA does what is described in the book, but 
that's not what metafor does (due to the reasons described above).

 Moreover, I do not know how to apply the J correction for calculating the
 Hedges'g.
 My request is: can anyone check the codes?
 Can anyone help me in adding the J correction?
 What should I multiply for J?
 Should I use the final yi and vi as measures of d and Variance of d?

Why don't you just use what escalc() gives you?

 Thank you in 

Re: [R] Trim and fill procedure

2015-04-07 Thread Viechtbauer Wolfgang (STAT)
Yes, a comparison of the two objects would tell you what's been added.

An object returned by the trimfill() function also has a vector added to it, 
named 'fill', which indicates whether the data (which are stored in the vector 
'yi') are observed or augmented values. So, for example:

library(metafor)

### load BCG vaccine data
data(dat.bcg)

### meta-analysis of the log relative risks using a fixed-effects model
res - rma(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
method=FE)

### trim and fill analysis
tmp - trimfill(res)

### show log relative risks and dummy variable to indicate augmented values
data.frame(tmp$yi, tmp$fill)

### that's in fact how the funnel() function knows how to draw the points when 
you do:
funnel(tmp)

Best,
Wolfgang

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael
 Dewey
 Sent: Monday, April 06, 2015 14:55
 To: Carlijn Wibbelink; r-help@r-project.org
 Subject: Re: [R] Trim and fill procedure
 
 Hello Carlijn
 
 Well the documentation for trimfill says they are added.
 
 library(metafor)
 example(trimfill)
 
 This now leaves you with
 res
 res.tf
 
 By looking at these and seeing which vectors have grown you should be
 able to extract the yi and vi which you want.
 
 Wolfgang will doubtless be on the list soon to tell us there is a neater
 way of doing this.
 
 On 04/04/2015 21:27, Carlijn Wibbelink wrote:
  Hi all,
 
  I have a question concerning the trim and fill procedure in metafor. In
 STATA it is possible to obtain the values of the added estimated effect
 sizes. I was wondering if this is also possible in R and if so, how I can
 obtain the new data with the added values.
  I would really appreciate your response.
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Course and book announcements on r-help

2015-03-13 Thread Viechtbauer Wolfgang (STAT)
Dear All,

Just wondering: Is there any official policy on announcing R-related courses 
and books on r-help?

I didn't find anything on this in the posting guide, but 
http://www.r-project.org/mail.html#instructions says that r-help is, among 
other things, for announcements (not covered by 'R-announce' or 'R-packages', 
see above). That sounds a bit like this would cover courses and books, but I 
am not sure. Obviously, R-announce is not meant for that, as it is for major 
announcements about the development of R and the availability of new code and 
is to be used for announcements mainly by the R Core Development Team.

I see the occasional course/book announcement, but it seems to me that there 
are a lot more courses and books out there compared to how many announcements 
there are related to them on this mailing list. So, I am wondering if such 
announcements are somewhat implicitly discouraged.

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to have NLME return when convergence not reached

2014-12-03 Thread Viechtbauer Wolfgang (STAT)
Here is a reproducible bug in nlme (reported in 2008) that still crashes R 
today:

https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q3/001425.html

Seems to be related to memory corruption (as diagnosed by Martin and William 
Dunlap at the time):

https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q3/001429.html
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q3/001431.html

I don't know if that is related to the present case, but it sounds a bit like 
it.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Martin
 Maechler
 Sent: Wednesday, December 03, 2014 09:26
 To: Bert Gunter
 Cc: r-help@r-project.org; Ramiro Barrantes
 Subject: Re: [R] How to have NLME return when convergence not reached
 
  Bert Gunter gunter.ber...@gene.com
  on Tue, 2 Dec 2014 14:03:44 -0800 writes:
 
  Yes, Bill almost always has helpful ideas.
  Just a comment: If indeed the process is gobbling up too much
 memory,
  that might indicate a problem with your function or implementation.
 I
  defer to real experts on this, however.
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
 
 Yes, thank you Bert, it could be entirely Ramiro's function, but
 we don't know as you have not given any indication about what
 the non-linear function is in your nlme() formula.
 
 The little you wrote _seems_ to indicate a bug in nlme, and if
 that was the case, the bug should be reported and fixed,
 and we (R core - the maintainer of the recommended package nlme)
 would really like to to get a reproducible example.
 
 If OTOH, it is your nonlinear function that goes haywire,
 the implicit blame on nlme would not be warranted.
 
 Martin Maechler,
 ETH Zurich and R Core team
 
 
  On Tue, Dec 2, 2014 at 1:59 PM, Ramiro Barrantes
  ram...@precisionbioassay.com wrote:
  Thanks so much for your reply.  I am using try but nlme never
 returns!!  and I think the process is getting killed by the system as it
 is taking over all the memory.  However, I do like William Dunlap's idea
 of using R.utils::withTimeout to limit the time.
 
  Thanks again for your help!
  
  From: Bert Gunter [gunter.ber...@gene.com]
  Sent: Tuesday, December 02, 2014 4:30 PM
  To: Ramiro Barrantes
  Cc: r-help@r-project.org
  Subject: Re: [R] How to have NLME return when convergence not
 reached
 
  ?try
  Or
  ?tryCatch
 
  Bert
 
  Sent from my iPhone -- please excuse typos.
 
  On Dec 2, 2014, at 12:57 PM, Ramiro Barrantes
 ram...@precisionbioassay.com wrote:
 
  Hello,
 
  I am trying to fit many hundreds of simulated datasets using NLME
 (it's all in a big loop in R).  Some don't seem to converge.  I am
 working on addressing the issues by perhaps adjusting my simulation, or
 tweaking iteration steps in nlme, etc.  However, when it doesn't
 converge, NLME just hangs, and my program either stalls for hours/days or
 takes over the computer memory and everything crashes eventually.  Is
 there a way to tell nlme to stop when it doesn't seem to be converging
 somehow?   I have been looking at the parameters in nlmeControl() but see
 nothing obvious.
 
  Thanks in advance,
 
  Ramiro

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] arcsine transformation with metafor

2014-11-24 Thread Viechtbauer Wolfgang (STAT)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Antonello Preti
 Sent: Monday, November 24, 2014 00:35
 To: r-help@r-project.org
 Subject: [R] arcsine transformation with metafor
 
 # I'm trying to adapt to my own data the double arcsine transformation
 according to Miller (1978) as described in the metafor site
 # I've understood all passages (I think)
 # I'm able to build a forest plot with the correct data
 # I would like to build a funnel plot and a radial plot
 # However, the rule that is helpful to build a forest plot does not work
 for the radial or the funnel plot
 # When I use the results of the fixed (or random) effects model, as
 expected, the estimates are wrong (about two times the correct estimates)
 # How can the radial and funnel plot be built for the double arcsine
 transformation?
 
 # Thank you in advance, Antonello
 
 # Here the code I've used
 
 library(metafor)
 
 # The data used by Miller (1978) to illustrate the transformation and its
 inversion can be re-created with:
 
 dat - data.frame(xi=c(3, 6, 10, 1), ni=c(11, 17, 21, 6))
 dat$pi - with(dat, xi/ni)
 dat - escalc(measure=PFT, xi=xi, ni=ni, data=dat)

[SNIP]

 res - rma(yi, vi, method=FE, data=dat)

[SNIP]
 
 ### However, this is wrong
 
 radial(res)
 funnel(res)

They are not wrong. The double arcsine transformed values are used for the 
plotting, not the raw proportions. In particular, the plots are based on 'yi' 
in:

 dat
  xi nipi yi vi
1  3 11 0.2727273 0.5695 0.0217
2  6 17 0.3529412 0.6444 0.0143
3 10 21 0.4761905 0.7626 0.0116
4  1  6 0.167 0.4758 0.0385

Best,
Wolfgang

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparing summary hazard ratios in meta-analysis

2014-11-21 Thread Viechtbauer Wolfgang (STAT)
Those hazard ratios and CIs seem a bit strange. On the log-scale, they should 
be symmetric, but they are not. Could be due to heavy rounding though. At any 
rate, it comes down to this:

hr- c(3.12, 1.15)
ci.lb - c(2.2, 1.03)
ci.ub - c(4.1, 2.6)
meta  - c(1,2)

### log-transform hazard ratios and compute standard error based on the CI 
bounds
yi  - log(hr)
sei - (log(ci.ub) - log(ci.lb)) / (2*1.96)

library(metafor)
res - rma(yi ~ factor(meta), sei=sei, method=FE)
res

So, yes, the two hazard ratios are significantly different from each other.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Friday, November 21, 2014 13:25
 To: Mario Petretta; r-help@r-project.org
 Subject: Re: [R] Comparing summary hazard ratios in meta-analysis
 
 On 21/11/2014 08:51, Mario Petretta wrote:
  Dear all,
 
  I use R 3.1.1 for Windows.
 
  I performed two different meta-analysis assessing the prognostic value
 of
  two different tests in patients with coronary artery disease. The study
  included in the two analysis are different.
 
 That makes life simpler.
 
 
  The variable of interest in dichotomous (normal/abnormal result) for
 both
  tests.
 
  The effects size is hazard ratio and its standard error (ln units) for
 both
  meta-analysis.
 
 It sounds as though you might want to use meta-regression. You will need
 a single data frame containing at least log hr, se of log hr, an
 identifier for the test. I would use the metafor package for this, look
 in the documentation for how to incorporate a moderator (your test
 variable). The advantage of meta-regression is that you not only get a
 test but also a measure of how different the hr are with a confidence
 interval.
 
  I would like to statistically compare the two summary hazard ratios and
 95%
  CI (eform) obtained from the two meta-analysis.
 
  For one meta-analysis: HR 3.12 (95% CI 2.2 - 4.1)
  For the other: HR 1.25 (95% CI 1.03 - 2.6)
 
  It is possible or I'm comparing apples with oranges?
 
  Any suggestion is welcome.
 
  ---
  Mario Petretta
  Associate Professor of Internal Medicine
  Department of Translational Medical Sciences Naples
  University Federico II Italy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor - code for analysing geometric means

2014-11-14 Thread Viechtbauer Wolfgang (STAT)
With geometric mean 1 CI /3.92, I assume you mean (upper bound - lower 
bound) / 3.92. Two things:

1) That will give you the SE of the mean, not the SD of the observations (which 
is what you need as input).

2) Probably the CI for the geometric mean was calculated on the log-scale (as 
Michael hinted at). Check if log(upper bound) and log(lower bound) is (within 
rounding error) symmetric around log(geometric mean). Then (log(upper bound) - 
log(lower bound)) / 3.96 * sqrt(n) will give you the SD of the log of the 
values used to compute the geometric mean. Then you could use log(geometric 
mean) and that SD as input. But this would give you the difference of the 
log-transformed geometric means. Not sure if this is what you want to analyze.

Two more articles that may be helpful here:

Friedrich, J. O., Adhikari, N. K.,  Beyene, J. (2012). Ratio of geometric 
means to analyze continuous outcomes in meta-analysis: Comparison to mean 
differences and ratio of arithmetic means using empiric data and simulation. 
Statistics in Medicine, 31(17), 1857-1886.

Souverein, O. W., Dullemeijer, C., van 't Veer, P.,  van der Voet, H. (2012). 
Transformations of summary statistics as input in meta-analysis for linear 
dose-response models on a logarithmic scale: A methodology developed within 
EURRECA. BMC Medical Research Methodology, 12(57).

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Thursday, November 13, 2014 12:36
 To: Purssell, Ed; r-help@r-project.org
 Subject: Re: [R] metafor - code for analysing geometric means
 
 On 13/11/2014 11:00, Purssell, Ed wrote:
  ?Dear All
 
  I have some data expressed in geometric means and 95% confidence
 intervals.  Can I code them in metafor as:
 
  rma(m1i=geometric mean 1, m2i=geometric mean 2, sd1i=geometric mean 1
 CI /3.92, sd2i=geometric mean 2 CI/3.92...etc, measure=MD)
 
 Would it not be better to work on the log scale?
 
  All of the studies use geometric means.
 
  Thanks!
 
  Edward
 
 --
 Michael
 http://www.dewey.myzen.co.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using compute.es and metafor together

2014-10-03 Thread Viechtbauer Wolfgang (STAT)
Yes, that should be fine.

By the way, you do not have to name the variables 'yi' and 'vi' (if this is 
what you meant by 'coding these as yi and vi respectively'). Indeed, the 
*argument names* for supplying pre-calculated effect sizes estimates and 
corresponding sampling variances are 'yi' and 'vi' in various functions in the 
metafor package, but the *variables names* can be different. For example:

rma(yi=d, vi=var.d, data=dat)

(assuming 'd' and 'var.d' are in data frame 'dat') would be perfectly fine. And 
since 'yi' and 'vi' are the first two arguments of the rma() function, that can 
be shortened to:

rma(d, var.d, data=dat)

I tend to use 'yi' and 'vi' also as the variable names in datasets and various 
examples (and the escalc() function in metafor also names the estimates and 
corresponding variances in that way), so that leads to rma(yi, vi, data=dat), 
which is just shorthand for rma(yi=yi, vi=vi, data=dat), so this may be a 
source of potential confusion. Just wanted to clarify that you do not have to 
name your variables that way.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Purssell, Ed
 Sent: Friday, October 03, 2014 09:39
 To: r-help@r-project.org
 Subject: [R] Using compute.es and metafor together
 
 Dear All
 
 For mathematically challenged people such as myself; is it ok to use the
 compute.es package to calculate effect sizes and then import the effect
 sizes d and variances of d into metafor, coding these as yi and vi
 respectively and then running the meta-analysis?  This seems easier
 because compute.es offers a lot of ways of calculating d and its variance
 using similar codes.
 
 Thanks
 Edward
 
 
 Edward Purssell PhD
 Senior Lecturer
 
 Florence Nightingale Faculty of Nursing and Midwifery
 King's College London
 James Clerk Maxwell Building
 57 Waterloo Road
 London SE1 8WA
 Telephone 020 7848 3021
 Mobile 07782 374217
 email edward.purss...@kcl.ac.uk
 https://www.researchgate.net/profile/Edward_Purssell
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor -can't calculate heterogeneity with non-positive sampling variances

2014-08-27 Thread Viechtbauer Wolfgang (STAT)
The warning message pretty much says it: When one of the variances is zero, 
then the I^2 statistic (and various other things) cannot be computed, at least 
if one sticks to the usual equations/methods. So, if you think the 0 sampling 
variances really make sense and you really want to get something like I^2, you 
will have to come up with a creative solution.

On the metafor package website, I explain how I^2 is computed (for the 
random-effects model):

http://www.metafor-project.org/doku.php/faq#how_are_i_2_and_h_2_computed_i

The crux of the problem is how to compute the 'typical' within-study variance 
(s^2). With any vi=0, you get division by zero in the equation given. So, you 
will have to compute s^2 in a different way. You could leave out the studies 
where vi=0, but this doesn't seem quite right, because this will inflate s^2. 
You could just take the simple average of the vi values and use that for s^2, 
but then it's not really I^2 anymore (it's I^2-like).

My question would be: How come you have studies where the sampling variance is 
estimated to be zero and does that really make sense? Maybe the solution is not 
to fix the computation of I^2, but to consider if vi=0 is really sensible.

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Owen, Branwen
 Sent: Wednesday, August 27, 2014 13:48
 To: r-help@r-project.org
 Subject: [R] Metafor -can't calculate heterogeneity with non-positive
 sampling variances
 
 Hi, I'm doing a meta-analysis in metafor. All is fine except when there
 are 0s in the values that i'm pooling, then i get a pooled estimate but
 not the I2 that i am also interested in.
 for example:
 
 summary(rma.1-
 rma(yi,vi,data=mix,method=ML,knha=F,weighted=F,intercept=T))
 (where yi are the study outcomes, one of which is 0, and vi is the
 variance of the study outcomes)
 
 Random-Effects Model (k = 17; tau^2 estimator: ML)
 
   logLik  deviance   AIC   BIC  AICc
  13.0539   Inf  -22.1077  -20.4413  -21.2506
 
 tau^2 (estimated amount of total heterogeneity): 0.0119 (SE = 0.0043)
 tau (square root of estimated tau^2 value):  0.1089
 
 Model Results:
 
 estimate   se zval pvalci.lbci.ub
   0.1837   0.0274   6.7154   .0001   0.1301   0.2374  ***
 
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 
 Warning messages:
 1: In rma(yi, vi, data = mix, method = ML, knha = F, weighted = F,  :
   There are outcomes with non-positive sampling variances.
 2: In rma(yi, vi, data = mix, method = ML, knha = F, weighted = F,  :
   Cannot compute Q-test, I^2, or H^2 with non-positive sampling
 variances.
 
 Is there any way around this?
 thanks
 Branwen
 
 From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on
 behalf of r-help-ow...@r-project.org [r-help-ow...@r-project.org]
 Sent: 27 August 2014 13:36
 To: Owen, Branwen
 Subject: Metafor -can't calculate heterogeneity with non-positive
 sampling variances
 
 Message rejected by filter rule match
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Correlating multiple effect sizes within a study to study-level predictors: metafor package

2014-07-14 Thread Viechtbauer Wolfgang (STAT)
Somehow that initial post slipped under the radar for me ...

Yes, I would give the same suggestion as Michael. Besides random effects for 
'site', I would also suggest to add random effects for each estimates (as in a 
regular random-effects model). So, if you have an 'id' variable that is unique 
to each observed d-value, you would use:

random = list(~ 1 | site, ~ 1 | id)

with the rma.mv() function. This is in essence the model given by equation (6) 
in:

Nakagawa, S.,  Santos, E. S. A. (2012). Methodological issues and advances in 
biological meta-analysis. Evolutionary Ecology, 26(5), 1253-1274.

(at the time of publication, this model could not be fitted with metafor, but 
it can now). Same model is described with a bit more detail in:

Konstantopoulos, S. (2011). Fixed effects and variance components estimation in 
three-level meta-analysis. Research Synthesis Methods, 2(1), 61-76.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Monday, July 14, 2014 14:42
 To: Megan Bartlett; r-help@r-project.org
 Subject: Re: [R] Correlating multiple effect sizes within a study to
 study-level predictors: metafor package
 
 At 23:18 11/07/2014, Megan Bartlett wrote:
 Hi everyone,
 
 Since metafor doesn't have its own list, I hope this is the correct
 place
 for this posting- my apologies if there is a more appropriate list.
 
 metafor questions welcome here, Megan
 
 Wolfgang seems to be off-list so while we wait for the definitive
 answer here are some hints.
 
 
 I'm conducting a meta-analysis where I would like to determine the
 correlation between plasticity in leaf traits and climate. I'm
 calculating
 effect sizes as Hedge's d. My data is structured so that each study
 collected data from one forest site, so there is one set of climate
 variable values for that study, and there are one or more species in
 each
 study, so all the species in a study have the same values for the
 climate
 variables. I'm not sure how to account for this structure in modeling
 the
 relationship between plasticity and climate.
 
 I think you need rma.mv for your situation and you need to specify a
 random effect for site.
 
 Try going
 ?rma.mv
 and looking for the section entitled Specifying random effects
   You will need to set up your dataframe with one row per species and
 an indicator variable for site and then use
 random = ~ 1 | site
 
 Not tested obviously and Wolfgang may have other suggestions
 
 My first thought was to calculate mean effect size and variance across
 species for every study with multiple species and correlate thatwith
 the climate variable values for those study with the rma() function, but
 trying to do that returns an error message:
 
 rma(yi = EffectSize, vi = Var, data = sitestable, mod = Precip)
 returns: Error in wi * (yi - X %*% b)^2 : non-conformable arrays
 
 This leaves me with two questions: 1) Am I even accounting for the data
 structure correctly with this approach, and 2) am I fundamentally
 misunderstanding how to use metafor to do so?
 
 Thanks very much for your help!
 
 Best,
 
 Megan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor package: changing decimal in forest plot to midline decimal

2014-07-07 Thread Viechtbauer Wolfgang (STAT)
I tried this:

library(metafor)
data(dat.bcg)
res - rma(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
slab=paste(author, year, sep=, ))
options(OutDec=\xB7)
forest(res)

No warning, no scrambling, and all decimals shown in midline (also on the 
x-axis). But this is on Windows.

My guess it's a font issue. There may be others that can give more useful 
advice.

Best,
Wolfgang

 -Original Message-
 From: Dietlinde Schmidt [mailto:schmidt.dietli...@web.de]
 Sent: Monday, July 07, 2014 10:09
 To: Viechtbauer Wolfgang (STAT); r-help@r-project.org
 Subject: Re: [R] metafor package: changing decimal in forest plot to
 midline decimal
 
 Thanks for that link, Wolfgang. Unfortunately, there comes the Warning
 with it:
 (process:3634): Pango-WARNING **: Invalid UTF-8 string passed to
 pango_layout_set_text()
 and decimal being scrambled in forest plot and not displaying the
 midline decimal.
 
 I think it has to do with the fact, that only 1-byte-codes are allowed
 for options(OutDec=\xB7).
 Or does it have to do with me using Ubuntu?
 
 Apart from that the options-command does not seem to change the decimal
 of values on the true x-axis under the plot.
 
 Still searching for a solution.
 
 Cheers,
 Linde
 
 Am 05.07.2014 19:06, schrieb Viechtbauer Wolfgang (STAT):
  I found this:
 
  https://stat.ethz.ch/pipermail/r-help/2012-August/321057.html
 
  So, use this before drawing the forest plot:
 
  options(OutDec=\xB7)
 
  Best,
  Wolfgang
 
  --
  Wolfgang Viechtbauer, Ph.D., Statistician
  Department of Psychiatry and Psychology
  School for Mental Health and Neuroscience
  Faculty of Health, Medicine, and Life Sciences
  Maastricht University, P.O. Box 616 (VIJV1)
  6200 MD Maastricht, The Netherlands
  +31 (43) 388-4170 | http://www.wvbauer.com
  
  From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On
 Behalf Of Dietlinde Schmidt [schmidt.dietli...@web.de]
  Sent: Thursday, July 03, 2014 3:07 PM
  To: r-help@r-project.org
  Subject: [R] metafor package: changing decimal in forest plot to
 midlinedecimal
 
  Dear R-Community,
 
  I need to change the punctuation of the reported weights, effect sizes
  and confidence intervals in a forest plot created with the
  forest()-function in the metafor-package.
 
  Midline decimal means that it looks like this (23*6) rather than that
  (23.6).
 
  Do I need to change the forest()-function and if yes which part
 exactly?
  Or is there an otherway how I can do it maybe by changing the
  rma()-function, of which the forest()-function is then applied to?
 
  Thanks for any hints and tipps!
 
  Cheers, Linde
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor package: changing decimal in forest plot to midline decimal

2014-07-05 Thread Viechtbauer Wolfgang (STAT)
I found this:

https://stat.ethz.ch/pipermail/r-help/2012-August/321057.html

So, use this before drawing the forest plot:

options(OutDec=\xB7)

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Dietlinde Schmidt [schmidt.dietli...@web.de]
Sent: Thursday, July 03, 2014 3:07 PM
To: r-help@r-project.org
Subject: [R] metafor package: changing decimal in forest plot to midline
decimal

Dear R-Community,

I need to change the punctuation of the reported weights, effect sizes
and confidence intervals in a forest plot created with the
forest()-function in the metafor-package.

Midline decimal means that it looks like this (23·6) rather than that
(23.6).

Do I need to change the forest()-function and if yes which part exactly?
Or is there an otherway how I can do it maybe by changing the
rma()-function, of which the forest()-function is then applied to?

Thanks for any hints and tipps!

Cheers, Linde

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor: Strange Trim and Fill Outcome?

2014-05-26 Thread Viechtbauer Wolfgang (STAT)
From help(forest.rma):

pch -- plotting symbol to use for the observed effect sizes or outcomes. By 
default, a solid circle is used. Can also be a vector of values. See points for 
other options.

pch.fill -- plotting symbol to use for the effect sizes or outcomes filled in 
by the trim and fill method. By default, a circle is used. Only relevant when 
plotting an object created by the trimfill function.

The defaults are pch=19 and pch.fill=21. So, by default, a solid circle is used 
for the observed outcomes and an open circle is used for the outcomes that are 
filled in.

An example is shown here:

http://www.metafor-project.org/doku.php/plots:funnel_plot_with_trim_and_fill

From help(trimfill.rma.uni):

side -- either left or right, indicating on which side of the funnel plot 
the missing studies should be imputed. If left undefined, the side is chosen 
within the function depending on the results of Egger's regression test (see 
regtest for details on this test).

The argument is left undefined by default, so the side is chosen based on the 
results of the regression test (essentially, whether the slope is positive or 
negative). If you think the suppression occurred on the other side than the one 
that is chosen, specify the side via this argument.

Best,
Wolfgang 

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Verena Weinbir [vwein...@gmail.com]
Sent: Monday, May 26, 2014 1:15 PM
To: Michael Dewey
Cc: r-help
Subject: Re: [R] Metafor: Strange Trim and Fill Outcome?

thanks for your reply, Michael!

ad primary studies:
yup, I have a large set of studies: At the moment I consider 126 data sets
in my analysis.

ad interpretation:
thats an interesting information. But usually there should be found an
effect.

ad bit :-):
I am irritiated, because in the plots I have studied so far, I always found
that the observed studies are open circles and the additional mirrored
effects are black dots. In my case, it is the other way round.

Also, most of the mirrored circels appear in the right upper corner,
indicating, that there are studies missing in my data set, which have
smaller SDs (i.e. are more precise?) and higher effect sizes?

best,

Verena

On Mon, May 26, 2014 at 12:26 PM, Michael Dewey i...@aghmed.fsnet.co.ukwrote:

 At 09:34 26/05/2014, Verena Weinbir wrote:

 Hey guys,

 I have tested the metafor trim and fill function (y:SD, x:SMD)on my data
 set and yielded the following result:

 1. missing studies on the right: 34

 That seems a lot of missing studies unless you have a very large set of
 primary studies.

  2. open circles on the rights side appear to be the number of additional
 effects

 3. adjusted d would be higher than observed d.

 Implying that the mechanism is suppressing studies which found a large
 effect. This might happen if the dominant view is that there is no effect
 and so when people find one they worry about their results.

  Since normally, as I understand, those parameters are the other way round
 (black dots indicating missing studies on the left, which would reduce the
 effect size), I wonder:

 Is there a mistake I have done? Or, if this is an actual outcome how can I
 interpret this?  That its not a publication bias that influences my data
 set, but a lack of precision (studies missing that are precise -small SD-
 and have big SMD)?

 Sorry but that bit is not very clear to me.

  Many thanks in advance!

 Verena
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor: forest plot for subset

2014-05-26 Thread Viechtbauer Wolfgang (STAT)
Pass 'slab' to the rma() function instead of the forest() function. Also, 
'slab' is evaluated in the data frame passed via the 'data' argument, so no 
need to use empa$... And there is a 'subset' argument for rma(). Might as well 
use it. This should do it:

resultREML - rma(yi=yi, vi=vi, method=REML, slab=paste(author, year, sep = 
,), data=empa, subset=task==x)
forest(resultREML)

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Verena Weinbir
 Sent: Monday, May 26, 2014 18:57
 To: r-help
 Subject: [R] Metafor: forest plot for subset
 
 Hey,
 
 I want to build a forest plot which states author and year for a subset
 of
 studies.
 
 But if I use this argument:
 
 resultREML - rma(yi=yi, vi=vi, method = REML,
  data = subset(empa, task==x))
 resultREML
 
 forest(resultREML, , slab=paste(empa$author, empa$year,sep = ,))
 
 I get the following error message:
 
 Error in forest.rma(resultREML, slab = paste(EFempa$Autor,
 EFempa$Jahreszahl,  :
   Number of outcomes does not correspond to the length of the slab
 argument.
 
 
 When I use this method without the subset function it works and I get a
 forest plot stating author and year - but of course for the whole data
 set,
 not only for the subset x that I want.
 
 Any idea how I can make the subset function work for a forest plot with
 slab function ?
 
 Thanks in advance!
 
 Verena
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help conduction Egger's test

2014-05-12 Thread Viechtbauer Wolfgang (STAT)
Yes, the 'traditional' Egger test is a weighted regression of the effect size 
estimates against their standard errors with weights s2/vi, where s2 is a 
multiplicative dispersion parameter. This is what you will get with:

regtest(x, model=lm, predictor=sei)

where 'x' is an object returned by the rma() function from a 
fixed/random-effects model.

An example:

### load BCG vaccine data
data(dat.bcg)

### calculate log relative risks and corresponding sampling variances
dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

### random-effects model
res - rma(yi, vi, data=dat)

### classical Egger test
regtest(res, model=lm, predictor=sei)

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Sultan Malik
 Sent: Monday, May 12, 2014 20:03
 To: r-help@r-project.org
 Subject: [R] Help conduction Egger's test
 
 Hi,
 
 I am currently conducting a meta analyses and wish to carry out Egger's
 test. I was just wondering, does the weighted linear regression model
 proposed by Egger et al correspond to the weighted regression with
 multiplicative dispersion option in Metafor?
 
 Many thanks
 
 Sultan
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor: How to integrate effectsizes?

2014-05-06 Thread Viechtbauer Wolfgang (STAT)
Without the sample size of a study (i.e., either the group sizes or the total 
sample size), you cannot convert the p-value to a t-value or a t-value to a 
d-value. And for studies where you have the d-value but no sample size, you 
cannot compute the corresponding sampling variance. So, without additional 
information, you cannot include these studies. Maybe studies where a d-value is 
directly reported also report a CI for the d-value? Then the sampling variance 
can be back-calculated (since a 95% CI for d is typically computed with d +- 
1.96 sqrt(vi), where vi is the sampling variance).

Best,
Wolfgang

 -Original Message-
 From: Verena Weinbir [mailto:vwein...@gmail.com]
 Sent: Tuesday, May 06, 2014 15:09
 To: Michael Dewey
 Cc: Viechtbauer Wolfgang (STAT); r-help@r-project.org
 Subject: Re: [R] Metafor: How to integrate effectsizes?
 
 Thank you very much for your illustration, Wolfgang! It helped me a
 lot.  And also thank you for the package-hint, Michael!
 
 Now, I have re-checked the respective studies, and there still are a
 couple of studies left, only stating cohens d, and the respective t-value
 and p-value - sample and group sizes are not addressed (its data from an
 older meta-analysis). Is there a way to embed these studies in my sample?
 Wolfgangs illustration addresses only cases in which group sizes are
 stated, if I understand you correctly...
 
 Many thanks in advance,
 
 Verena
 
 On Sat, Apr 26, 2014 at 1:38 PM, Michael Dewey i...@aghmed.fsnet.co.uk
 wrote:
 At 20:34 25/04/2014, Viechtbauer Wolfgang (STAT) wrote:
 If you know the d-value and the corresponding group sizes for a study,
 then it's possible to add that study to the rest of the dataset. Also, if
 you only know the test statistic from an independent samples t-test (or
 only the p-value corresponding to that test), it's possible to back-
 compute what the standardized mean difference is.
 
 I added an illustration of this to the metafor package website:
 
 http://www.metafor-project.org/doku.php/tips:assembling_data_smd
 
 Verena might also like to look at the compute.es package available from
 CRAN to see whether any of the conversions programmed there do the job.
 
 
 Best,
 Wolfgang
 
 --
 Wolfgang Viechtbauer, Ph.D., Statistician
 Department of Psychiatry and Psychology
 School for Mental Health and Neuroscience
 Faculty of Health, Medicine, and Life Sciences
 Maastricht University, P.O. Box 616 (VIJV1)
 6200 MD Maastricht, The Netherlands
 +31 (43) 388-4170 | http://www.wvbauer.com
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org]
  On Behalf Of Michael Dewey
  Sent: Friday, April 25, 2014 16:23
  To: Verena Weinbir
  Cc: r-help@r-project.org
  Subject: Re: [R] Metafor: How to integrate effectsizes?
 
  At 12:33 25/04/2014, you wrote:
  Thank you very much for your reply and the book recommendation,
 Michael.
  
  Yes, I mean Cohen's d - sorry for the typo :-)
  
  Just to make this sure for me: There is no
  possibility to integrate stated Cohens' ds in an
  R-Metaanalysis (or a MA at all), if there is no
  further information traceable regarding SE or the like?
 
  If there is really no other information like
  sample sizes, significance level, value of some
  significance test then you would have to impute a
  value from somewhere. That would seem a last resort.
 
  I have cc'ed this back to the list, please keep
  it on the list so others may benefit and contribute.
 
 
  best regards,
  
  Verena
  
  
  On Fri, Apr 25, 2014 at 1:21 PM, Michael Dewey
  mailto:i...@aghmed.fsnet.co.uki...@aghmed.fsnet.co.uk wrote:
  At 13:15 24/04/2014, Verena Weinbir wrote:
  Hello!
  
  I am using the metafor package for my master's thesis as an R-newbie.
  While
  calculating effectsizes from my dataset (mean values and
  standarddeviations) using escalc shouldn't be a problem (I hope ;-
 )),
  I
  wonder how I could at this point integrate additional studies, which
  only
  state conhens d (no information about mean value and sds available),
 to
  calculate an overall analysis. Â I would be very grateful for your
  support!
  
  
  You mean Cohen's d I think.
  
  You will need some more information to enable
  you to calculate its standard error. Have a look at Rosenthal's
 chapter
  in
  @book{cooper94,
  Â  Â author = {Cooper, H and Hedges, L V},
  Â  Â title = {A handbook of research synthesis},
  Â  Â year = {1994},
  Â  Â publisher = {Russell Sage},
  Â  Â address = {New York},
  Â  Â keywords = {meta-analysis}
  }
  (There is an updated edition)
  This gives you more information about converting
  effect sizes and extracting them from unpromising beginnings.
  
  It often requires some ingenuity to get the
  information you need so have a go and then get
  back here with more details if you run into problems
  
  
  Best regards,
  
  Verena
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman

Re: [R] matafor package: adding additional information under a forest plot

2014-05-03 Thread Viechtbauer Wolfgang (STAT)
1) There is no function that will do that automatically for you, but it's easy 
to do with text() and paste(). If you have fitted a random-effects model with 
rma(), then you can find the Q-statistic in res$QE, the I^2 statistic in 
res$I2, and probably whatever else you need, and then just paste() together 
what you want and add it to the plot via text().

2) If you want to add lots of columns, then indeed you will need a wide plot. 
You probably want to set up your plotting device to be quite wide. For example, 
with png(), make sure 'width' is large and you may need to decrease the 
'pointsize' to still make it all fit.

Best,
Wolfgang

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Dietlinde Schmidt [schmidt.dietli...@web.de]
Sent: Friday, May 02, 2014 4:09 PM
To: r-help@r-project.org
Subject: [R] matafor package: adding additional information under a forest plot

Dear R-Users,

i have to questions about plotting a forest plot with the metafor package:

1) Is there a (text()) function to add additional information (e.g.
heterogeneity statistics) under the forest plot?
2) I want to add various columns of additional information about each
study (e.g. quality, time point, measure). I thought i could do that
with the ilab-argument, but i keep getting in the way with the line that
restricts the plot and although i tweaked everything around, I do not
succeed. Basecally, i want the format of the forest plot to be rather
wide than tall, because i have little studies but many columns with
additional study information. Does someone know how to solve that (over
xlim, ylim???)?

Thanks a lot for your help

Linde
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor: How to integrate effectsizes?

2014-04-25 Thread Viechtbauer Wolfgang (STAT)
If you know the d-value and the corresponding group sizes for a study, then 
it's possible to add that study to the rest of the dataset. Also, if you only 
know the test statistic from an independent samples t-test (or only the p-value 
corresponding to that test), it's possible to back-compute what the 
standardized mean difference is.

I added an illustration of this to the metafor package website:

http://www.metafor-project.org/doku.php/tips:assembling_data_smd

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Friday, April 25, 2014 16:23
 To: Verena Weinbir
 Cc: r-help@r-project.org
 Subject: Re: [R] Metafor: How to integrate effectsizes?
 
 At 12:33 25/04/2014, you wrote:
 Thank you very much for your reply and the book recommendation, Michael.
 
 Yes, I mean Cohen's d - sorry for the typo :-)
 
 Just to make this sure for me: There is no
 possibility to integrate stated Cohens' ds in an
 R-Metaanalysis (or a MA at all), if there is no
 further information traceable regarding SE or the like?
 
 If there is really no other information like
 sample sizes, significance level, value of some
 significance test then you would have to impute a
 value from somewhere. That would seem a last resort.
 
 I have cc'ed this back to the list, please keep
 it on the list so others may benefit and contribute.
 
 
 best regards,
 
 Verena
 
 
 On Fri, Apr 25, 2014 at 1:21 PM, Michael Dewey
 mailto:i...@aghmed.fsnet.co.uki...@aghmed.fsnet.co.uk wrote:
 At 13:15 24/04/2014, Verena Weinbir wrote:
 Hello!
 
 I am using the metafor package for my master's thesis as an R-newbie.
 While
 calculating effectsizes from my dataset (mean values and
 standarddeviations) using escalc shouldn't be a problem (I hope ;-)),
 I
 wonder how I could at this point integrate additional studies, which
 only
 state conhens d (no information about mean value and sds available), to
 calculate an overall analysis. Â I would be very grateful for your
 support!
 
 
 You mean Cohen's d I think.
 
 You will need some more information to enable
 you to calculate its standard error. Have a look at Rosenthal's chapter
 in
 @book{cooper94,
 Â  Â author = {Cooper, H and Hedges, L V},
 Â  Â title = {A handbook of research synthesis},
 Â  Â year = {1994},
 Â  Â publisher = {Russell Sage},
 Â  Â address = {New York},
 Â  Â keywords = {meta-analysis}
 }
 (There is an updated edition)
 This gives you more information about converting
 effect sizes and extracting them from unpromising beginnings.
 
 It often requires some ingenuity to get the
 information you need so have a go and then get
 back here with more details if you run into problems
 
 
 Best regards,
 
 Verena

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor - rstudent(res) - omitted rows

2014-04-22 Thread Viechtbauer Wolfgang (STAT)
I think this may help:

http://www.metafor-project.org/doku.php/tips:handling_missing_data

I am not sure I understand your second question. All studies are shown (for 
which the standardized residual can be computed), but since there are so many 
studies, these plots are not really all that helpful. If you only want to plot 
the standardized residuals, then you could start with:

options(na.action = na.pass)
sav - rstandard(res)
plot(sav$slab, sav$z, pch=19, cex=.4, type=o)

and just start tweaking this. You will have to reduce the size of the axis 
annotations (look into cex.axis), probably make them vertically aligned (las), 
and stretch that plot very wide if you want to make out individual points. Look 
into help(par) for more details cex.axis and las, and help(Devices) for setting 
up a much wider plot.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Dipl. Kfm Dominik Wagner MSc; MSc
 Sent: Tuesday, April 22, 2014 12:56
 To: r-help@r-project.org
 Subject: [R] metafor - rstudent(res) - omitted rows
 
 Dear all,
 
 I am quite new to R. Now my following easy question.
 
 I use metafor and performed an outlier test with rstudent(res).
 This is resulting in 1000 rows of 1578 and 578 omitted rows (starting
 with
 row 598).
 
 
1. How can I display all 1578 rows in R-studio? Because in the
standardized residual plot it starts with study 1 (see attachment). In
R-studio with row 598.
2. How can I just plot the standardized residuals with manipulated
x-axis to see every single study?
 
 
 Thank you very much for your help.
 
 Cordially
 
 Dominik
 
 --
 
 _
 
 
 *Dipl.-Kfm. Dominik Wagner MSc. MSc.*
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R, RStudio, and a server for my iPad.

2014-04-12 Thread Viechtbauer Wolfgang (STAT)
You will have to enter the external IP address and then use port forwarding.

Just google for that term (port forwarding) ... For example:

http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/
http://en.wikipedia.org/wiki/Port_forwarding

Best,
Wolfgang

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
John Sorkin [jsor...@grecc.umaryland.edu]
Sent: Saturday, April 12, 2014 7:37 PM
To: fransiepansiekever...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] R, RStudio, and a server for my iPad.

Grand,
Thank you. I have been able to use my iPad to connect to a server running 
RStudio server as described in an earlier email and can use the virtual 
keyboard, which works but is not convenient as one needs to go from keyboard 
screen to another.
My current problem is that while I can get everything to work when my iPad is 
on my local network, I don't know how to access my server from outside my LAN. 
I know my server's private IP address I know my cable modem's external IP 
address, but I have no idea what IP address to enter in my iPad, when my iPad 
is outside my LAN trying to access my server.
John
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] {metafor} variance explaination for paired pre-test/posttest

2014-04-08 Thread Viechtbauer Wolfgang (STAT)
The standardized mean change using 'change score standardization' is described 
in this article:

Gibbons, R. D., Hedeker, D. R.,  Davis, J. M. (1993). Estimation of effect 
size from a series of experiments involving paired comparisons. Journal of 
Educational Statistics, 18(3), 271-279.

For a comparison of the standardized mean change using change versus raw score 
standardization, see:

Morris, S. B.,  DeShon, R. P. (2002). Combining effect size estimates in 
meta-analysis with repeated measures and independent-groups designs. 
Psychological Methods, 7(1), 105-125.

Viechtbauer, W. (2007). Approximate confidence intervals for standardized 
effect sizes in the two-independent and two-dependent samples design. Journal 
of Educational and Behavioral Statistics, 32(1), 39-60.

These articles also provide equations for the sampling variance of the 
standardized mean change. The equation 1/ni + yi^2/(2*ni) is the estimate based 
on the asymptotic variance of the standardized mean change using change score 
standardization. 

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of John Williams
 Sent: Tuesday, April 08, 2014 02:30
 To: r-help@r-project.org
 Subject: [R] {metafor} variance explaination for paired pre-test/posttest
 
 In a previous post
 https://stat.ethz.ch/pipermail/r-help/2012-April/308946.html
 https://stat.ethz.ch/pipermail/r-help/2012-April/308946.html  , the
 following calculation was given for imputing the variance of change
 scores
 for paired studies:
 
 // begin quote
 
 2) Often, the dependent variable is not the same in each study. Then you
 will have to resort to a standardized outcome measure. There are two
 options:
 
 a) standardization based on the change score standard deviation
 
 Then yi = (m1i - m2i) / sdi with sampling variance vi = 1/ni + yi^2 /
 (2*ni).
 
 // end quote
 
 I used the sampling variance equation above in a paper that is being
 reviewed by a coauthor, who is a biostatistician.
 
 He commented that he has never seen this equation for variance before,
 and
 it looks strange to him. To put my knowledge into perspective, I am an
 undergraduate taking my first statistics course. I imputed the t-
 statistic
 from two-sided p-values reported in the paper, and used that to get the
 sdi
 (as in the previous post).
 
 I consulted the Cochrane Handbook and The Handbook of Research Syntheses
 and
 Meta-analysis 2nd Ed (Cooper, Hedges, Valentine 2009) and couldn't find
 that
 equation anywhere.
 
 Would Prof. Viechtbauer, or anyone else knowledgeable, mind explaining
 the
 sample variance above? I need to be able to defend my choice of equation.
 Since it's the only method that I found that doesn't rely on a
 correlation
 coefficient (which are not included in the papers), I'd like to be able
 to
 justify it and not redo calculations for 23 studies if possible.
 
 Thank you very much,
 
 John
 
 
 John Williams
 ALB Candidate, Harvard University (Expected May 2014)
 johnwilli...@fas.harvard.edu
 jawilliam...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor - why use escalc?

2014-03-14 Thread Viechtbauer Wolfgang (STAT)
Often, there is a mix of information available from the various studies that 
needs to be used to compute the effect sizes or outcomes to be used for the 
meta-analysis. Then you have to 'build up' your dataset in multiple steps and 
you cannot bypass first using escalc().

As a very basic example, suppose you have 2x2 table data for most studies, but 
for a few studies, you only have the odds ratio and corresponding 95% CI (since 
this is all that the authors reported). The odds ratios are easily converted 
into log odds ratios and the CIs can be used to obtain the sampling variances 
of the log odds ratios. And for the studies for which the 2x2 table data is 
available, one can use escalc() to compute the log odds ratios and 
corresponding sampling variances.

Best,
Wolfgang

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Purssell, Ed [ed.purss...@kcl.ac.uk]
Sent: Friday, March 14, 2014 10:11 AM
To: r-help@r-project.org
Subject: [R] Metafor - why use escalc?

Dear All

As you can specify the data directly to rma.uni via n1i, m1i, sd1i, etc in 
Metafor, why would you ever want to use escalc to calculate yi and vi?  Aren't 
these just intermediate steps to the final pooled effect size which is 
calculated by rma.uni; or is there some advantage to calculating yi and vi 
separately using escalc?

Thanks

Ed

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor package

2014-02-12 Thread Viechtbauer Wolfgang (STAT)
Good advice already from Michael and S Ellison.

I must apologize for the 'hack-job of a function' called forest() in metafor. I 
realized a while ago that people would prefer more fine-grained control over 
the various elements of the plot (this has come up a few times before). I think 
Paul Murrell described the issue best in his R Journal article:

http://journal.r-project.org/archive/2012-2/RJournal_2012-2_Murrell.pdf

But it is what it is at this point.

I noticed the problem with the dotted line of the credibility interval myself a 
while back. In an updated version of the metafor package (to be released at 
some point in the near future), there will at least be the possibility to 
control the color of that line. Maybe also the line type (a dotted line is 
indeed often too faint).

You can try changing efac=2 (or something larger than 1) to at least make the 
whiskers longer.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Wednesday, February 12, 2014 12:50
 To: Nathan Pace; r-help@R-project.org
 Subject: Re: [R] metafor package
 
 At 22:11 11/02/2014, Nathan Pace wrote:
 Hi,
 
 I have a random effects meta analysis of a proportion (logit
 transformation) using rma.glmm.
 
 I have created a forest plot of the proportion (inverse logic
 transformation) using forest.rma.
 
 I have added the credibility interval.
 
 The forest plot is saved as a pdf.
 
 The dotted line and whiskers of the credibility interval are too faint.
 
 I need help on the argument(s) to widen the credibility interval
 dots and whiskers.
 
 I have looked at the forest.default function, but don't see anything
 obvious to me.
 
 Dear Nathan
 I think you need to look at forest.rma. There is a fairly obvious
 section (search for addcred). If worst comes to worst you can always
 hack it and save as nathansforest.rma.
 
 Nathan
 
 --
 Nathan Pace, MD, MStat
 Department of Anesthesiology
 University of Utah
 801.581.6393
 n.l.p...@utah.edu
 
  [[alternative HTML version deleted]]
 
 Michael Dewey
 i...@aghmed.fsnet.co.uk
 http://www.aghmed.fsnet.co.uk/home.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] refline in forest() {metafor}

2013-12-12 Thread Viechtbauer Wolfgang (STAT)
Regarding your question: Do you want *another* line or do you just want to move 
the reference line to the value of the summary estimate? The latter can be done 
by passing the value of the summary estimate to the 'refline' argument. If you 
want another line, you could just use the abline function, or, for finer 
control, the segments function. Something like:

segments(coef(res), 0, coef(res), res$k, lty=dashed)

where 'res' is the name of the fitted model object. You may have to play around 
with the 0 and res$k values, so that the line has the 'correct' length.

Thanks for the positive feedback about the package.

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
johnwilli...@fas.harvard.edu [johnwilli...@fas.harvard.edu]
Sent: Thursday, December 12, 2013 6:49 AM
To: r-help@r-project.org
Subject: [R] refline in forest() {metafor}

Hello all,

I am using forest.rma to plot a random effects model meta-analysis. I noticed
that refline sets a vertical line indicating the null hypothesis.

Is there a way to draw another vertical line, possibly dashed, centered on the
summary estimate?

Prof. Viechtbauer, if you happen to read this, I'd like to thank you for making
an excellent package. I have been using the metafor package to do my first
meta-analysis, having never used R before. The documentation is thorough and
intuitive.

Thanks,

John

John Williams
ALB Candidate
Harvard University Extension School
johnwilli...@fas.harvard.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How do I print predicted effect sizes in forest plot?

2013-12-06 Thread Viechtbauer Wolfgang (STAT)
The model you are fitting is a random-effects model and does not include any 
potential moderators/covariates. Therefore, the estimated intercept of that 
model is *the* estimated/predicted (average) effect and it applies to each 
study. That is why the predict function also just gives you that value. That 
value is also included in the forest plot (at the bottom). The predicted 
(average) effect will no longer be the same for each study only if you include 
covariates in the model.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Alma Wilflinger
 Sent: Thursday, December 05, 2013 22:06
 To: R help r-help@r-project.org
 Subject: [R] How do I print predicted effect sizes in forest plot?
 
 Hi,
 
 I am struggling a bit with creating a forest plot containing the predicted
 effect size. As seen in other studies these effect sizes are shown per
 study usually as a light grey diamond - which is what I want to achieve.
 
 The calls I use are:
 iat_result = rma(yi=Mean, vi=Variance_rounded, ni=N, sei=Std_error,
 slab=Study_Name, subset=(Country == AUT), data=cma_iat, method=HS)
 
 summary.rma(iat_result)
 
 
 #not sure how to use it or if needed
 #predict(iat_result)
 
 forest(iat_result)
 
 
 At the end I am getting the forest plot as is without the predicted
 values.
 
 I am not sure if I need the predict function and how to use it? - the
 predict function deliveres the same values as already computed in the rma
 object.
 
 
 I checked the manual for package metafor but was not able to find out how
 to print the predicted values per study.
 
 
 kind regards, Alma
   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How do I print predicted effect sizes in forest plot?

2013-12-06 Thread Viechtbauer Wolfgang (STAT)
One more thing ... You used the command:

iat_result = rma(yi=Mean, vi=Variance_rounded, ni=N, sei=Std_error, 
slab=Study_Name, subset=(Country == AUT), data=cma_iat, method=HS)

This probably does not do what you want it to do. First of all, if you specify 
vi, there is no need to specify sei (or vice-versa). One is sufficient. But 
more crucially, I assume 'Mean' is what it says it is - a mean of a certain 
variable X. And I assume that 'Variance_rounded' is the variance of said 
variable X. But vi is used to specify the *sampling variance* of yi (or sei is 
used to specify the standard error), which, for a mean, is the variance divided 
by N (and the standard error is the SD divided by the square root of N):

http://en.wikipedia.org/wiki/Standard_error_of_the_mean#Standard_error_of_the_mean

So, my hunch is that you are not supplying the right information to the rma() 
function.

Best,
Wolfgang 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Alma Wilflinger
 Sent: Thursday, December 05, 2013 22:06
 To: R help r-help@r-project.org
 Subject: [R] How do I print predicted effect sizes in forest plot?
 
 Hi,
 
 I am struggling a bit with creating a forest plot containing the predicted
 effect size. As seen in other studies these effect sizes are shown per
 study usually as a light grey diamond - which is what I want to achieve.
 
 The calls I use are:
 iat_result = rma(yi=Mean, vi=Variance_rounded, ni=N, sei=Std_error,
 slab=Study_Name, subset=(Country == AUT), data=cma_iat, method=HS)
 
 summary.rma(iat_result)
 
 
 #not sure how to use it or if needed
 #predict(iat_result)
 
 forest(iat_result)
 
 
 At the end I am getting the forest plot as is without the predicted
 values.
 
 I am not sure if I need the predict function and how to use it? - the
 predict function deliveres the same values as already computed in the rma
 object.
 
 
 I checked the manual for package metafor but was not able to find out how
 to print the predicted values per study.
 
 
 kind regards, Alma
   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor escalc(measure=SMCC)

2013-11-21 Thread Viechtbauer Wolfgang (STAT)
.cmicalc is a non-exported function. You can see the code with:

getAnywhere(.cmicalc)

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of petre...@unina.it
 Sent: Thursday, November 21, 2013 13:39
 To: r-help@r-project.org
 Subject: [R] metafor escalc(measure=SMCC)
 
 Many thanks to Wolfgang Viechtbauer for the prompt and clear answer.
 However, I'm unable to understand what .cmicalc mathematically does in the
 code line:
 
 cmi - .cmicalc(mi)
 
 I look in the metafor documentation and in R (?.cmical and ??.cmicalc) but
 I have no result. Please, can I have further explanation on this point?
 
 Sorry for the trouble
 
 Sincerely
 
 Mario Petretta
 Department of Translational Medical Sciences
 Naples University Federico II
 Italy
 
 
 Message: 50
 Date: Tue, 19 Nov 2013 11:48:33 +0100
 From: Viechtbauer Wolfgang (STAT)
 wolfgang.viechtba...@maastrichtuniversity.nl
 To: petre...@unina.it petre...@unina.it, r-help@r-project.org
 r-help@r-project.org
 Subject: Re: [R] metafor escalc(measure=SMCC)
 Message-ID:
 077E31A57DA26E46AB0D493C9966AC730D9925568A@UM-
 MAIL4112.unimaas.nl
 Content-Type: text/plain; charset=us-ascii
 
 Dear Mario,
 
 You can always just inspect the code:
 
 escalc.default
 
 Best,
 Wolfgang
 
 --
 Wolfgang Viechtbauer, Ph.D., Statistician
 Department of Psychiatry and Psychology
 School for Mental Health and Neuroscience
 Faculty of Health, Medicine, and Life Sciences
 Maastricht University, P.O. Box 616 (VIJV1)
 6200 MD Maastricht, The Netherlands
 +31 (43) 388-4170 | http://www.wvbauer.com
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
  On Behalf Of petre...@unina.it
  Sent: Tuesday, November 19, 2013 11:29
  To: r-help@r-project.org
  Subject: [R] metafor escalc(measure=SMCC)
 
  Dear all,
 
  I use R 3.0 for Windows.
 
  I ask how escalc(measure=SMCC) [metafor package] mathematically
  calculate yi and vi when only change score and SD change score are
  provided.
 
  I used the example (repoted below) posted by Qiang Yue at:
 
  http://r.789695.n4.nabble.com/using-metafor-for-meta-analysis-of-before-
  after-studies-escalc-SMCC-td4667233.html
 
  but it is unclear for me the formula used to derive y1 and v1. I read
  the documentation of metafor package and it is all very well
  described, but I ask if possible for the formula used by
  escalc(measure=SMCC) to mathematically calculate yi and vi.
  Unfortunatel, I have no free access to the paper quoted in metafor
  package.
 
  Beginning example:
 
  fMRS
  author year n mean_r sd_r mean_s sd_s r
  1 Tom  2006 9  0   0 0.12 0.030   0
  2 Jack 2012 6  0   0 0.23 0.050   0
  3 Zhu  2013 8  0   0 0.18 0.050   0
 
  
 
 dat_SMCC=escalc(measure=SMCC,data=fMRS,ni=n,m1i=mean_s,m2i=mean_r,sd1i=s
  d_s,sd2i=sd_r,ri=r
  ,append=TRUE)
   dat_SMCC
  author year n mean_r sd_r mean_s sd_s r  yi  vi
  1 Tom 2006  9  0 00.12  0.03  0 3.6108 0.8354
  2 Jack 2012 6  0 00.23  0.05  0 3.8674 1.4131
  3 Zhu 2013  8  0 00.18  0.05  0 3.1975 0.7640
 
 
 
  Sincerely
 
  --
  Mario Petretta
  Department of Translational Medical Sciences
  Naples University Federico II
  Italy
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor escalc(measure=SMCC)

2013-11-19 Thread Viechtbauer Wolfgang (STAT)
Dear Mario,

You can always just inspect the code:

escalc.default

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of petre...@unina.it
 Sent: Tuesday, November 19, 2013 11:29
 To: r-help@r-project.org
 Subject: [R] metafor escalc(measure=SMCC)
 
 Dear all,
 
 I use R 3.0 for Windows.
 
 I ask how escalc(measure=SMCC) [metafor package] mathematically
 calculate yi and vi when only change score and SD change score are
 provided.
 
 I used the example (repoted below) posted by Qiang Yue at:
 
 http://r.789695.n4.nabble.com/using-metafor-for-meta-analysis-of-before-
 after-studies-escalc-SMCC-td4667233.html
 
 but it is unclear for me the formula used to derive y1 and v1. I read
 the documentation of metafor package and it is all very well
 described, but I ask if possible for the formula used by
 escalc(measure=SMCC) to mathematically calculate yi and vi.
 Unfortunatel, I have no free access to the paper quoted in metafor
 package.
 
 Beginning example:
 
 fMRS
 author year n mean_r sd_r mean_s sd_s r
 1 Tom  2006 9  0   0 0.12 0.030   0
 2 Jack 2012 6  0   0 0.23 0.050   0
 3 Zhu  2013 8  0   0 0.18 0.050   0
 
 
 dat_SMCC=escalc(measure=SMCC,data=fMRS,ni=n,m1i=mean_s,m2i=mean_r,sd1i=s
 d_s,sd2i=sd_r,ri=r
 ,append=TRUE)
  dat_SMCC
 author year n mean_r sd_r mean_s sd_s r  yi  vi
 1 Tom 2006  9  0 00.12  0.03  0 3.6108 0.8354
 2 Jack 2012 6  0 00.23  0.05  0 3.8674 1.4131
 3 Zhu 2013  8  0 00.18  0.05  0 3.1975 0.7640
 
 
 
 Sincerely
 
 --
 Mario Petretta
 Department of Translational Medical Sciences
 Naples University Federico II
 Italy
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dose-response relationship using metafor?

2013-09-19 Thread Viechtbauer Wolfgang (STAT)
Can you provide a minimal and self-contained example showing/illustrating what 
you have done and would like to test? Based on the information provided, I 
could only make a vague suggestion along the lines of: You could include dose 
in an appropriate meta-regression model and then examine whether polynomial 
versions of the dose variable are significant (which would suggest a non-linear 
relationship).

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Ross, Stephanie
 Sent: Wednesday, September 18, 2013 21:41
 To: r-help@r-project.org
 Subject: [R] Dose-response relationship using metafor?
 
 I am currently working a meta-analysis that is exploring the effect of a
 drug on plasma lipid levels. However, I am primarily interested in
 assessing the overall dose-response relationship with mean change in
 lipids. I have used the metafor package to conduct a meta-regression but
 is there a way to determine if this relationship is linear? Something like
 a p-value for trend?
 Thanks so much!
 
 
 PHRI DISCLAIMER This information is directed in confidence solely to the
 person named above and may not otherwise be distributed, copied or
 disclosed. Therefore, this information should be considered strictly
 confidential. If you have received this email in error, please notify the
 sender immediately via a return email for further direction. Thank you for
 your assistance.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Meta-analysis on a repeated measures design with multiple trials per subject using metafor

2013-07-08 Thread Viechtbauer Wolfgang (STAT)
It seems to me that the most straightforward approach would be to pool the b 
coefficients directly. I assume you used some kind of mixed-effects logistic 
model to analyze those data for each study with random effects for subjects and 
a dummy variable for treatment (besides possibly some other covariates) and the 
coefficient of interest is the one corresponding to the dummy for treatment. 
Given those 5 coefficients and the corresponding standard errors, you can then 
pool them with rma(b, sei=se), where 'b' is the vector with the coefficients 
and 'se' is the vector with the corresponding standard errors.

Careful: rma(b, se) would not be correct, since the second argument is assumed 
to represent the *sampling variances*:

 library(metafor)
 args(rma)
function (yi, vi, sei, [SNIP])

So, due to positional matching of arguments, rma(b, se) would be treated as 
rma(yi=b, vi=se), which is not what you want (you would not be the first person 
to fall into that trap). 

And yes, if you include additional covariates in the mixed-effects logistic 
model, then of course the b's and se's will change, but I see no issue here. 
It's just a question of whether you want to pool raw or adjusted coefficients 
(if you do adjust though, it would be best to adjust for the same covariates, 
so that the adjusted coefficients are directly comparable).

Aside from all of that, there is another approach you could take. Since you 
have the raw data from all 5 studies, you could just as well pool the raw data 
into one dataset and analyze that. This is essentially an individual person 
(or patient) data meta-analysis (IPDMA). You would then include either fixed 
or random effects for studies and you probably would also want the treatment 
effect to vary randomly across studies. That approach should give you similar 
results as pooling the 5 coefficients (which is a sort of two-step approach).

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: Marc Heerdink [mailto:m.w.heerd...@uva.nl]
 Sent: Sunday, July 07, 2013 23:51
 To: Michael Dewey
 Cc: Viechtbauer Wolfgang (STAT); r-help@r-project.org
 Subject: Re: [R] Meta-analysis on a repeated measures design with multiple
 trials per subject using metafor
 
 Dear Michael and other readers,
 
 Please see below for my answers to your questions about my data.
 
 On 07/06/2013 02:56 PM, Michael Dewey wrote:
 [..]
  Because everything was randomized, I can only calculate the total
  number of times a certain response was used under each type of trial.
  There is no pairing of trials under two treatments, so I am forced to
  use the marginal totals from your table.
 
  But presumably you could calculate some statistic suitable for
  summarising the relevant features here? Difference in proportions, odds
  ratio, ...
 
 Using the totals, it is indeed easy to calculate the difference in
 proportions or odds ratio based on these totals. However, I am not sure
 how I should calculate a study-level statistic suitable for
 meta-analysis on the basis of these participant-level proportion
 differences.
 
 So, for instance, I have the following table;
 
 ppproportion_difference
 1 0.1
 2 0.05
 3 0.08
 4 0.02
 ..
 N ..
 
 Can I just calculate the mean and standard deviation of these proportion
 differences -- mean(proportion_difference) and sd(proportion_difference)
 -- and use these for meta-analysis? If yes, what escalc measure should I
 use?
 
 [..]
  One alternative that I have tried over the last few days, is to use
  the b parameter of interest and it's corresponding standard error from
  the lme4 regression output that I use to analyse the individual
  experiments. Then, I use rma(yi, sei) to do a meta-analysis on these
  parameters. I am not sure this is correct though, since it takes into
  account between-subjects variance (through a random effect for
  subject), and it is sensitive to the covariates/moderators I include
  in the models that I get the b parameters from.
 
  So you end up with 5 values of b? The fact that they adjust for
  different moderators does not seem an issue to me, indeed it could be
  argued to be an advantage of the meta-analytic approach here.
 
 OK, thank you for your comment on this one. I think the results of a
 meta-analysis using these 5 b values are indeed more or less sensible,
 which is encouraging. I think I will go this way if it turns out I
 cannot find a simpler approach, as a simpler approach would be easier to
 sell to potential reviewers.
 
 [..
  I think we are all assuming you have different participants in each
  experiment but I thought I would raise that as a question.
 
 You are right in assuming

Re: [R] Meta-analysis on a repeated measures design with multiple trials per subject using metafor

2013-07-04 Thread Viechtbauer Wolfgang (STAT)
Dear Marc,

Let me see if I understand the type of data you have. You say that you have 5 
experiments. And within each experiment, you have n subjects and for each 
subject, you have data in the form described in your post. Now for each 
subject, you want to calculate some kind of measure that quantifies how much 
more likely it was that subjects gave/chose response 2 under treatment 2 versus 
treatment 1. So, you would have n such values. And then you want to pool those 
values over the n subjects within a particular experiment and then ultimately 
over the 5 experiments. Is that correct so far?

Assuming I got this right, let me ask you about those data that you have for 
each subject. In particular, are these paired data? In other words, is there 
are 1:1 relationship between the 30 trials under treatment 1 versus treatment 
2? Or phrased yet another way, can you construct a table like this for every 
subject:

trt 2
 
 resp1 resp2  
trt 1 resp1  a b  10
  resp2  c d  20
 2010 30

Note that I added the marginal counts based on your example data, but this is 
not sufficient to reconstruct how often response 1 was chosen for the same 
trial under both treatment 1 and treatment 2 (cell a). And so on for the 
other 3 cells.

If all of this applies, then essentially you are dealing with dependent 
proportions and you can calculate the difference y = (20/30)-(10/30) as you 
have done. The corresponding sampling variance can be estimated with v = var(y) 
= (a+b)*(c+d)/t^3 + (a+c)*(b+d)/t^3 - 2*(a*d/t^3 - b*c/t^3) (where t is the 
number of trials, i.e., 30 in the example above). See, for example, section 
10.1.1. in Agresti (2002) (Categorical data analysis, 2nd ed.).

So, ultimately, you will have n values of y and v for a particular experiment 
and then the same thing for all 5 experiments. You can then pool those values 
with rma(yi, vi) in metafor (yi and vi being the vectors of the y and v 
values). You probably want to add a factor to the model that indicates which 
experiment those values came from. So, something like: rma(yi, vi, mods = ~ 
factor(experiment)).

Well, I hope that I understood your data correctly.

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Marc Heerdink [m.w.heerd...@uva.nl]
Sent: Wednesday, July 03, 2013 2:15 PM
To: r-help@r-project.org
Subject: [R] Meta-analysis on a repeated measures design with multiple trials 
per subject using metafor

Hi all,

I am currently attempting to compile a summary of a series of five
psychological experiments, and I am trying to do this using the metafor
package. However, I am quite unsure which of the scenarios described in
the metafor help pages applies to these data, because it is a repeated
measures design, with multiple trials in each condition.

Assume that for every participant, I have a basic contingency table such
as this one:

treatment
1   2
response
1   10  20
2   20  10

(if this ASCII version does not work, I have 30 trials in each
treatment, and participants give either response 1 or 2; the exact
numbers don't matter)

The problem that I am trying to solve is how to convert these numbers to
an effect size estimate that I can use with metafor.

As far as I understand it, I can only use it to get an effect size for
outcomes that are dichotomous; i.e., either 1 or 0 for any subject.
However, I have proportion data for every participant.

I have considered and tried these strategies:

1. Base the effect size on within-participant proportion differences.
That is, in the table above, the treatment effect would be
(20/30)-(10/30) = 1/3; and I would take the M and SD of these values to
estimate a study-level effect (MN measure in metafor).

2. Use the overall treatment * response contingency table, ignoring the
fact that these counts come from different participants (PHI or OR
measures in metafor). In a study with 10 participants, I would get cell
counts around 150.

However, from the research I've done into this topic, I know that 1) is
not applicable to (as far as I understand) an odds ratio, and I suspect
2) overestimates the effect.

A third method would be to use the regression coefficients, that I can
easily obtain since I have all the raw data that I need. However, it is
unclear to me whether and if yes, how I can use these in the metafor
package.

 From my understanding of another message about this topic I found on
this list (1), I understand that having access to the raw data is 

Re: [R] Strange behaviour of R graphics copied to PowerPoint

2013-06-03 Thread Viechtbauer Wolfgang (STAT)
I have come across this issue many times. I have yet to find a pattern in what 
causes this.

At least I can offer a workaround. Instead of using Save As to create the 
pdf, what I do is Print with Adobe PDF as the printer. This gets rid of 
those lines and the resulting pdf looks just as nice.

There is one slight disadvantage to this. Hyperlinks in your Powerpoint 
presentation that are not directly given as a URL (with no line breaks) will no 
longer work. So, if you have:

http://www.r-project.org/

in your slide, then this will be clickable. However, if the hyperlink is a 
property of the object (e.g., text, button) in the slide, then it won't be 
anymore clickable when you print it (while Save As does preserve those 
links).

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jeff Newmiller
 Sent: Monday, June 03, 2013 13:58
 To: Erling Johan Frøysa; r-help@r-project.org
 Subject: Re: [R] Strange behaviour of R graphics copied to PowerPoint
 
 I have not seen this particular problem, but I have seen other problems
 and I tend to export bitmaps or pdf files as a result.
 
 Note that a reproducible example is usually required to to obtain help on
 this list, and posting in HTML format is bad because it mutilates example
 code, so fix your email client. Please read the Posting Guide for more
 etiquette tips.
 --
 -
 Jeff NewmillerThe .   .  Go
 Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
 Go...
   Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.
 rocks...1k
 --
 -
 Sent from my phone. Please excuse my brevity.
 
 Erling Johan Frøysa erling.fro...@gmail.com wrote:
 
 Hello,
 
 I am using R to create graphics, especially to plot time series charts.
 These charts are then copied as metafiles (for best quality) to a
 PowerPoint
 presentation and then saved to PDF (via the Save As dialog).
 
 Attached is two pictures. The first picture shows how my chart looks
 like in
 the R Graphics window, and the second picture shows how the chart
 becomes
 after saving it to PDF.
 
  http://r.789695.n4.nabble.com/file/n4668522/R.png
 
  http://r.789695.n4.nabble.com/file/n4668522/Rppt.png
 
 As you can see. After saving the metafile to PDF via PowerPoint, some
 straight lines appears (it seems like all of the lines has the same
 origin
 in the upper left corner and ends somewhere on the times series line).
 This
 happens in both plot() and ggplot(). The problem appears more often
 when
 using daily data in my time series. With monthly data the problem don't
 exist.
 
 Have anyone experienced this before? Do you think the problem is
 related to
 R or to Powerpoint?
 
 Thanks all,
 
 E
 
  [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] using metafor for meta-analysis of before-after studies (escalc, SMCC)

2013-05-23 Thread Viechtbauer Wolfgang (STAT)
The mean percentage change and the raw mean change are not directly comparable, 
even after standardization based on the SD of the percentage change or raw 
change values. So, I would not mix those in the same analysis.

Best,
Wolfgang

 -Original Message-
 From: Qiang Yue [mailto:qiangm...@gmail.com]
 Sent: Wednesday, May 22, 2013 20:38
 To: Viechtbauer Wolfgang (STAT); r-help
 Subject: Re: RE: [R] using metafor for meta-analysis of before-after
 studies (escalc, SMCC)
 
 Dear Dr. Viechtbauer:
 
 Thank you very much for sparing your precious time to answer my question.
 I still want to make sure for the third question below:  for studies which
 only reported percentage changes (something like: the metabolite
 concentration increased by 20%+/-5% after intervention), we can not use
 the percentage change to calculate SMCC, but have to get the raw change
 first?
 
 With best wishes.
 
 Qiang Yue
 
 From: Viechtbauer Wolfgang (STAT)
 Date: 2013-05-21 10:09
 To: Moon Qiang; r-help
 Subject: RE: [R] using metafor for meta-analysis of before-after studies
 (escalc, SMCC)
 Please see my answers below.
 
 Best,
 Wolfgang
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
  On Behalf Of Moon Qiang
  Sent: Thursday, May 16, 2013 19:12
  To: r-help
  Subject: [R] using metafor for meta-analysis of before-after studies
  (escalc, SMCC)
 
  Hello.
 
  I am trying to perform meta-analysis on some before-after studies. These
  studies are designed to clarify if there is any significant metabolic
  change before and after an intervention. There is only one group in thes
 e
  studies, i.e., no control group. I followed the e-mail communication of
  R-help (https://stat.ethz.ch/pipermail/r-help/2012-
 April/308946.html ) and
  the Metafor Manual (version 1.8-0, released 2013-04-
 11, relevant contents
  can be found on pages of 59-61 under 'Outcome Measures for Individual
  Groups '). I made a trial analysis and attached the output here, I wonde
 r
  if anyone can look through it and give me some comments.
   I have three questions about the analysis:
 
  1) Most studies reported the before-and-after raw change as Mean+/-
 SD, but
  few of them have reported the values of before-intervention (mean_r and
  sd_r) and the values of after-
 intervention (mean_s and sd_s), and none of
  them reported the r value (correlation for the before- and after-
  intervention measurements). Based on the guideline of the Metafor manual
 ,
  I
  set the raw mean change as m1i (i.e., raw mean change=mean_s=m1i), and s
 et
  the standard deviation of raw change as sd1i (i.e., the standard deviati
 on
  of raw change =sd_s=sd1i), and set all other arguments including m2i,
  sd2i,
  ri as 0, and then calculated the standardized mean change using change
  score (SMCC). I am not sure if all these settings are correct.
 
 This is correct. The escalc() function still will compute (m1i-
 m2i)/sqrt(sd1i^2 + sd2i^2 -
  2*ri*sd1i*sd2i), but since m2i=sd2i=ri=0, this is equivalent to mean_chan
 ge / SD_change, which is what you want.
 
 Make sure that mean_s is NOT the standard error (SE) of the change scores,
  but really the SD.
 
  2) A few studies have specified individual values of m1i, m2i, sd1i, sd2
 i
  ,
  but did not report the change score or its sd. So can I set r=0 and use
  these values to calculate SMCC? Since SMCC is not calculated in the same
  way like 1), will this be a problem?
 
 Yes, this will be a problem, since you now really assume that r=0, which i
 s not correct. Maybe you can back-
 calculate r from other information (e.g., the p or t value from a t-test -
 - see https://stat.ethz.ch/pipermail/r-help/2012-
 April/308946.html). Or you could try to get r from the authors (then you c
 ould also just directly ask for the change score mean and SD). If that is
 not successful, you will have to impute some kind of reasonable value for
 r and do a sensitivity analysis in the end.
 
  3) some studies reported the percentage mean changes instead of raw mean
  change (percentage change=(value of after-intervention - value of before
  intervention) / value of before intervention), I think it may not be the
  right way to simply substitute the raw mean change with the percentage
  mean
  changes. Is there any method to deal with this problem?
 
 Don't know anything off the top of my head.
 
  Any comments are welcome.
 
  With best regards.
    --
   Qiang Yue

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor matrix error

2013-05-22 Thread Viechtbauer Wolfgang (STAT)
Dear Branwen,

This means that your design matrix is not of full rank (in a more recent 
version of the metafor package, the error message is a bit more informative; 
i.e., please upgrade). Since continent is a factor, this should imply that 
one of the levels never actually occurs, leading to a column of 0s in the 
design matrix, which then causes the problem with the matrix inversion.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Branwen Owen
 Sent: Tuesday, May 21, 2013 23:12
 To: r-help@r-project.org
 Subject: [R] metafor matrix error
 
 hi
  I've been using this code to set a reference level for uni and
 multivariate analysis
   rmix$interviewmethodcode-
 relevel(mix$interviewmethodcode,ref=SAQ)
   summary(rma.1-
 rma(yi,vi,mods=~interviewmethodcode,data=rmix,method=SJ,knha=F,weighted=
 F,intercept=T))
 giving this output:
   Model Results:
   estimate  se zvalpvalci.lb
 ci.ub
   intrcpt 0.1437  0.0176   8.1485  .0001
 0.1091  0.1783  ***
   interviewmethodcodeACASI0.0022  0.0412   0.0545  0.9566  -
 0.0784  0.0829
   interviewmethodcodeFTFI-0.0926  0.0656  -1.4112  0.1582  -
 0.2213  0.0360
 
 However, when i use the same code with a different variable (below) I get
 the error message -  Error in qr.solve(wX, diag(k)) : singular matrix 'a'
 in solve.
  rmix$continent-relevel(mix$continent,ref=North America)
  summary(rma.1-
 rma(yi,vi,mods=~continent,data=rmix,method=SJ,knha=F,weighted=F,intercep
 t=T))
 
 Can anyone help to see where the problem is?
 thanks
 Branwen
 
 --
 View this message in context: http://r.789695.n4.nabble.com/metafor-
 matrix-error-tp4667653.html
 Sent from the R help mailing list archive at Nabble.com.
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] using metafor for meta-analysis of before-after studies (escalc, SMCC)

2013-05-21 Thread Viechtbauer Wolfgang (STAT)
Please see my answers below.

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Moon Qiang
 Sent: Thursday, May 16, 2013 19:12
 To: r-help
 Subject: [R] using metafor for meta-analysis of before-after studies
 (escalc, SMCC)
 
 Hello.
 
 I am trying to perform meta-analysis on some before-after studies. These
 studies are designed to clarify if there is any significant metabolic
 change before and after an intervention. There is only one group in these
 studies, i.e., no control group. I followed the e-mail communication of
 R-help (https://stat.ethz.ch/pipermail/r-help/2012-April/308946.html ) and
 the Metafor Manual (version 1.8-0, released 2013-04-11, relevant contents
 can be found on pages of 59-61 under 'Outcome Measures for Individual
 Groups '). I made a trial analysis and attached the output here, I wonder
 if anyone can look through it and give me some comments.
  I have three questions about the analysis:
 
 1) Most studies reported the before-and-after raw change as Mean+/-SD, but
 few of them have reported the values of before-intervention (mean_r and
 sd_r) and the values of after-intervention (mean_s and sd_s), and none of
 them reported the r value (correlation for the before- and after-
 intervention measurements). Based on the guideline of the Metafor manual,
 I
 set the raw mean change as m1i (i.e., raw mean change=mean_s=m1i), and set
 the standard deviation of raw change as sd1i (i.e., the standard deviation
 of raw change =sd_s=sd1i), and set all other arguments including m2i,
 sd2i,
 ri as 0, and then calculated the standardized mean change using change
 score (SMCC). I am not sure if all these settings are correct.

This is correct. The escalc() function still will compute (m1i-m2i)/sqrt(sd1i^2 
+ sd2i^2 - 2*ri*sd1i*sd2i), but since m2i=sd2i=ri=0, this is equivalent to 
mean_change / SD_change, which is what you want.

Make sure that mean_s is NOT the standard error (SE) of the change scores, but 
really the SD.

 2) A few studies have specified individual values of m1i, m2i, sd1i, sd2i
 ,
 but did not report the change score or its sd. So can I set r=0 and use
 these values to calculate SMCC? Since SMCC is not calculated in the same
 way like 1), will this be a problem?

Yes, this will be a problem, since you now really assume that r=0, which is not 
correct. Maybe you can back-calculate r from other information (e.g., the p or 
t value from a t-test -- see 
https://stat.ethz.ch/pipermail/r-help/2012-April/308946.html). Or you could try 
to get r from the authors (then you could also just directly ask for the change 
score mean and SD). If that is not successful, you will have to impute some 
kind of reasonable value for r and do a sensitivity analysis in the end.

 3) some studies reported the percentage mean changes instead of raw mean
 change (percentage change=(value of after-intervention - value of before
 intervention) / value of before intervention), I think it may not be the
 right way to simply substitute the raw mean change with the percentage
 mean
 changes. Is there any method to deal with this problem?

Don't know anything off the top of my head.

 Any comments are welcome.
 
 With best regards.
   --
  Qiang Yue

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error when adding lines to a plot using the mixed-effect model and metafor package

2013-03-20 Thread Viechtbauer Wolfgang (STAT)
See comments below.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Hewitt, Charlotte
 Sent: Tuesday, March 19, 2013 19:17
 To: r-help@R-project.org
 Subject: [R] Error when adding lines to a plot using the mixed-effect
 model and metafor package
 
 Hi,
 
 I am a student using R for my final year project, with the metafor package
 being particularly helpful. I have been following the steps laid out in
 the manual 'Conducting Meta-analysis in R with the Metafor package'
 (Viechtbauer, 2010) and applying it to my own data of infected Anopheles
 mosquitoes across Africa.
 
 In particular, I am attempting to apply a mixed-effect model to my data
 with absolute latitude as a moderator as per the example in the manual. I
 am able to generate a plot of Relative Risk against absolute latitude
 without issue, but when I try to add lines in from the predicted values
 generated I continually get an error:
 
 Error in xy.coords(x, y) : 'x' and 'y' lengths differ
 
 However, I have used the length function on both my x and y co-ordinates
 and found no difference in lengths. If anyone could shed some light on
 this I'd really appreciate it. The code I used can be found below:
 
  mixed-read.delim(regressiontest.txt)
  mixed
  study year ablat mosq1pos mosq1neg mosq2pos mosq2neg
 1 Cano et al.  2006 2   42  237  148  629
 2 Kerah - Hinzoumbe et al. 200910  103 72603  215
 3Konate et al. 199413   83 5714   48 3609
 4   Mwanzia et al. 2011 42 89710  100

So there are 4 studies in your dataset.

  dat-escalc(measure=RR, ai = mosq1pos, bi = mosq1neg, ci = mosq2pos,
 di = mosq2neg, data = mixed, append = TRUE)
  res-rma(yi, vi, mods = ablat, data=dat)
  predict(res,transf = exp, addx = TRUE)
  preds-predict(res, transf = exp)

This will save the predicted values *for those 4 studies* in preds.

  wi-1/sqrt(dat$vi)
  size-0.5 + 3 *(wi-min(wi))/(max(wi)) - min(wi)
  plot(dat$ablat, exp(dat$yi), pch = 19, cex = size, xlab = Absolute
 Latitude, ylab = Relative Risk, las=1, bty = l, log = y)
  lines(0:15, preds$pred)

So you are trying to plot a line based on 16 x-values (0:15) and the 4 y-values 
in preds. That can't work. If you want to obtain the predicted values for ablat 
values equal to 0:15, then you need to do:

preds - predict(res, newmods=0:15, transf=exp)

And then the code should work.

 Many thanks,
 Charlotte Hewitt

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor - multivariate analysis

2013-03-15 Thread Viechtbauer Wolfgang (STAT)
Dear Owen,

What is your definition of multivariate analysis? Do you mean: A 
meta-regression model with more than one predictor/moderator? In that case, 
yes, metafor handles that. Usually, this is referred to as multiple 
regression (as opposed to simple regression with a single predictor) -- and 
in the case of a meta-analysis, I guess one could call it multiple 
meta-regression. 

If you are referring to a model that handles statistical dependencies in the 
observed outcomes (and hence requires multivariate methods), then you will have 
to use some other package (e.g., mvmeta).

See also:

http://stats.stackexchange.com/questions/2358/explain-the-difference-between-multiple-regression-and-multivariate-regression

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Owen, Branwen
 Sent: Friday, March 15, 2013 11:23
 To: r-help@r-project.org
 Subject: [R] metafor - multivariate analysis
 
 
 
 
 Dear Metafor users, I'm conducting a metaanalysis of prevalence of a
 particular behaviour based on someone elses' code. I've been labouring
 under the impression that this:
 
 summary(rma.1-
 rma(yi,vi,mods=cbind(approxmeanage,interviewmethodcode),data=mal,method=D
 L,knha=F,weighted=F,intercept=T))
 
 is doing the multivariate analysis that i want, but have read that
 multivariate analysis can't be done in metafor.
 
 this is the output:
 
 Mixed-Effects Model (k = 22; tau^2 estimator: DL)
 
 logLik Deviance AIC BIC
 18.7726 -37.5452 -27.5452 -22.0899
 
 tau^2 (estimate of residual amount of heterogeneity): 0.0106
 tau (sqrt of the estimate of residual heterogeneity): 0.1031
 
 Test for Residual Heterogeneity:
 QE(df = 18) = 1273.9411, p-val  .0001
 
 Test of Moderators (coefficient(s) 2,3,4):
 QM(df = 3) = 11.0096, p-val = 0.0117
 
 Model Results:
 
 estimate se zval pval ci.lb ci.ub
 intrcpt 0.4014 0.1705 2.3537 0.0186 0.0671 0.7356 *
 continent -0.0206 0.0184 -1.1200 0.2627 -0.0568 0.0155
 approxmeanage 0.0076 0.0091 0.8354 0.4035 -0.0102 0.0254
 interviewmethodcode -0.0892 0.0273 -3.2702 0.0011 -0.1426 -0.0357 **
 
 ---
 Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 
 my questions are
 1. what is this line of code?
 2. if it isn't multivariate analysis, will i have to use the mvmeta
 instead.
 
 thanks very much for any help
 Branwen
 .http://r.789695.n4.nabble.com/metafor-multivariate-analysis-
 td4661233.html
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Create patterns within a plot?

2013-03-14 Thread Viechtbauer Wolfgang (STAT)
Same idea, but just using base graphics and using an x-axis with log units:

library(metafor)

data(dat.bcg)

res - rma(measure=OR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
slab=paste(dat.bcg$author, dat.bcg$year, sep=, ))

forest(res, cex=.9, at=log(c(.05, .25, 1, 4)), xlim=c(-10,7), atransf=exp)
rect(log(0.5), 0.1, log(1.5), 13.9, col=gray90, border=NA)
par(new=TRUE)
forest(res, cex=.9, at=log(c(.05, .25, 1, 4)), xlim=c(-10,7), atransf=exp)

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jim Lemon
 Sent: Thursday, March 14, 2013 12:19
 To: Öhagen Patrik
 Cc: R hELP
 Subject: Re: [R] Create patterns within a plot?
 
 On 03/14/2013 09:19 PM, Öhagen Patrik wrote:
 
  Please note that I want to use log-scale on the x-axis which makes the
 polygon function sad.
 
  Cheers, Patrik
 
 
  -Ursprungligt meddelande-
  Från: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 För Öhagen Patrik
  Skickat: den 14 mars 2013 08:47
  Till: R hELP
  Ämne: [R] Create patterns within a plot?
 
 
 
  Dear All,
 
  As an attempt to highlight the overall pattern in a Forest plot, I would
 like to highlight the area around HR=1. I cannot find any simple tools
 for painting a grey ribbon between 0.9 and 1.1. Any suggestions?
 
 Hi Patrik,
 This is a bit indirect, but it may do what you want. The example plot is
 from the metafor package (see forest.default):
 
 forest(dat$yi, dat$vi)
 library(plotrix)
 gradient.rect(0.9,-0.1,1.1,14,
   reds=c(1,0.5,1),greens=c(1,0.5,1),
   blues=c(1,0.5,1),gradient=x,border=NA)
 par(new=TRUE)
 forest(dat$yi, dat$vi)
 
 Jim
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor SMCR Pre-Post Effect sizes

2013-03-04 Thread Viechtbauer Wolfgang (STAT)
Absolutely correct. The documentation wasn't clear on that. Changed for the 
next version of the package. And the escalc() function now no longer checks for 
sd2i, since it is not needed anyway (for SMCR). For now, you will just have 
to set sd2i to something (e.g., 0).

Thanks for bringing this to my attention!

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Markus Kösters
 Sent: Saturday, March 02, 2013 23:31
 To: R-help@r-project.org
 Subject: [R] Metafor SMCR Pre-Post Effect sizes
 
 Dear all,
 
 I am very grateful that Wolfgang Viechtbauer implemented the standardised
 mean change for dependent
 groups. I was playing around a bit today, and I am not sure if I
 understand the SMCR procedure correctly. The documentation states that
 sd1i and sd2i are needed, but it seems to me that SMCR is ignoring sd2i
 (so Variances are not pooled). Instead, it uses sd1i (pre-test sd), as
 suggested by Becker 1988. Is that correct?
 
 Thank you all very much for your time and help,
 
 Markus
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor - interpretion of QM in mixed-effects model with factor moderator

2013-02-27 Thread Viechtbauer Wolfgang (STAT)
Please see my comments below.

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Rachel Slatyer
 Sent: Wednesday, February 27, 2013 06:00
 To: R-help@r-project.org
 Subject: [R] metafor - interpretion of QM in mixed-effects model with
 factor moderator
 
 Hi,
 
 I'm using metafor to perform a mixed-effects meta-analysis. I'd like to
 test whether the effect is different for animals and plants/whether
 group
 (animal/plant) influences the effect size, but am having trouble
 interpreting the results I get. I've read previous posts about QM in
 metafor, but I'm still a bit confused. I've dummy-coded the factors:
 
 MData$k.animal-ifelse(MData$Type==Animal,1,0)
 MData$k.plant-ifelse(MData$Type==Plant,1,0)
 
 I've then run the model with the following script:
 
 MixModel-rma(z, v.z., mods=cbind(k.animal, k.plant), intercept=FALSE,
 data=MData, subset=(Response==Tolerance))
 
 I receive the output:
 
 Test of Moderators (coefficient(s) 1,2):
 QM(df = 2) = 8.5758, p-val = 0.0137
 
 Model Results:
 
   estimate  sezvalpvalci.lb   ci.ub
 k.animal0.4877  0.2703  1.8042  0.0712  -0.0421  1.0175  .
 k.plant 0.5095  0.2209  2.3066  0.0211   0.0766  0.9424  *
 
 Does this mean that, overall, there is a significant effect of group on
 the overall effect size (based on the QM test)? 

Not quite. Since you have removed the intercept, the two estimates reflect the 
estimated effect sizes (or to be precise, the estimated average effect sizes) 
for animals and plants, respectively. The QM test is testing these two 
coefficients simultaneously, so it is testing the null hypothesis that the 
average effect sizes are both equal to 0. Since the test is significant, we can 
reject that null hypothesis. However, this does not test whether the effect is 
different for animals or plants.

 If I want to test whether
 the effect size for plants is different to that for animals, can I use:
 
 MixModel2-rma(z, v.z., mods=cbind(k.plant), data=MData,
 subset=(Response==Tolerance)) ?
 
 Here I get:
 
 Test of Moderators (coefficient(s) 2):
 QM(df = 1) = 0.0039, p-val = 0.9502
 
 Model Results:
 
  estimate  sezvalpvalci.lb   ci.ub
 intrcpt0.4877  0.2703  1.8042  0.0712  -0.0421  1.0175  .
 k.plant0.0218  0.3491  0.0624  0.9502  -0.6624  0.7060
 
 Does this mean that there is no significant difference in effect size
 between plants and animals (now the intercept?) ? Or is this something
 completely different?

Correct. Now you are testing whether the difference in the average effect for 
plants is different from the average effect for animals. The estimated 
difference is 0.0218 (so the estimated average effect for plants is 0.4877 + 
0.0218 = 0.5095 -- the same value as obtained from your first model), which is 
not significantly different from zero.

This is a nice example to illustrate that the common practice of subgrouping 
(whether it be in a meta-analysis or in a primary trial) and testing effects 
within subgroups can be misleading. Note that your first example indicates a 
significant effect for plants, but not for animals. If you were to fit a 
random-effects model just within the subset of studies with animals and just 
within the subset of studies with plants, you will probably obtain rather 
similar results as in your first model (the difference only arising from the 
fact that in your first model, tau^2 is estimated once, while two separate 
models within those two subgroups will also give you two separate values for 
tau^2). However, the difference in the effect is far from significant and that 
is in fact the proper test of this interaction.

 I'd really appreciate any input,
 
 Rachel Slatyer
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] dummy encoding in metafor

2013-01-28 Thread Viechtbauer Wolfgang (STAT)
Dear Alma,

either there is a whole lot of miscommunicaton here, or you (and your 
supervisor) are way in over your head.

You say that you are working with Cohen's d values. And you mentioned CMA. So, 
let me ask you some questions:

1) Has CMA computed those d values for you?
2) If yes, what information did you supply to CMA for the computation of those 
d values? (means, standard deviations, and the sample sizes of the two groups?)
3) Did CMA then provide you with a column of values that are the corresponding 
sampling variances or standard errors? (those values should NOT all be equal to 
1!)

Best,
Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Alma Wilflinger
 Sent: Sunday, January 27, 2013 21:52
 To: Michael Dewey; r-help@r-project.org
 Subject: Re: [R] dummy encoding in metafor
 
 Hi Michael!
 
 Yes, I do use Cohens d. As a matter of fact my thesis supervisor told me
 to use 1 as the value for standard deviation for all of my studies.
 Unfortunately I am not totally sure myself why to do this have you ever
 used such an approach?
 
 kind regards,
 Alma
 
 
  From: Michael Dewey i...@aghmed.fsnet.co.uk
 
 t.co.uk; r-help@r-project.org r-help@r-project.org
 Sent: Thursday, January 24, 2013 6:57 PM
 Subject: Re: [R] dummy encoding in metafor
 
 At 22:06 23/01/2013, Alma Wilflinger wrote:
 
  Hi Michael,
 
  The supervisor for my Master's Thesis told me that my means are the
 effect size and cause of this I have to take figure 1 for all standard
 deviations. So I hope that was the right information.
 
 Alma
 There is a fairly comprehensive list of all the things which might be an
 effect size on
 http://en.wikipedia.org/wiki/Effect_size
 Is what you call Mean one of them?
 
 
 
  From: Michael Dewey i...@aghmed.fsnet.co.uk
 
 wolfgang.viechtba...@maastrichtuniversity.nl; Michael Dewey
 i...@aghmed.fsnet.co.uk; r-help@r-project.org r-help@r-project.org
  Sent: Wednesday, January 23, 2013 10:22 AM
  Subject: Re: [R] dummy encoding in metafor
 
  At 08:30 23/01/2013, Alma Wilflinger wrote:
   Dear Wolfgang and Michael,
  
 [[elided Yahoo spam]]
  
   Concerning the Variance: I took the variance I used for CMA (which
 is always 1), so I think it should be the right one.
 
  It seems unlikely to me that the variance from each study would be the
 same although I suppose it could be possible. Are you sure you are
 supplying the right values to CMA?
 
 
   Thank you for noticing and mentioning though :)
  
   I really appreciate how helpful you both are.
  
   best,
   Alma

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] mixed effects meta-regression: nlme vs. metafor

2013-01-23 Thread Viechtbauer Wolfgang (STAT)
Hello Christian,

First of all, it's good to see that you are well aware of the fact that lme() 
without lmeControl(sigma=1) will lead to the estimation of the residual 
variance component, which implies that the sampling variances specified via 
varFixed() are only assumed to be known up to a proportionality constant -- 
however, in the usual meta-analytic models, we assume that the sampling 
variances are exactly known. In fact, trying to disentangle that residual 
variance component from any random study effects is usually next to impossible. 
I mention this explicitly one more time, because I have seen some publications 
using lme() in exactly this way ...

Indeed, lmeControl(sigma=1) is an option only available in (at least some 
versions of) S-Plus (I know that it is available in version 6). Of course, 
that's not that helpful unless you happen to have a copy of S-Plus.

In fact, I ended up developing the metafor package (which started out with a 
function called mima() that is essentially the predecessor of the rma() 
function) for that very reason -- I needed a function to fit the meta-analytic 
random- and mixed-effects models.

As you are also aware of, right now, rma() adds a random effect per observation 
(i.e., observed effect or outcome), while you want a random effect per study 
(which of course only matters if you have more than one outcome per study -- as 
in your example). I have a function in the works that will allow you to do just 
that. It's not in the package yet, but it will be in the future. This 
essentially relates back to numerous requests I have received for adding 
functions to the metafor package that will handle multivariate meta-analytic 
models, dependent outcomes, and things like network meta-analyses. And to my 
shame, I have said numerous times: Yes, it's in the works, it will be in the 
package in the future, don't know yet when (don't hold your breath). It's 
probably just as frustrating for me not to find the time to work as much on the 
package as I would like as it is for those waiting for me to get around to 
actually adding that functionality to the package.

I actually have picked up quite a bit of steam in terms of working on the 
package recently. I am very close to releasing an updated version, the package 
website (http://www.metafor-project.org/ ) has been totally revamped (and is 
starting to become actually useful), and a bit of grant money is soon trickling 
in my direction that involves certain developments in the package. The updated 
version of the package still does not include that aforementioned function, but 
I may consider putting a pre-alpha version on the website so that the 
adventurous are able to try it out.

Alternatively, you could try taking a look at MCMCglmm 
(http://cran.r-project.org/web/packages/MCMCglmm/index.html), which should be 
able to fit the model that you want. Can't give you any details on how, but if 
you get stuck, try posting to R-sig-mixed-models and Jarrod Hadfield (the 
MCMCglmm package author) is very likely to help you further.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: Christian Röver [mailto:christian.roe...@med.uni-goettingen.de]
 Sent: Wednesday, January 23, 2013 11:10
 To: r-help@r-project.org
 Cc: Wolfgang Viechtbauer
 Subject: mixed effects meta-regression: nlme vs. metafor
 
 Hi,
 
 I would like to do a meta-analysis, i.e., a mixed-effects regression,
 but I don't seem to get what I want using both the nlme or metafor
 packages.
 
 My question: is there indeed no way to do it?
 And if so, is there another package I could use?
 
 Here are the details:
 
 In my meta-analysis I'm comparing different studies that report a
 measure at time zero and after a certain followup time. Each reported
 measurement comes with standard error, and each study uses one (or
 several) of a few treatment categories. I want to fit a random effect
 for each study (the study effect) and a treatment-dependent time effect.
 For the moment I use a linear model, i.e., twice the followup time will
 give you twice the effect, etc...
 
 I get /almost/ what I want using nlme via this command:
 
   lme01 - lme(effect ~ treatment + treatment*time - time - 1,
random = ~ 1|study,
weights = varFixed(~se2),
data = dat)
 
 effect is the real-valued measurement, treatment is a factor, and
 time is the followup time in months. se2 is the squared standard
 error.
 Problem is: using the varFixed() option, lme() will fit an
 additional variance parameter scaling the provided standard errors by a
 certain factor to be estimated. According to some discussions on the
 web, you once 

Re: [R] dummy encoding in metafor

2013-01-21 Thread Viechtbauer Wolfgang (STAT)
As Michael already mentioned, the error:

Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve

indeed indicates that your design matrix is not of full rank (i.e., there are 
linear dependencies among your predictors). With this many factors in the same 
model, this is not surprising if k is only 94 (which is actually quite large 
for a meta-analysis). One options is to leave out some of the predictors. You 
can also try collapsing some of the levels of the factors. Of course, you lose 
some details that way, but apparently you don't have enough data in the first 
place to carry out such a detailed analysis.

One other thing I noticed. You wrote:

rma(yi=Mean, vi=Variance, ni=N.1, ...)

I suspect that your variable Variance is actually the variance of the raw 
scores. However, the vi argument is used to pass the sampling variances of the 
yi values to the function -- not the variance of raw scores. The (estimated) 
sampling variance of a mean is s^2 / n, so if I am not mistaken, you really 
want to use:

rma(yi=Mean, vi=Variance/N.1, ...)

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Monday, January 21, 2013 10:40
 To: Alma Wilflinger; Michael Dewey; r-help@r-project.org
 Subject: Re: [R] dummy encoding in metafor
 
 At 14:48 20/01/2013, Alma Wilflinger wrote:
 Hi,
 
 thank you very much for your kind answer.
 
  If you look a bit further down the manual page you will see
  ### using a model formula to specify the same model
  rma(yi, vi, mods=~factor(alloc)+year+ablat, data=dat, method=REML,
  btt=c(2,3))
 
  which is much easier.
 
 I have seen the possibility of using a model formula for dummy
 encoding and you are right it is much easier than doing it by hand.
 Thing is that if I include some moderator variables into the
 parameters I get the error:
 
 Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve
 
 I suspect that you have a linear dependence between your moderator
 variables. Depending on how many levels there are for country,
 sample, and so on you do have a lot of predictors (you presumably
 know that a factor counts as levels-1 for this purpose?)
 
 
 For example this call works:
 result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) +
 relevel(factor(Sample), ref=Students) + Gender + Age +
 factor(Category) + relevel(factor(Block), ref=c)+
 relevel(factor(order), ref=x), data=csvDataCmaAll, method=REML)
 
 If I add the trials which is of type INT:
 result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) +
 relevel(factor(Sample), ref=Students) + Gender + Age +
 factor(Category) + relevel(factor(Block), ref=c)+
 relevel(factor(order), ref=x) + trials, data=csvDataCmaAll,
 method=REML)
 
 I get the error and I was not able to find a definite reason for
 this error or how to solve it I wanted to try it by doing it manually.
 I think I have found out that it somehow relates to the
 
  If you code them yourself R does not know. You know.
 
 Regarding this I think my question was not clear enough. If R does
 the dummy encoding automatically via a model formula it leaves out
 one of the factors and uses it as a baseline automatically. If I do
 it by hand R is still able to execute the function but the baseline
 is missing because I do not define it via a parameter.
 
 You perhaps would benefit from rereading some of the introductory
 material about formulas. Also look for anything about the model
 matrix (also called the design matrix)
 
 I simply want to know how R is handling this and what I have to do
 by hand to get the correct results. Sorry, this may be a beginners
 question, but as stated I am new to this field.
 
  You say you have seven moderator variables. Unless you have a shed
  load of studies you will not be able to look at them simultaneously.
  Apologies if you already knew that.
 
 No I have not known that. In total I have about 94 studies and want
 to test different sets of moderators. Do you think this is
 sufficient or do you suggest another approach?
 
 The truthful but perhaps unhelpful answer is that you need to collect
 more data or use fewer moderators.
 
 I started in CMA (comprehensive meta analysis) but one of the
 benefits of R is that I am able to test multiple moderators at once
 - at least as I was told.
 
 kind regards,
 Alma
 
 
 From: Michael Dewey i...@aghmed.fsnet.co.uk
 To: Alma Wilflinger alma_an...@yahoo.com; r-help@r-project.org
 r-help@r-project.org
 Sent: Sunday, January 20, 2013 12:52 PM
 Subject: Re: [R] dummy encoding in metafor
 
 At 17:14 19/01/2013, Alma Wilflinger wrote:
  Hi,
  
  I am 

Re: [R] package metafor: error when setting 'col' and 'at' for a forest plot

2013-01-07 Thread Viechtbauer Wolfgang (STAT)
Dear Brian,

At the moment, the various forest() functions are not meant to accept 'col' as 
an argument. While it is indeed possible to specify a 'col' argument, it will 
be passed on via the ... argument to further functions within forest() and this 
is where things can go awry. 

To give a more technical explanation, let's look at your example. First, note 
that the highest 'at' value you specified is log(10), which is approximately 
2.30. However, the highest upper CI bound in your dataset is 2.9. Therefore, 
the forest() function wants to draw a right-pointed arrow for that study using 
the polygon() function. The code within forest() looks something like this:

polygon(lots of other stuff, col=black, ...)

When you specify a 'col' argument, it is passed on to polygon() via ... -- but 
col=black is already hard-coded in forest() and so you get the formal 
argument col matched by multiple actual arguments error.

The issue of changing colors in the forest() functions has come up before:

https://stat.ethz.ch/pipermail/r-help/2011-August/287788.html

In fact, the problems associated with allowing the user to specify colors in 
high-level plotting functions, such as forest(), was nicely discussed in a 
recent article by Paul Murrell in the R Journal:

http://journal.r-project.org/archive/2012-2/RJournal_2012-2_Murrell.pdf

I may add functionality to the forest() functions to handle a 'col' argument 
for specifying row colors, but I will have to evaulate carefully how well that 
will work. Also, I would then need to change the current 'col' argument in the 
forest.rma() function -- breaking backwards compatability :/

Back to your example. You can actually get it to work if you use:

forest(forest$OR, ci.lb=forest$Low, ci.ub=forest$High,  at=log(c(.05, .25, 1, 
20)), slab=forest$SNP, atransf=exp)

in which case the values of 'at' encompass the CI bounds of all studies. Then 
the forest() function does not use polygon(), but segments() and here 'col' is 
not hard-coded. One (probably) unintended consequence of using 'col' this way 
is that the x axis label is also given a different color. 

A few other notes:

1) Calling your data frame 'forest' is probably not a good idea -- since that 
is the name of a function.

2) Your data appear to be (raw -- not log transformed) odds ratios and the 
corresponding CI bounds. So, you should not be using the atransf arguments -- 
or you would be transforming your odds ratios to exp(ORs). Probably closer to 
what you want is:

dat - read.table(header=TRUE, text=
SNP   Group   High   Low   OR
rs1137101   A   1.21   0.87   1.03
rs1137101   B   2.11   1.21   1.6
rs1137101   C   2.9   1.42   2.03
rs1042522   A   1.12   0.84   0.97
rs1042522   B   1.15   0.79   0.95
rs1042522   C   0.92   0.5   0.7
rs1625895   A   1.14   0.76   0.93
rs1625895   B   1.15   0.75   0.93
rs1625895   C   NA   NA   NA
ACEI/D   A   1.55   0.79   1.11
ACEI/D   B   1.25   0.76   0.98
ACEI/D   C   0.85   0.41   0.59
)

forest(dat$OR, ci.lb=dat$Low, ci.ub=dat$High, col=c(1,2,3), at=c(.25, 1, 2, 3), 
slab=dat$SNP, refline=1, xlab= , xlim=c(-1.5,5.5))
mtext(Odds Ratio, side=1, line=2.5, adj=0.45)

where I manually add the x axis label, so that it is in black. Again, though, 
using 'col' this way is technically not intended (even though it does work 
here).

I hope this helps!

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Brian Z Ring
 Sent: Sunday, January 06, 2013 05:48
 To: 'David Winsemius'; r-help@r-project.org
 Subject: Re: [R] package metafor: error when setting 'col' and 'at' for a
 forest plot
 
 Good suggestion, and yes, the given examples work. Using a modification of
 one of the supplied examples, where in the final line I only added the
 parameter col=c(1,2,3):
 
 data(dat.bcg)
 dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg,
 data=dat.bcg, append=TRUE)
 forest(dat$yi, dat$vi, slab=paste(dat$author, dat$year, sep=, ),
 atransf=exp, at=log(c(.05,.25,1,4,20)), col=c(1,2,3))
 
 I get a plot similar to what I want to achieve. My code:
 
 forest(forest$OR, ci.lb=forest$Low, ci.ub=forest$High,  col=c(1,2,3),
 at=log(c(.05, .25, 1, 10)), slab=forest$SNP, atransf=exp)
 
 differs in the data and using confidence intervals instead of vi (sample
 variance). The parameters being changed in my line of code are fairly
 simple, just color of each row and the x axis tick marks. Setting each of
 these independently with my data works fine, it's only when I try to do
 both
 that it fails. I'm still stuck.
 
 Here is some example data that should reproduce the error:
 SNP   Group   HighLow

Re: [R] a problem for metafor package

2012-12-31 Thread Viechtbauer Wolfgang (STAT)
Dear Xudong,

First of all, most attachments are stripped on r-help -- yours didn't make it 
through either. Since you sent a separate e-mail to me personally (including 
the attachment), I can see what you want to accomplish, but let's keep this on 
the list.

Second, your mail to r-help contained the welcome message you received when 
you signed up for the mailing list. That message also contained your password 
(I removed that part from your message below). Maybe not such a wise thing to 
do.

Now, regarding your question. You could just include the information from the 
whole study and the two subgroups in the dataset and then use the forest() 
function. However, for computing the overall estimate (in case you also want to 
include this in the forest plot), you need to decide how that should be done. 
Do you want to just count the results from whole study or just the two subsets? 
(using the information from the whole study and the two subsets would be 
double-counting and not appropriate). In either case, you could then pass the 
respective data to rma(), compute the overall estimate, and add it to the 
forest plot using the addpoly() function.

I suggest carefully studying:

?forest.default
?addpoly.default

and especially the examples. If you then get stuck, please provide minimal and 
self-contained code that can be used as a starting point for a more specific 
response.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of LiuXudong
 Sent: Monday, December 31, 2012 10:21
 To: r-help@r-project.org
 Subject: [R] a problem for metafor package
 
 Dear sir or madam
 
 I want to know how to use metaforpackage do a meta anlysis,  forest
 plot  show the results of whole study and  results of two subgroups
 like this the forest plot show in the attachment.
 
 looking forword to your reply
 
 Regards and Cheers
 
 Xudong Liu
 
 School of Public Health and Primary Care
 The Chinese University of Hong Kong
 Email: liuxud...@cuhk.edu.hk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help: Meta-analysis with metacor

2012-11-20 Thread Viechtbauer Wolfgang (STAT)
There are multiple issues here. First of all, you should simplify your code to:

metacor(cor, n, title=title, complab=comparison, outclab=outcome)

The rest of your call to metacor() is just using the defaults, so no need to 
repeat all of that in your call and apparently one of these arguments is 
causing some problems.

Second, your vector of correlations (cor) includes values below -1, which is 
impossible if these are supposed to be Pearson product-moment correlation 
coefficients. 

Finally, note that the sampling variance of an r-to-z transformed correlation 
is calculated with 1/(n-3), so you get division by zero when n=3. As far as I 
can tell, metacor() will handle this by setting the weight for these values to 
0. It is certainly unusual to meta-analyze correlations, where some of those 
correlations are based on only 3 observations.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Catherine Proulx
 Sent: Monday, November 19, 2012 18:55
 To: r-help@r-project.org
 Subject: [R] Help: Meta-analysis with metacor
 
 
 Trying to do a meta-analysis of correlations in R using the meta package;
 have tried several things and keep getting a similar error. Can anyone
 help explain the error?
  cor-c(-0.3018, 0.667, -3.8002, -0.607, -0.4885, -3.8002, -0.0701,
 0.1348, -0.9505, -0.5709, -0.6127, -1.2419, -0.1511, -0.1054) n-
 c(3,4,3,3,3,3,16,36,30,9,3,3,30,4) library(meta) metacor(cor, n,
 data=NULL, subset=NULL, sm=ZCOR, level=0.95, level.comb=level,
 comb.fixed=TRUE, comb.random=TRUE, hakn=NULL, method.tau=DL,
 tau.preset=NULL, TE.tau=NULL, method.bias=linreg, title=title,
 complab=comparison, outclab=outcome)
 Error in data.frame(subset = NULL, comb.fixed = TRUE, comb.random = TRUE,
 :   arguments imply differing number of rows: 0, 1
 Thanks,
 Catherine
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] combine unadjusted and adjusted forest plots

2012-10-18 Thread Viechtbauer Wolfgang (STAT)
Dear Romita,

It is not quite clear to me what exactly you want the graph to look like. What 
do you mean by plots of the unadjusted and adjusted models?

In general though, it sounds to me as if the graph you have in mind is rather 
complex. It may be possible to accomplish this with the forest() and addpoly() 
functions in the metafor package, but I can't say for sure. Essentially, what I 
would have to see first is a hand-sketch of the graph you would like to draw. 
At a certain point though, it may be easier to just create the graph with the 
low-level plotting functions in R (points, lines, segments, polygon, etc.). 

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Romita Mukerjee, M.D.
 Sent: Wednesday, October 10, 2012 21:43
 To: r-help@r-project.org
 Subject: [R] combine unadjusted and adjusted forest plots
 
 Hello,
 
 I am learning to use the metafor package to conduct meta-regression
 analyses for a systematic review on multidisciplinary care interventions
 in chronic kidney disease.  For the forest plots, I can't figure out how
 to plot unadjusted and adjusted models on the same plot.  From top to
 bottom, I would like to be able have the unadjusted plot, the multivariate
 adjusted plot, then each univariate adjusted plot.  Below each plot I
 would like to also include a polygon with the respective summary estimate
 and confidence interval.  I would also like to have only one x-axis at the
 bottom of the whole plot.  The moderators for the meta-regression include
 both continuous and categorical variables.  Any thoughts?
 
 Thanks,
 Romi Mukerjee
 
 
 
 Romita Mukerjee, M.D.
 Nephrology Fellow, PGY-6
 Duke University Medical Center
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] What to use for ti in back-transforming summary statistics from F-T double square-root transformation in 'metafor'

2012-09-28 Thread Viechtbauer Wolfgang (STAT)
Dear Chunyan,

One possibility would be to use the harmonic mean of the person-time at risk 
values. You will have to do this manually though at the moment. Here is an 
example:

### let's just use the treatment group data from dat.warfarin
data(dat.warfarin)
dat - escalc(xi=x1i, ti=t1i, measure=IRFT, data=dat.warfarin, append=TRUE)
dat

### check if back-transformation of individual IRFT values works
transf.iirft(dat$yi, ti=dat$t1i)
escalc(xi=x1i, ti=t1i, measure=IR, data=dat.warfarin)$yi

### random-effects models
res - rma(yi, vi, data=dat)
res

### harmonic mean of the ti's
ti.hm - 1/(mean(1/dat$t1i))

### back-transformation using the harmonic mean
transf.iirft(res$b, ti=ti.hm)
transf.iirft(res$ci.lb, ti=ti.hm)
transf.iirft(res$ci.ub, ti=ti.hm)

Best,
Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Liu, Chunyan [chunyan@cchmc.org]
Sent: Thursday, September 27, 2012 10:48 PM
To: r-help@R-project.org
Subject: [R] What to use for ti in back-transforming summary statistics from 
F-T double square-root transformation in 'metafor'

Hi Dr. Viechtbauer,

I'm doing meta-analysis using your package 'metafor'. I used the 'IRFT' to 
transform the incident rate. But when I tried to back-transform the summary 
estimates from function rma, I don't know what's the appropriate ti to feed in 
function transf.iirft. I searched and found your post about using harmonic mean 
for ni  to back-transform the double arcsine  transformation. I'm hoping I can 
get your help on ti too.

Thanks.


Chunyan Liu

513-636-9763
Biostatistician II
Department of Biostatistics and Epidemiology
Cincinnati Children's Hospital Medical Center
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Broken Links on http://www.r-project.org

2012-09-26 Thread Viechtbauer Wolfgang (STAT)
I was not sure who I should contact about this, so I am posting this here.

There are a few broken links on the R website.

1) http://www.r-project.org/search.html - link to the Nabble R Forum. I belive 
the correct/new URL should be: http://r.789695.n4.nabble.com/

2) http://www.r-project.org/other-docs.html - link to Auswertung ökologischer 
Daten. Not sure if there is a new URL.

3) http://www.r-project.org/other-projects.html - link to Jim Lindsey's R 
page. I believe the correct/new URL should be: 
http://www.commanster.eu/rcode.html

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] using alternative models in glmulti

2012-09-12 Thread Viechtbauer Wolfgang (STAT)
Dear Meghan,

you can do this with rma() in metafor, but you will have to set up the loop 
yourself. Here is an example. First, I need to simulate some data:



library(metafor)
library(MASS)

k  - 40   ### number of studies
ni - runif(k, 20, 200)### simulate the sample 
sizes of the studies
vi - (rchisq(k, ni-1) / (ni-1)) / ni  ### simulate the 
sampling variances of the means
X  - mvrnorm(k, mu=rep(0,6), Sigma=diag(6))   ### simulate 6 moderators
yi - .2 * X[,1] + .4 * X[,2] + rnorm(k, 0, sqrt(vi))  ### simulate the 
observed means

### note that only the first and second moderators in X are real moderators

### now the part that you need:

### moderator inclusion matrix
incl - do.call(expand.grid, rep(list(eval(parse(text = c(T,F, 6))

AICs - rep(NA, nrow(incl)) ### vector to save the AICs

for (m in 1:nrow(incl)) {
   res - rma(yi, vi, mods=X[,unlist(incl[m,])], method=ML)
   AICs[m] - AIC(res)
}

### and here are the 64 models listed in increasing AIC order (at the top is 
the best model according to the AIC):

cbind(incl, AICs)[order(AICs),]



When I run this, I got:

 cbind(incl, AICs)[order(AICs),]
Var1  Var2  Var3  Var4  Var5  Var6   AICs
61  TRUE  TRUE FALSE FALSE FALSE FALSE -77.890028
29  TRUE  TRUE FALSE FALSE FALSE  TRUE -75.957174
53  TRUE  TRUE FALSE  TRUE FALSE FALSE -75.917222
57  TRUE  TRUE  TRUE FALSE FALSE FALSE -75.915086
45  TRUE  TRUE FALSE FALSE  TRUE FALSE -75.894423

and voila: The true model is actually the one that came up best according to 
the AIC. Now this isn't guaranteed to happen and if you run this code multiple 
times, you may get different results (since the simulated data may not come out 
as nicely).

And if you have lots of moderators, this may take a while to run. With 20 
moderators, this will fit 1048576 models, so you may need to be patient for 
this to finish.

Also, it can happen that the fitting algorithm does not converge for a 
particular model (with a large number of models, this could very well happen). 
So, to avoid the looping from stopping, use:

for (m in 1:nrow(incl)) {
   res - try(rma(yi, vi, mods=X[,unlist(incl[m,])], method=ML))
   if (is.element(try-error, class(res)))
  next
   AICs[m] - AIC(res)
}

which will give you an NA for the AIC for a model that does not converge, but 
at least the loop will run all the way through. As an alternative, you could 
replace the next with:

   res - rma(yi, vi, mods=X[,unlist(incl[m,])], method=HS)

which uses not ML estimation for the amount of (residual) heterogeneity, but 
the method suggested by Hunter and Schmidt. This behaves very much like 
method=ML, but is non-iterative, so it will always give you an answer. Maybe 
not ideal to mix the two, but it probably matters little.

Three other things:

The moderator matrix X in the example above does not contain any missing 
values. You can only really compare AICs that are based on the same set of 
data, so if you have missing data in X, you need to filter out those cases.

You wrote: variance is the SE around the mean. But SE usually stands for 
standard error and the sampling *variance* is the square of the SE. The syntax 
for rma() is: rma(yi, vi, sei, ...), so the first argument would be the effect 
sizes, the second argument would be for the *variances*, and the third would be 
for the standard errors. If you really have SEs, you should use 
rma(Effect_size, sei=name of variable for SEs, ...).

Just curious: Are you working on mycorrhizal fungi? (Myco_type sounds like 
it).

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Midgley, Meghan Grace
 Sent: Tuesday, September 11, 2012 23:41
 To: r-help@r-project.org
 Subject: [R] using alternative models in glmulti
 
 All,
 
 I am working on a multiple-regression meta-analysis and have too many
 alternative models to fit by hand.  I am using the metafor package in
 R, which generates AIC scores among other metrics.  I'm using a simple
 formula to define these models.  For example,
 rma(Effect_size,variance, mods=~Myco_type + N.type +total,
 method=ML)-mod  where Effect_size is the mean response for each
 experiment, variance is the SE around the mean, mods are the variables,
 and the method used to fit the AIC score is maximum likelihood
 estimation.  I thought I might be able to use the function glmulti(mod,
 level=1) to rank all alternative models 

Re: [R] metafor package: study level variation

2012-09-10 Thread Viechtbauer Wolfgang (STAT)
As usual, Michael was faster than I in responding. Let me add a few thoughts of 
my own. See comments below in text.

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jarrett Byrnes
 Sent: Friday, September 07, 2012 16:02
 To: R help
 Subject: [R] metafor package: study level variation
 
 Hello.  A quick question about incorporating variation due to study in the
 metafor package.  I'm working with a particular data set for meta-analysis
 where some studies have multiple measurements.  Others do not.  So, let's
 say the effect I'm looking at is response to two different kinds of drug
 treatment - let's call their effect sizes T1 and T2.  Some studies have
 multiple experiments measuring  T1 and T2.  Some have one of each.  Some
 only have T1 or T2.

I assume there is also a control group/condition in each of these studies, so 
in other words, you have a bunch of studies where some are two-arm studies 
comparing Trt1 *or* Trt2 to control and some are three-arm studies comparing 
both Trt1 *and* Trt2 to control.

 Now, in metafor, I've been using
 
 rma(yi = logRatio, vi=varLogRatio, mods=~ Drug.Type, data=mydata)

So, drug.type is a dummy variable (either Trt1 or Trt2), so the code above will 
fit the model:

yij = beta0 + beta1 Trt2 + uij + eij,

where yij is the jth observed outcome in the ith study, beta0 then corresponds 
to the (average) outcome for Trt1, beta1 indicates how much higher or lower the 
(average) outcome is for Trt2 compared to Trt1, uij ~ N(0, tau^2), and eij ~ 
N(0, varLogRatio). This model will treat three-arm studies as if they were two 
(independent) two-arm studies. Probably not ideal.

 This works fine.  Out of curiosity, I ran a quickie model in lme4
 
 lmer(logRatio ~ Drug.Type + (1+studyID), data=mydata, weights=varLogRatio)
 
 and I noticed that the results are quite different, and this appears due
 to some variation due to study (after inspecting ranef - note, I included
 Drug.Type as a fixed effect as there were only two levels).

1) Did you use (1+studyID) or (1 | studyID)? The latter is probably what you 
meant/want to use.
2) You need to specify the *inverse* of the variances as weights.
3) This model assumes that the sampling variances are known up to a 
proportionality constant, not exactly known. You will therefore get what is 
sometimes called a multiplicative model for heterogeneity, with heterogeneity 
reflected in a residual variance estimate larger than 1. This model is 
different from the additive model (which is typically used), where the sampling 
variances are assumed to be known exactly and we *add* an additional random 
effect to reflect heterogeneity.

So, with (1 | studyID) and inverse sampling variance weights, you get the model:

yij = beta0 + beta1 Trt2 + ui + eij,

where ui ~ N(0, tau^2), eij ~ N(0, sigma^2 * varLogRatio). Now tau^2 reflects 
study-level variability and sigma^2 reflects multiplicative heterogeneity.

 So, I went back to metafor and ran
 
 rma(yi = logRatio, vi=varLogRatio, mods=~ Drug.Type+studyID, data=mydata)
 
 which yielded the error
 
 Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve
 In addition: Warning message:
 In rma(yi = logRatio, vi = varLogRatio, data = mydata, mods = ~Drug.Type
 :
   Cases with NAs omitted from model fitting.
 
 which appears to be due to the unbalanced nature of the dataset (some
 studies having T1 and T2, some having multiple measures of T1 and T2).

I would have to see:

with(mydata, model.matrix(~ Drug.Type + studyID))

to figure out what is going on here. The error indicates that you have some 
linear dependency between the columns of the design matrix. That should not 
happen based on what you describe. For example, suppose there are 4 studies, 
the first and fourth a three-arm studies, the second only examines Trt1 and the 
third only Trt2. Then:

 study - factor(c(1,1,2,3,4,4))
 trt - factor(c(1,2,1,2,1,2))
 model.matrix(~ trt + study)
  (Intercept) trt2 study2 study3 study4
1   10  0  0  0
2   11  0  0  0
3   10  1  0  0
4   11  0  1  0
5   10  0  0  1
6   11  0  0  1

which is of full rank. That should be true regardless of how many studies (of 
each type) I add.

 So, is there a way to properly incorporate studyID in a metafor using rma?
 Is there an argument I'm missing, or perhaps should be using a different
 function?

At the moment, metafor is really only a set up for univariate models (that 
should change in the near? future). The kind of 

Re: [R] (Slight) calculation discrepancy in escalc (metafor package)

2012-08-21 Thread Viechtbauer Wolfgang (STAT)
The pooled standard deviation is calculated exactly how you describe it. There 
are, however, two differences between your approach and the way escalc() 
computes the SMD and corresponding sampling variance:

1) Instead of the equation for approximating the correction factor (J), 
escalc() uses the exact equation, namely:

gamma(mi/2)/(sqrt(mi/2)*gamma((mi-1)/2))

where mi = n1+n2-2. In your example, that is:

 mi - 5+5-2
 gamma(mi/2)/(sqrt(mi/2)*gamma((mi-1)/2))
[1] 0.9027033

which is really only slightly different from the value you computed (0.903226) 
and hence, the corrected SMD value computed by escalc() and your computations 
essentially agree.

2) More importantly, the sampling variance (Vd) is computed in escalc() by 
plugging the *corrected* version of the SMD into the equation you gave and no 
further adjustment is made to Vd. This explains the more substantial difference 
you found between your computations of the sampling variance and the value 
returned by escalc(). This kind of difference will only be noticeable when the 
sample sizes are small (as in your example). 

One could debate which approach is more correct. Probably neither is 
appropriate here. The equation for the sampling variance given below is 
actually a large-sample approximation. For n1=n2=5, it's probably not accurate 
at all. An alternative would be to discard that equation altogether and instead 
use an unbiased estimate of the sampling variance, which can be obtained with:

escalc(measure=SMD, m1i=5,m2i=10,n1i=5,n2i=5,sd1i=1,sd2i=2,vtype=UB)

which gives a value of 1.0487, much bigger than either of the two values.

Best,

Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Stephen Ban [stephen@my.jcu.edu.au]
Sent: Wednesday, August 22, 2012 2:28 AM
To: r-help@r-project.org
Subject: [R] (Slight) calculation discrepancy in escalc (metafor package)

Hello,

I recently started using the metafor package (version 1.6-0) in R (2.15.1,
64-bit Windows 7) and noticed that I was getting slightly different values
when I manually calculated the standardized mean difference versus what
escalc was giving me. Here's a very simple example:

escalc(measure=SMD, m1i=5,m2i=10,n1i=5,n2i=5,sd1i=1,sd2i=2,vtype=LS)

The result is:

 yivi
1 -2.854599 0.8074367

However, if I calculate this manually using the pooled standard deviation
formula given in Cooper et al (2009)*, I get an SMD of -2.85625 and a
variance of 0.870205.

The formula given in Cooper et al for the pooled standard deviation is:

Swithin = sqrt(((n1i - 1) * Sd1i^2 + (n2i - 1) * Sd2i^2)/(n1i + n2i -2))
[1.581139 for my example]

And the formula for variance is:

Vd = (n1i + n2i)/(n1i*n2i) + d^2/(2 *(n1i+n2i)) [1.07 for my example]

Where d is:

d = (m1i - m2i)/Swithin [-3.16228 for my example]

These are both corrected by the correction factor J:

J = 1 - 3/(4*(n1i+n2i-2)-1) [0.903226 for my example]

The resulting g is [0.903226 * -3.16228] = -2.85625 and the resulting
variance is [0.903226^2 * 1.06667] = 0.870205. Thus, my calculated SMD is
very close to the escalc value (only 0.05% different), but the variance is
nearly 8% different.

I assume the difference must lie in how the pooled standard deviation is
being calculated, but the help for escalc only says that the pooled standard
deviation is calculated inside the function, and I can't find the exact
formula for how this is being done. I'm trying to track down a copy of
Hedges and Olkin (1985), but it would be great in the meantime somebody
could enlighten me.

Thanks,

Stephen Ban

*p. 226. Cooper, H., Hedges, L., and Valentine, J. The handbook of research
synthesis and metaanalysis. Russell Sage Foundation, 2009.

Stephen Ban, M.Sc.
Ph.D. Candidate
Australian Research Council Centre of Excellence for Coral Reef Studies
James Cook University
Townsville, Queensland 4811 Australia
Phone: +61 7 4781 6063
Fax: +61 7 4781 6722
 mailto:stephen@jcu.edu.au stephen@my.jcu.edu.au
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error in metafor documentation on maximum iterations

2012-08-16 Thread Viechtbauer Wolfgang (STAT)
I had noticed this oversight a while ago. In an updated version of the metafor 
package (hopefully to be released in the near future), the argument will be 
called maxiter (as intended). Using maxit will then work as well, due to 
partial matching.

Thanks for bringing this to my attention though.

Also, the package name is metafor (spelled with an f). It's supposed to be a 
(convoluted) abbreviation for META-analysis FOr R). I suppose metaphor 
would then be META-analysis PHOr R, but I decided against that (other 
candidates were metaforR, metafoR, and a few others). Well, at the time, I 
thought the name metafor was clever. These days, I am not so sure anymore.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Weylandt
 Sent: Thursday, August 16, 2012 04:19
 To: John Hodgson
 Cc: r-help@r-project.org
 Subject: Re: [R] Error in metafor documentation on maximum iterations
 
 Send this to Wolfgang directly. See
 
 maintainer(metaphor)
 
 Michael
 
 On Aug 15, 2012, at 12:13 PM, John Hodgson j...@formby.plus.com wrote:
 
  Both the official R documentation and Wolfgang's paper in the Journal of
  Statistical Science describing this (extremely useful) package, name the
  control variable for maximum iterations in numeric model fitting as
  'maxiter'.  The correct name is 'maxit'.  A small point concerning an (I
  guess) infrequently used bit of functionality, but this may help save
  someone an hour or so's head scratching!
 
  John Hodgson
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] What package to use to calculate odds ratio and the confidence interval?

2012-08-14 Thread Viechtbauer Wolfgang (STAT)
This is not an odds ratio. You simply calculated 27/131 = .206, which is the 
odds of having the disease given 40%. You can calculate a confidence interval 
for this with:

exp(log(27/131) - 1.96 * sqrt(1/27 - 1/(27+131)))
exp(log(27/131) + 1.96 * sqrt(1/27 - 1/(27+131)))

which yields (0.146, 0.291).

Wolfgang

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
C W [tmrs...@gmail.com]
Sent: Tuesday, August 14, 2012 9:06 PM
To: Nordlund, Dan (DSHS/RDA)
Cc: r-help
Subject: Re: [R] What package to use to calculate odds ratio and the confidence 
interval?

The table did not come out on rich text format.

So what I wrote was,

 40%40%  Total
No disease  131 75 206
Have diease  27   6  33
 239

My odds ratio: 27/(27+131))/(131/(27+131)) = 0.206
I am looking for the confidence interval.

Mike
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Factor moderators in metafor

2012-08-09 Thread Viechtbauer Wolfgang (STAT)
There is a simple explanation:

1) The command:

factor(ftype)

does not actually turn 'ftype' permanently into a factor, since you are not 
re-assigning it back to the object 'ftype'. You have to use:

ftype - factor(ftype)

2) If you want to use the formula interface for specifying moderators, you have 
to use mods = ~ formula, so in other words:

rma(KL, VL, mods = ~ ftype)

after you have made 'ftype' a factor (see 1).

Or you can simply use:

rma(KL, VL, mods = ~ factor(ftype))

which does the conversion of 'ftype' into a factor within the model formula.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of John Hodgson
 Sent: Thursday, August 09, 2012 12:56
 To: r-help@r-project.org
 Subject: [R] Factor moderators in metafor
 
 I'm puzzled by the behaviour of factors in rma models, see example and
 comments below. I'm sure there's a simple explanation but can't see it...
 
 Thanks for any input
 
 John Hodgson
 
 
 - code/selected output ---
 --
 
 
 library(metafor)
 
 ##Set up data (from Lenters et al  A Meta-analysis of Asbestos and
 Lung
 Cancer...
 ##Environmental Health Perspectives • volume 119 | number 11 |
 November
 2011)
 
 KL = c(0.02905, 0.06929, -0.1523, 1.6441, 0.1215, 0.3975, 1.0566, 0.1257,
 0.2277, 0.06791, 0.08164, 0.2526, 0.07577, 0.03266, 0.1141, 0.1836,
 1.8276,
 0.4149, 15.4974)
 SE = c(0.006633, 0.09335, 0.08909, 0.4297, 0.07858, 0.1753, 0.3679,
 0.1837,
 0.2172, 0.2775, 0.4201, 0.1976, 0.7688, 0.06507, 0.06239, 0.09061, 0.9509,
 0.2181, 7.331)
 
 VL = SE*SE
 
 amph =   c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 mix =c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
 ftype =  c(0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
 
 
 factor(amph)
 factor(ftype)
 factor(mix)
 
 ##  Fit ftype...
 
  rma(KL,VL,mods=ftype)
 
 
 Mixed-Effects Model (k = 19; tau^2 estimator: REML)
 
 tau^2 (estimate of residual amount of heterogeneity): 0.0111 (SE = 0.0095)
 tau (sqrt of the estimate of residual heterogeneity): 0.1054
 
 Test for Residual Heterogeneity:
 QE(df = 17) = 43.0937, p-val = 0.0005
 
 Test of Moderators (coefficient(s) 2):
 QM(df = 1) = 1.1069, p-val = 0.2928
 
 Model Results:
 
  estimate  sezvalpvalci.lb   ci.ub
 intrcpt0.0811  0.0606  1.3380  0.1809  -0.0377  0.2000
 mods   0.0473  0.0449  1.0521  0.2928  -0.0408  0.1353
 
 
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 
 
 ##   why only one df for the 2-level factor?
 ##   in other words, why isn't the above model the same as the
 following...
 
 
 
 
 
  rma(KL,VL,mods=cbind(amph,mix))
 
 Mixed-Effects Model (k = 19; tau^2 estimator: REML)
 
 tau^2 (estimate of residual amount of heterogeneity): 0.0030 (SE = 0.0046)
 tau (sqrt of the estimate of residual heterogeneity): 0.0549
 
 Test for Residual Heterogeneity:
 QE(df = 16) = 37.5762, p-val = 0.0017
 
 Test of Moderators (coefficient(s) 2,3):
 QM(df = 2) = 6.9220, p-val = 0.0314
 
 Model Results:
 
  estimate  sezvalpvalci.lb   ci.ub
 intrcpt0.0380  0.0402  0.9448  0.3447  -0.0408  0.1169
 amph   0.2879  0.1163  2.4754  0.0133   0.0599  0.5158  *
 mix0.0888  0.0625  1.4199  0.1556  -0.0338  0.2114
 
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor- interpretation of moderators test for raw proportions

2012-08-04 Thread Viechtbauer Wolfgang (STAT)
Just to follow up on what Michael wrote:

I cannot reproduce that error. For example, this all works as intended:

data(dat.bcg)

dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
append=TRUE)

rma(yi, vi, mods = ~ alloc, data=dat) ### 'alloc' automatically converted to a 
factor

dat$alloc - factor(dat$alloc) ### explicitly make 'alloc' a factor

rma(yi, vi, mods = ~ alloc, data=dat) ### works as before

rma(yi, vi, mods = ~ factor(alloc), data=dat) ### factor() not necessary, but 
works

If you can provide a reproducible example, I'll be glad to look into the issue.

Aside from that, the error you got occurs when the design matrix is not of full 
rank. For example:

X - model.matrix(~ factor(alloc) - 1, data=dat)
rma(yi, vi, mods = X, data=dat)

will fail, because the model now has an intercept plus the 3 dummy variables 
for the 3 levels (setting intercept=FALSE will make this work). It seems to me 
that this is what happened (since in your previous post, you showed that you 
coded the three levels of your factor manually). But this is something 
different than what you describe below, so I don't know for sure.

Best,

Wolfgang

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
cpanderson [christopher.p.ander...@healthpartners.com]
Sent: Friday, August 03, 2012 6:03 PM
To: r-help@r-project.org
Subject: Re: [R] metafor- interpretation of moderators test for raw 
proportions

Wolfgang,
Thanks for your quick response.  You are correct- indeed I had inadvertently
left out that i had set intercept = FALSE in rma.

Following your suggestions, I get the following results:

Test of Moderators (coefficient(s) 2,3):
QM(df = 2) = 0.2207, p-val = 0.8955

Model Results:

 estimate  se zvalpvalci.lb   ci.ub
intrcpt0.6498  0.0492  13.2160  .0001   0.5534  0.7462  ***
Complex0.0457  0.1007   0.4538  0.6500  -0.1517  0.2430
Dome   0.0244  0.1135   0.2148  0.8299  -0.1980  0.2468

This may be an even dumber question than my first one, but if you have time
I'd appreciate knowing how this works.  Originally I had tried the syntax
mods = ~ Technique.  I ended up getting the following error message:

Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve

if I supply the argument that mods =~ factor(Technique), I don't get the
singular matrix 'a' message.  But I don't understand why that should make a
difference, because dat$Technique is already an object of class factor:

class(dat$Technique)
[1] factor

Thanks again.

Christopher
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor package: Including multiple (categorical) predictors

2012-08-03 Thread Viechtbauer Wolfgang (STAT)
Just to follow up on that: You can use the 'btt' argument in the rma() function 
to specify which coefficients to include in the QM test. For example:

data(dat.bcg)
dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
append=TRUE)
rma(yi, vi, mods = ~ factor(alloc) + year + ablat, data=dat, btt=c(2,3))

will give you a test of the alloc factor. Note that it does not matter which 
level of the factor is the reference level:

rma(yi, vi, mods = ~ relevel(factor(alloc), ref=random) + year + ablat, 
data=dat, btt=c(2,3))

This will give you a Wald-type test. Alternatively, you can use a likelihood 
ratio test (for this, you have to use method=ML):

res1 - rma(yi, vi, mods = ~ factor(alloc) + year + ablat, data=dat, 
method=ML)
res0 - rma(yi, vi, mods = ~   + year + ablat, data=dat, 
method=ML)
anova(res1, res0)

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jeremy Miles
 Sent: Friday, August 03, 2012 04:01
 To: Bexkens, Anika
 Cc: r-help@r-project.org
 Subject: Re: [R] Metafor package: Including multiple (categorical)
 predictors
 
 The test of moderator coefficients (QM) is chi-square distributed.You
 can use the change in this value when you add a predictor to the model
 as a chi-square test, with df equal to the change in df.
 
 Jeremy
 
 On 2 August 2012 05:54, Bexkens, Anika a.bexk...@uva.nl wrote:
  Dear Metafor users,
 
  I'd like to test a model with 2 continuous and 2 categorical moderators
 in a meta regression. One categorical parameter has 2 levels and the other
 has 4 levels. If I understand correctly, when I include all moderators in
 the model, Metafor returns main effects of the continuous parameters and
 contrasts of each level of categorical moderators with the intercept
 (which includes the reference level of the categorical parameters).
 
  This makes it possible to see whether different levels of the
 categorical moderator are differentially related to effect size. I include
 multiple moderators and would like to report for each variable whether it
 is significantly moderating effect size. Is it possible to obtain an
 overall main effect of each categorical variable, instead of the contrast
 effects? Or can I only obtain this by including one categorical moderator
 at a time and reporting the omnibus moderator test?
 
  Many thanks,
 
  Anika

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor- interpretation of moderators test for raw proportions

2012-08-03 Thread Viechtbauer Wolfgang (STAT)
Are you sure that output was produced by: rma(yi, vi, data=dat, 
mods=cbind(LateralWedge,Dome,Complex))?

Because your model does not have an intercept, which suggests that you actually 
used:

rma(yi, vi, data=dat, mods=cbind(LateralWedge,Dome,Complex), intercept=FALSE)

In that case, the coefficients are the estimated (average) proportions for each 
level of that moderator. If you want to actually see whether levels differ from 
each other, you make one of the levels your reference level, leave out the 
corresponding dummy, and include the model intercept:

rma(yi, vi, data=dat, mods=cbind(Dome,Complex))

Now the coefficients estimate the (average) difference between the proportions 
for the Dome vs. LateralWedge levels and the Complex vs. LateralWedge levels. 
If you want to estimate the difference between Dome and Complex, you can use:

rma(yi, vi, data=dat, mods=cbind(LateralWedge,Complex))

Those are all pairwise comparisons. The QM test will tell you whether that 
factor is significant overall.

Note that you do not need to dummy code those levels manually. You could just 
use:

rma(yi, vi, data=dat, mods = ~ Technique)

With the relevel() function, you can change which level is used as the 
reference level. For example:

rma(yi, vi, data=dat, mods = ~ relevel(Technique, ref=LateralWedge))

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of cpanderson
 Sent: Friday, August 03, 2012 00:43
 To: r-help@r-project.org
 Subject: [R] metafor- interpretation of moderators test for raw
 proportions
 
 Hello metafor users,
 I'm using metafor to perform a single-effect summary estimate of the raw
 proportion of patients experiencing a post-operative complication, and I'm
 interested in seeing if this proportion differs between the three most
 commonly used surgical techniques.  The software is working as expected,
 but
 I would like to double check on the interpretation of my mixed-effect
 model
 summary.
 
 The levels of my moderator variable surgery.type are LateralWedge, Dome,
 and
 Complex, which I've dummy coded like this:
 
 dat$LateralWedge-ifelse(dat$Technique==LateralWedge,1,0)
 datDome-ifelse(dat$Technique==Dome,1,0)
 dat$Complex-ifelse(dat$Technique==Complex,1,0)
 
 When i fit this random effect model:
 rma(yi,vi,data=dat, mods=cbind(LateralWedge,Dome,Complex))
 
 I get this output:
 /Mixed-Effects Model (k = 33; tau^2 estimator: REML)
 
   logLik  Deviance   AIC   BIC
 -11.2426   22.4852   30.4852   36.0900
 
 tau^2 (estimate of residual amount of heterogeneity): 0.0925 (SE = 0.0269)
 tau (sqrt of the estimate of residual heterogeneity): 0.3041
 
 Test for Residual Heterogeneity:
 QE(df = 30) = 654.3038, p-val  .0001
 
 *Test of Moderators (coefficient(s) 1,2,3):
 QM(df = 3) = 128.7528, p-val  .0001*
 Model Results:
 
   estimate  sezvalpval   ci.lb   ci.ub
 LateralWedge*0.6462*  0.0722  8.9450  .0001  *0.5046  0.7878*  ***
 Dome*0.6659 * 0.1471  4.5283  .0001  *0.3777  0.9541 * ***
 Complex *0.6938*  0.1306  5.3136  .0001 * 0.4379  0.9498*  ***/
 
 My suspicion is that the test of moderators is addressing the hypothesis
 that the proportion of my outcome is not zero in any of the three groups,
 because all the estimated proportions appear to be well within the
 confidence bounds of the other two groups.  Is this correct?  If it is, I
 would appreciate any suggestions on how I would change that hypothesis
 test,
 so that I am testing whether the proportion in group 1 = the proportion in
 group 2 = the proportion in group 3?
 
 Thanks for your input,
 Christopher Anderson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor package, proportions: single groups wrt to a categorical dependent variable‏

2012-08-01 Thread Viechtbauer Wolfgang (STAT)
Dear Dushanthi,

Please keep your e-mails on the R-Help list, where Michael has already given 
you some excellent advice. As Michael already explained, metafor can handle 
proportions, but does not have any specific functionality for categorical 
variables with more than 2 levels (at the moment). So, if it is logical and 
possible to do so, you could collapse the levels of the categorical outcome to 
2 levels and then proceed with the proportions. To be specific, what you need 
is the total sample size (let's call this variable ni) and the number of 
cases (e.g., the number of people that improved) (let's call this variable 
xi) for each study. For example:

xi - c(12, 18, 6)
ni - c(30, 70, 40)
res - rma(measure=PR, xi=xi, ni=ni)
res
forest(res)

just to give you an idea. There are also various transformations that can be 
applied to proportions and depending on your data, it may be more sensible to 
work with one of these transformations. See Proportions and Transformations 
Thereof under ?escalc.

Of course, by doing so, you lose some information. More advanced would be to 
use an ordinal regression or a multinomial model.

Also, regarding your analysis plan -- while it is fine in principle, I hope you 
are not planning to use the information obtained in this way to draw any 
conclusions about the relative effectiveness of the two surgical procedures. 
Based on what you wrote, it seems as if these are non-randomized studies with 
one or the other procedure applied. Therefore, any comparisons you make would 
be purely observational and may be related to other variable that confound any 
difference you may find. 

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: Dushanthi Pinnaduwage [mailto:dushan...@bell.net]
 Sent: Tuesday, July 31, 2012 16:40
 To: w...@metafor-project.org; Dushanthi Pinnaduwage
 Subject: metafor package, proportions: single groups wrt to a
 categorical dependent variable‏
 
 Dear Dr. Wolfgang Viechtbauer,
 
 I am using R version 2.15.0 and 'metafor' package version 1.6-0. Can this
 version of the package handle proportions from
 a categorical dependent variable for single studies? I mean can the
 package functions handle more than 2 proportions ?
 I know it can handle binary variables.
 
 If it can handle how do I set up my dataframe for the raw data from
 different studies? Also
 how do I give inputs, specially xi, mi (or ni) to the function escalc()?
 
 Thanks,
 Dushanthi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Annotate forest plot 'forest.rma()' for meta-analysis with metafor package

2012-07-25 Thread Viechtbauer Wolfgang (STAT)
Just replace the fixed y coordinate values in the text() calls with something 
that will change appropriately with the number of studies/effects included in 
the plot. For example:

text(c(-9.5,-8,-6,-4.5), res$k+2, c(TB+, TB-, TB+, TB-))
text(c(-8.75,-5.25), res$k+3, c(Vaccinated, Control))
text(-16,res$k+2, Author(s) and Year, pos=4)
text(6,  res$k+2, Relative Risk [95% CI], pos=2)

should do it.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jokel Meyer
 Sent: Tuesday, July 24, 2012 16:16
 To: r-help@r-project.org
 Subject: [R] Annotate forest plot 'forest.rma()' for meta-analysis with
 metafor package
 
 Dear R-experts,
 
 The forest.rma() function from the metafor package creates nice forest
 plots for presenting the results of a meta-analysis. These plots can be
 annotated for e.g. giving names to the columns. E.g. as in the
 documentation of the package:
 
 data(dat.bcg)
 
 ### meta-analysis of the log relative risks using a random-effects model
 res - rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure=RR,
slab=paste(author, year, sep=, ), method=REML)
 
forest(res, slab=paste(dat.bcg$author, dat.bcg$year, sep=, ),
xlim=c(-16, 6), at=log(c(.05, .25, 1, 4)), atransf=exp,
ilab=cbind(dat.bcg$tpos, dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg),
ilab.xpos=c(-9.5,-8,-6,-4.5), cex=.75)
 op - par(cex=.75, font=2)
 text(c(-9.5,-8,-6,-4.5), 15, c(TB+, TB-, TB+, TB-))
 text(c(-8.75,-5.25), 16, c(Vaccinated, Control))
 text(-16,15, Author(s) and Year, pos=4)
 text(6,  15, Relative Risk [95% CI], pos=2)
 par(op)
 
 
 However the column names have to be re-positioned everytime the number of
 included studies in the meta-analysis changes.
 E.g.:
 
 dat.bcg - dat.bcg[1:12,]
 
 ### meta-analysis of the log relative risks using a random-effects model
 res - rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure=RR,
slab=paste(author, year, sep=, ), method=REML)
 
 forest(res, slab=paste(dat.bcg$author, dat.bcg$year, sep=, ),
xlim=c(-16, 6), at=log(c(.05, .25, 1, 4)), atransf=exp,
ilab=cbind(dat.bcg$tpos, dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg),
ilab.xpos=c(-9.5,-8,-6,-4.5), cex=.75)
 op - par(cex=.75, font=2)
 text(c(-9.5,-8,-6,-4.5), 15, c(TB+, TB-, TB+, TB-))
 text(c(-8.75,-5.25), 16, c(Vaccinated, Control))
 text(-16,15, Author(s) and Year, pos=4)
 text(6,  15, Relative Risk [95% CI], pos=2)
 par(op)
 
 Is there a way to define the colum names' position relatively to the plot
 so they would be adequately positioned no matter what is the number of
 studies included in the plot?
 
 
 Many thanks for your help!,
 Jokel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tweaking forest plot (metafor package)

2012-07-19 Thread Viechtbauer Wolfgang (STAT)
I think Michael already gave you some really good hints. To add a bit more 
details to this, first of all, I suggest to use:

q2 - rma(yi, vi, mods=cbind(grupo), data=qim)
forest(q2, transf=transf.ztor, digits=3, alim=c(0,1), refline=.5, addfit=FALSE)

so that the fitted values for that categorical moderator are not actually shown 
in the plot yet. Then use:

par(usr)

after you create the forest plot. That will tell you what the xlim values are 
that were chosen by default (the first and second value). Start adjusting these 
values with the xlim argument to see how that expands and shrinks the 
horizontal space.

Next, try the following. Suppose you have k=20 observed correlations in total 
that will be shown in the forest plot. Then the default value for ylim (for a 
model that does includes a moderator, as you have) will be ylim=c(0.5, 23) 
(i.e., the second value is k+3). The first study will be placed in row 20 of 
the plot, the second in row 19, and so on, all the way down to row 1 for the 
20th study. So, try this:

abline(h=20, lwd=3)
abline(h=1, lwd=3)

which will show you where that first and last study are being placed.

In row 21, the horizontal line is plotted. So try this:

abline(h=20, lwd=3)

which shows you where that line is being placed.

Rows 22 and 23 are for some extra white space at the top of the figure to add 
column headings (with the text() function). So try this:

text(par(usr)[1], 22, Study, pos=4, font=2)
text(par(usr)[2], 22, Cor [95% CI], pos=2, font=2)

which will add column headings for the first and last column. Of course, you 
can adjust the value 22 to something slightly different (i.e., to adjust the 
vertical placement of the headings).

Now try using ylim=c(0.5, 30) in the call to forest(). You will see that a 
bunch of extra vertical space is added. The first study is still placed in row 
20, going down again to row 1 for the 20th study. Confirm this with:

abline(h=20, lwd=3)
abline(h=1, lwd=3)

Now, you want to use the row argument to actually tell the forest() function 
where those studies should be placed. Try rows=c(25:21, 15:1) in the call to 
forest(), which will place study 1 in row 25, study 2 in row 24, going down to 
study 5 in row 21, and then study 6 in row 15, study 7 in row 14, going down to 
study 1 in row 1. Again, you can use something like:

abline(h=25, lwd=3)
abline(h=15, lwd=3)

to check on the vertical placement of the 1st and 6th study.

So now you have full control over the placement of the studies and you can add 
space as needed. Then you can use the addpoly() function to add summary 
polygons for the various levels of the grupo factor. I suggest carefully 
going through the last example in:

help(addpoly.default)

to see a detailed example of this.

Finally, to change the axis limits to .5 and 1, just use alim=c(0.5, 1) in the 
call to forest().

I hope this helps!

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Wednesday, July 18, 2012 19:16
 To: eeste...@ualg.pt; r-help@r-project.org
 Subject: Re: [R] tweaking forest plot (metafor package)
 
 At 00:10 18/07/2012, eeste...@ualg.pt wrote:
 Dear All,
 
 I'm having trouble tweaking a forest plot made using the R
 meta-analysis package metafor. I did the analysis based upon the
 correlation coeff from studies and plotted the corresponding forest
 plot easily
 
 q2-rma(yi,vi,mods=cbind(grupo),data=qim)
 q2
 forest (q2,transf=transf.ztor,digits=3, ... ,alim=c(0,1),refline=.5)
 text(-1.55,42,Espécie [refª],pos=4,font=2)
 
 Not sure why you use cbind(grupo) but it will not change much.
 
 
 I'd like to subdivide the table by the moderator 'grupo' - i.e.
 create the necessary spacings in the list of studies to accommodate
 the moderator statistics (cf.
 http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=metafor:addpoly.default).
 
 My main issue is that I cannot really understand how the function
 (forest()) really uses space; specifically, how to use the parameters
 'xlim', 'ylim' and 'rows' in the function? how can I change the scale
 from 0-1 to 0.5-1?
 
 An example of what went wrong would help but I
 think you will find that the rows argument tells
 forest where to put the results of the individual
 trials so if you give it non-consecutive integers
 you will get gaps in the plot which you can fill
 with addpoly. So if rows does not contain 4 you
 can use addpoly to put something in row 4. As far
 as xlim and ylim are concerned my advice would be
 to try a whole range of values and see what
 happens as this is one of those cases where it is
 easier to experiment than to 

Re: [R] package metafor: specify weights?

2012-05-24 Thread Viechtbauer Wolfgang (STAT)
At the moment, there is no possibility of specifying the weights with the rma() 
function. While the main model fitting part could be easily adapted to 
incorporate user-specified weights, the problem comes in with all the 
additional statistics that can be computed based on a fitted model. How should 
the predict() function now work? What would be the definition of I^2 now? How 
would one generalize the influence and outlier statistics to that case? Just to 
give some examples.

Of course, I could leave out such things when the user has specified the 
weights, but then things also get confusing for the user. For example, it is 
already less than ideal that you can only use the trim and fill method with 
models that do not incorporate moderators. Nobody has (as of yet) generalized 
the trim and fill method to that case. But when there are too many special 
cases, the package becomes unusable.

I did consider user-specified weights at one point, but it opened up so many 
cans of worms that I preferred to quickly put the lid pack on those cans. That 
item is written down in my to-do list, but to be honest, it is somewhere at the 
very end of that list.

If you are hesitant to combine the results from those two types of studies, 
what about simply using a moderator to distinguish the two groups?

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Anke Stein
 Sent: Thursday, May 24, 2012 15:59
 To: r-help@r-project.org
 Subject: [R] package metafor: specify weights?
 
 Dear R-experts,
 Dear Wolfgang,
 
 Weighted model fitting in metafor uses the inverse of the study specific
 variances as weights.
 I am wondering if it is possible to specify different weights.
 
 In my meta-analysis, there are two types of studies with (intrinsic)
 differences in their range of sample sizes (which are used to calculate
 the variances of Fisher's z).
 I would like to try normalizing the sample sizes within each set of the
 two study types and use these normalized sample sizes as weights.
 Would that be possible with rma()? So far, I only found the option
 weighted = TRUE/FALSE, but no possibility to specify which weights
 should be used.
 
 Many thanks in advance,
 Anke
 
 
 
 
 
 
 --
 __
 Anke Stein (Dipl.-Biol.)
 
 Biodiversity, Macroecology  Conservation Biogeography Head Prof. Dr.
 Holger Kreft Georg-August University of Göttingen Büsgenweg 2 | 37077
 Göttingen | Germany
 
 phone +49(0)551-39-13761
 fax +49(0)551-39-3618
 ast...@uni-goettingen.de
 http://www.uni-goettingen.de/biodiversity
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor

2012-05-07 Thread Viechtbauer Wolfgang (STAT)
Michael just provided a good suggestion, using the subset argument to make sure 
that you are really using the same data in both analyses.

However, I would not expect the results to be exactly the same anyway. Remember 
that these are random/mixed-effects models you are using. So, when you use the 
meta-regression approach, you are estimating tau^2 differently than when using 
just the subset of data on European women. Essentially, the meta-regression 
approach assumes that the amount of heterogeneity is the same within each of 
the 4 possible combinations of sex and race (I am assuming that race is coded 
dichotomously). When you just use the subset of data on European women, you are 
estimating tau^2 just for that particular subgroup. Since the estimate of tau^2 
is probably not the same with these two approaches, you will also get 
(slightly?) different results.

Here is an example from one of the datasets that comes with the metafor package 
to illustrate this:



library(metafor)

### load empint data
data(dat.empint)

### calculate r-to-z transformed correlations and corresponding sampling 
variances
dat - escalc(ri=ri, ni=ni, measure=ZCOR, data=dat.empint, append=TRUE)

### remove studies where struct is NA
dat - dat[!is.na(dat$struct ),]

### mixed-effects model with struct as moderator
res - rma(yi, vi, mods=~relevel(factor(struct), ref=u), data=dat)
res$tau2
predict(res, transf=transf.ztor, newmods=c(0,1), digits=2)

### two separate random-effects models within each level of struct
res.u - rma(yi, vi, data=dat, subset=struct==u)
res.s - rma(yi, vi, data=dat, subset=struct==s)
res.u$tau2
predict(res.u, transf=transf.ztor, digits=2)
res.s$tau2
predict(res.s, transf=transf.ztor, digits=2)



Note that the results are similar, but not quite the same. This is a result of 
the estimate of tau^2 being different in the two subgroups from the tau^2 
estimated in the meta-regression model. To illustrate this further, try this 
out (which simply sets the estimate of tau^2 in the two subgroup models equal 
to the estimate of tau^2 from the mixed-effects model):



res.u - rma(yi, vi, data=dat, subset=struct==u, tau2=res$tau2)
res.s - rma(yi, vi, data=dat, subset=struct==s, tau2=res$tau2)
res.u$tau2
predict(res.u, transf=transf.ztor, digits=2)
res.s$tau2
predict(res.s, transf=transf.ztor, digits=2)



Now you will find that the results are exactly the same with the 
meta-regression and the subgrouping approach. This may lead one to think that 
subgrouping is the preferred approach (since it does not assume that tau^2 is 
the same in the subgroups). However, the precision of the estimate of tau^2 
tends to be determined largely by k (the number of studies/observations). Since 
the overall k is often not very large to begin with (the example used above is 
actually a rather large meta-analysis), subgrouping makes the k within each 
subgroup even smaller, leading to even less precise estimates of tau^2. 
Hopefully, the actual *conclusions* are not affected by the approach used.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jin Choi
 Sent: Saturday, May 05, 2012 19:04
 To: r-help@r-project.org
 Subject: [R] metafor
 
 Dear users of metafor,
 
 I am working on a meta-analysis using the metafor package. I have a excel
 csv database that I am working with. I am interested in pooling the effect
 measures for a particular subgroup (European women) in this csv database.
 I am conducting both sub-group and meta-regression.
 
 In subgroup-analyses, I have stratified the database to create a separate
 csv file just for European women from the original database and conducted
 the following:
 
 women_west-read.csv(women_west.csv)
 print(women_west)
 dat-escalc(measure=ZCOR,ri=Pearson,ni=N,data=women_west,append=TRUE)
 res-rma(yi,vi,data=dat)
 is.factor(dat$year)
 forest(res,transf=transf.ztor)
 
 In meta-regression, I used the original database, but used categorical
 moderators for sex (=women), and ethnicity (=european) to find the effect
 specifically in European women.
 adult-read.csv(adult.csv)
 print(adult)
 dat-escalc(measure=ZCOR,ri=Pearson,ni=N,data=adult,append=TRUE)
 res-rma(yi,vi,data=dat)
 res-rma(yi,vi,mods=cbind(sex,race),data=dat)
 predict(res,transf=transf.ztor,newmods=cbind(seq(from=0,to=1,by=1),1),addx
 =TRUE)
 
 I am 

Re: [R] using metafor for meta-analysis of before-after studies

2012-04-05 Thread Viechtbauer Wolfgang (STAT)
To add to Michael's response:

There are several things you can do:

1) If the dependent variable is the same in each study, then you could conduct 
the meta-analysis with the (raw) mean changes, i.e., yi = m1i - m2i, where m1i 
and m2i are the means at time 1 and 2, respectively. The sampling variance of 
yi is vi = sdi^2 / ni, where sdi = sqrt(sd1i^2 + sd2i^2 - 2*ri*sd1i*sd2i), sd1i 
and sd2i are the standard deviations of the outcomes at time 1 and 2, 
respectively, ri is the correlation between the outcomes at time 1 and time 2, 
and ni is the sample size. So, sdi is the standard deviation of the change 
scores.

When sdi is not reported, you will have to back-calculate sdi based on what you 
have. You say that the p-value for the paired samples t-test is reported. 
Typically, this will be a two-sided p-value, so ti = qt(pval/2, df=ni-1, 
lower.tail=FALSE) will give you the value of the test statistic.

And since ti = (m1i - m2i) * sqrt(ni) / sdi, you can back-calculate what sdi is 
with sdi = (m1i - m2i) * sqrt(ni) / ti (you just have to make sure that the 
sign of m1i - m2i and the sign of ti are matched up). And now, you can even 
back-calculate what ri was by rearranging the equation for sdi.

2) Often, the dependent variable is not the same in each study. Then you will 
have to resort to a standardized outcome measure. There are two options:

a) standardization based on the change score standard deviation

Then yi = (m1i - m2i) / sdi with sampling variance vi = 1/ni + yi^2 / (2*ni).

b) standardization based on the raw score standard deviation

Then yi = (m1i - m2i) / sd1i with sampling variance vi = 2*(1-ri)/ni + yi^2 / 
(2*ni).

Note that we standardize based on sd1i (i.e., the SD at time 1). So, we do not 
pool sd1i and sd2i. Also, since ri is typically not reported, you will have to 
use the method described above to back-calculate what ri was.

Regardless of which approach you use, you can then proceed with the 
meta-analysis using the yi and vi values. For example, with the metafor 
package, if those values are in a data frame called dat, 

rma(yi, vi, data=dat)

will fit a random-effects model.

Those three outcome measures described above will actually be implemented in an 
upcoming version of the metafor package. For now, you will have to do the 
computations of yi and vi yourself.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Thursday, April 05, 2012 13:04
 To: mp.sylves...@gmail.com; r-help@r-project.org
 Subject: Re: [R] using metafor for meta-analysis of before-after studies
 
 At 18:39 04/04/2012, mp.sylves...@gmail.com wrote:
 Greetings,
 I wish to conduct a meta-analysis for which the outcome is a continuous
 variable measured on the same individuals before and after an
 intervention.
 Hence, the comparison is not made between two groups, but within
 groups, at diffrent times.
 
 Each study reports the mean outcome and SD before the intervention and
 the mean outcome and SD after the intervention. While p-values for
 paired t-test (or similar methods for paired data) are reported in the
 studies, no estimate of the variability of the individual differences are
 available.
 
 If you know the p-value you can generate the t-value If you know the t-
 value and the mean difference you can back calculate the standard errors
 of the differences.
 
 Having said that I am not absolutely sure what the design of the primary
 studies you are analysing is so my answer may not apply directly to your
 problem.
 
 
 Can metafor deal with this sort of meta-analysis? I know that I can
 technically run metafor on these data, assuming that the groups are
 independent but my inference is likely to be wrong. On the other hand,
 I have no idea of the correlation within individuals.
 
 Thanks in advance,
 MP
 
  [[alternative HTML version deleted]]
 
 Michael Dewey
 i...@aghmed.fsnet.co.uk
 http://www.aghmed.fsnet.co.uk/home.html
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] meta-analysis, outcome = OR associated with a continuous independent variable

2012-04-05 Thread Viechtbauer Wolfgang (STAT)
I do not see any major difficulties with this case either. Suppose you have OR 
= 1.5 (with 95% CI: 1.19 to 1.90) indicating that the odds of a particular 
outcome (e.g., disease) is 1.5 times greater when the (continuous) exposure 
variable increases by one unit. Then you can back-calculate the SE of log(OR) = 
.41 with

sei = (ln(ci.ub) - ln(ci.lb)) / (2*1.96), 

which in this case is approximately 0.12. The sampling variance of log(OR) is 
then vi = sei^2.

Now you have everything for the meta-analysis, using any of the packages 
mentioned.

What Thomas already mentioned is that the 'one unit increase' must mean the 
same thing in each study. Therefore, if the exposure variable is measured in 
months in one study and in years in another study, then the odds ratios are 
obviously not directly comparable. If the units are just multiples of each 
other, then you can easily calculate what the OR would be when putting the 
exposure variable on the same scale. For example, an OR of 1.5 for a one month 
increase in exposure is the same as an OR of 1.5^12 = 129.75 for a one year 
increase in exposure.

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Thomas Lumley
 Sent: Wednesday, April 04, 2012 23:42
 To: Marie-Pierre Sylvestre
 Cc: r-help@r-project.org
 Subject: Re: [R] meta-analysis, outcome = OR associated with a continuous
 independent variable
 
 On Thu, Apr 5, 2012 at 8:24 AM, Marie-Pierre Sylvestre
 mp.sylves...@gmail.com wrote:
  Hello everyone,
  I want to do a meta-analysis of case-control studies on which an OR
  was computed based on a continuous exposure. I have found several
  several packages (metafor, rmeta, meta) but unless I misunderstood
  their main functions,  it seems to me that they focus on two-group
  comparisons (binary independent variable), and do not have the option
  of using a continuous independent variable.
 
 
 There's no problem in using continuous exposures in meta.summaries() in
 the rmeta package.  For each study, compute your log odds ratio and its
 standard error, and feed them in.
 
 You just need to make sure that the odds ratio is in the same units in
 each study, of course.
 
-thomas
 
 --
 Thomas Lumley
 Professor of Biostatistics
 University of Auckland
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] meta-analysis, outcome = OR associated with a continuous independent variable

2012-04-05 Thread Viechtbauer Wolfgang (STAT)
You can get an OR from a 2x2 table (which is equivalent to doing logistic 
regression with a single dummy variable that indicates the group) or from some 
continuous exposure (where the logistic regression model will then include that 
continuous variable). The various packages are set up to accept counts for 2x2 
tables and then will compute the OR (or rather, log(OR)) for you. If you have 
ORs from the second case, you simply calculate the log(ORs) yourself and supply 
them to the appropriate function from the packages.

Best,

Wolfgang

 -Original Message-
 From: mp.sylves...@gmail.com [mailto:mp.sylves...@gmail.com]
 Sent: Thursday, April 05, 2012 15:23
 To: Viechtbauer Wolfgang (STAT); Marie-Pierre Sylvestre
 Cc: r-help@r-project.org; Thomas Lumley
 Subject: Re: RE: [R] meta-analysis, outcome = OR associated with a
 continuous independent variable
 
 For some reason I was under the false impression that these packages were
 made for meta-analyses of RCT-like studies in which two groups are
 compared. I am glad to see that I was wrong and that I can use one of
 these packages.
 
 All studies reported using the same units for the exposure so the OR are
 comparable.
 
 Thanks for your responses,
 MP

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor: Moderator variables for each study arm

2012-02-21 Thread Viechtbauer Wolfgang (STAT)
Dear Faiz,

in principle, you can include whatever moderators you want in a meta-regression 
model. A technical issue here is that the two follow-up variables are probably 
strongly correlated, so this may create issues with the model fitting and it 
also complicates the interpretation of the results (the notion of: what happens 
to y when increasing x1 while holding x2 constant is then questionable). Since 
the dependent variable in meta-analyses is (typically) a measure of a group 
contrast, it may also be reasonable to use the contrast (i.e., difference) of 
the follow-up times as a moderator. It all depends on what your question is: Do 
you believe that the *difference between the two groups* depends on the 
absolute follow-up time or rather on the difference in follow-up duration 
between the two groups?

Best,

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 368-5248 | http://www.wvbauer.com   


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Faiz Ahmad Khan
 Sent: Monday, February 20, 2012 16:00
 To: r-help@r-project.org
 Subject: [R] Metafor: Moderator variables for each study arm
 
 Hello,
 
 I am trying to do a meta-analysis where each study has two arms, similar
 to the BCG data set. However, follow-up duration was different for each
 study arm, so I would like to fit a model that uses the length of follow-
 up in each arm as a moderator. Is this possible?
 
 For example, if this was the BCG data, each study would have 2 follow up
 variables: 1 for the treatment group, and 1 for the control group.
 
 thanks for the help,
 Faiz
 
 .
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] meta-analysis normal quantile plot metafor

2012-01-16 Thread Viechtbauer Wolfgang (STAT)
I do not know how Metawin calculates the confidence interval for the QQ-plot. 
The manual lists Chambers, Cleveland, Kleiner, and Tukey (1983) as a reference 
for the method used. Not sure whether that is the classical confidence 
interval.

The method used in metafor is based on Cook and Weisberg (1982) and you can 
examine the code to see exactly what is done.

I would start by first checking whether the results from the 
fixed/random-effects model are essentially the same in Metawin and metafor. 
Metawin uses the DL-estimator for heterogeneity, so you would want to use that 
as well in metafor for the random-effects model. Also note that Metawin 
calculates confidence intervals for the fixed effects (i.e., the mean effect 
size in the fixed/random-effects model) based on a t-distribution with k-1 
degrees of freedom, so you may get a slight difference there (in metafor, the 
default is to use a normal distribution; if you set knha=TRUE, you will also 
get a t-distribution with k-1 degrees of freedom, but the additional Knapp  
Hartung adjustment to the standard error will be done, so these results are 
also not directly comparable). But these are minor differences. If the results 
are not close, then there is some prior difference (before getting the QQ-plot) 
that needs to be resolved first before the two plots can be compared.

Best,

Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 368-5248 | http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Ricc [alltheweb2cc+rh...@gmail.com]
Sent: Monday, January 16, 2012 1:15 PM
To: Michael Dewey
Cc: r-help@r-project.org
Subject: Re: [R] meta-analysis normal quantile plot metafor

Hello,
I used the default parameters:
- envelope: default is TRUE
- level: the default is to take the value from the object (I do not
understand this very well)
- bonferroni : no
- reps : default is 1000
- smooth: default is TRUE
- bass : default is 0

 I used no other arguments.


2012/1/13 Michael Dewey i...@aghmed.fsnet.co.uk:
 At 15:53 11/01/2012, Ricc wrote:

 Hello,

 I once used the metawin software to perform a meta-analysis (see
 metawinsoft, Rosenberg et al.) and produced normal qqplot to test for
 a potential bias in the dataset.
 I now want to re-use the same dataset with the package metafor by W.
 Viechtbauer (great package btw).

 I run the qqnorm.rma.uni function. I use standardized effect sizes as
 in metawin.


 I think it would help if you said which parameters you used to control the
 envelope. Did you smooth it? Did you use the Bonferroni correction?



 QQplot generated with metafor differs from the plot obtained with
 metawin: most of the datapoint fall outside the confidence envelope
 (using the same confidence level). I don't understand very well how
 the pseudo confidence envelope was created in metafor. Is it more
 conservative than that from metawin or created using the package
 envelope ? Unfortunately I do not have access to metawin's code so
 that I cannot compare implementations but the manual let me think that
 metawin print classical confidence interval...

 Thanks for input !
 Ricc

 More precisions:
 R version 2.13.1 (2011-07-08)
 Platform: x86_64-pc-linux-gnu (64-bit)
 metafor_1.6-0


 Michael Dewey
 i...@aghmed.fsnet.co.uk
 http://www.aghmed.fsnet.co.uk/home.html


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] metafor: weights computation in Mantel-Haenszel method

2012-01-15 Thread Viechtbauer Wolfgang (STAT)
Yes, I forgot to divide the weights by the sum of the weights (and multiply by 
100) for weights.rma.mh(). This bug was pointed out to me a few weeks ago and 
this will be changed in the next version of the package.

Best,

Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 368-5248 | http://www.wvbauer.com


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Ignacio López De Ullibarri Galparsoro [i...@udc.es]
Sent: Saturday, January 14, 2012 8:19 PM
To: r-help@r-project.org
Subject: [R] metafor: weights computation in Mantel-Haenszel method

Dear R users,

In metafor 1.6-0, the Mantel-Haenszel method is implemented by the rma.mh() 
function. I have observed that the sum of the weights computed by weights(x) 
doesn't add to 100% when x is an object of class rma.mh. The consequences of 
this fact can be clearly seen when a forest diagram is drawn with forest(x), 
which calls weights(x) (or more precisely, the method weights.rma.mh() defined 
in the package).

Is this, as I suppose, a bug?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Overlaying density plot on forest plot

2011-12-12 Thread Viechtbauer Wolfgang (STAT)
Here is an example. It requires a bit of extra work, but that's the beauty of R 
-- you can essentially customize a graph to your taste with low-level 
functions. I also added the prediction interval using the addcred argument (as 
suggested by Michael), since it gives the same information as that fancy normal 
distribution at the bottom. Essentially, that distribution is just 
window-dressing. I am not sure if I would go as far as calling that 
chart-junk, but it's certainly somewhat gratuitous. Well, I hope the code 
below gives you enough of an idea so that you can adjust this to your specific 
case.


library(metafor)

### load BCG vaccine data
data(dat.bcg)

### meta-analysis of the log relative risks using a random-effects model
res - rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure=RR, 
   slab=paste(author, year, sep=, ), method=REML)

### forest plot with extra annotations
forest(res, slab=paste(dat.bcg$author, dat.bcg$year, sep=, ), 
   xlim=c(-16, 6), at=log(c(.05, .25, 1, 4)), atransf=exp,
   ilab=cbind(dat.bcg$tpos, dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg), 
   ilab.xpos=c(-9.5,-8,-6,-4.5), cex=.7, ylim=c(-3,16), addcred=TRUE)
text(c(-9.5,-8,-6,-4.5), 15, c(TB+, TB-, TB+, TB-), font=2, cex=.70)
text(c(-8.75,-5.25), 16, c(Vaccinated, Control), font=2, cex=.70)
text(-16,15, Author(s) and Year, pos=4, font=2, cex=.70)
text(6,  15, Relative Risk [95% CI], pos=2, font=2, cex=.70)
text(-16,  -2.5, Prediction Distribution, pos=4, cex=.70)

### add prediction distribution
res - predict(res)
pred.m - res$pred
pred.s - (res$cr.ub - res$cr.lb) / (2*1.96)
xs - seq(-2.5,1,.01)
cords.xs - c(-2,xs,-2)
cords.ys - c(0, 1.5*dnorm(xs, pred.m, sd=pred.s), 0) - 3
polygon(cords.xs, cords.ys, col=darkgray, border=NA)
ptext - paste(round(exp(res$pred),2),  [ , round(exp(res$cr.lb),2),  , , 
round(exp(res$cr.ub),2), ], sep=)
text(6, -2.5, ptext, pos=2, cex=.70)

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 368-5248 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Monday, December 12, 2011 18:50
 To: Frank Peter; r-help@r-project.org
 Subject: Re: [R] Overlaying density plot on forest plot
 
 At 15:09 11/12/2011, you wrote:
 Dear Michael,
 
 Thanks for the email. This is the kind of forest plot, I want to
 replicate
 
 http://www.biomedcentral.com/1471-2334/11/122/figure/F2
 
 It would be helpful to cc to r-help in case someone else there knows
 better.
 
 If you follow my suggestion you get a similar plot to sub-plot A in your
 example but the credible interval is shown as a dashed line superimposed
 on the summary diamond and not as a normal density as shown in sub-plot A.
 Whether that is what you want is up to you I think.
 
 Regards
 Frank Peter
 
  Original Message 
 From: Michael Dewey i...@aghmed.fsnet.co.uk
 To: Frank Peter frankpe...@safe-mail.net, r-help@r-project.org
 Subject: Re: [R] Overlaying density plot on forest plot
 Date: Sun, 11 Dec 2011 14:20:13 +
 
   At 07:16 10/12/2011, Frank Peter wrote:
   Dear R User,
   
   Please, I am new to R. I want to overlay density plot for
   predictive interval pooled result in meta-analysis.
   http://addictedtor.free.fr/graphiques/graphcode.php?graph=114
  
   It is hard to be sure from your rather brief question but does the
   addcred parameter to forest.rma in package metafor do what you want?
  
   
   
   Regards
   Frank Peter
  
   Michael Dewey
   i...@aghmed.fsnet.co.uk
   http://www.aghmed.fsnet.co.uk/home.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sensitivity and Specificity Forest Plots

2011-11-22 Thread Viechtbauer Wolfgang (STAT)
Essentially, this is a side-by-side forest plot, where the plot on the left is 
for sensitivity and the plot on the right is for specificity. For 2x2 table 
data from diagnostic studies, it is easy to calculate the sensitivity and 
specificity values (and corresponding sampling variances) by hand. In fact, 
since sensitivity and specificity values are actually simply proportions, you 
can use the escalc() function in the metafor package to do this for you (just 
pass the appropriate cell counts to escalc() and use one of the outcome 
measures listed under Proportions and Transformations Thereof -- see 
help(escalc). Then, you could set up a plotting device with layout() and put 
the forest plot for sensitivity on the left and the plot for specificity on the 
right. So, everything is already there to do this.

Best,

Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician 
Department of Psychiatry and Psychology 
School for Mental Health and Neuroscience 
Faculty of Health, Medicine, and Life Sciences 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
+31 (43) 368-5248 | http://www.wvbauer.com 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jonathan Minton
 Sent: Monday, November 21, 2011 17:34
 To: r-help@r-project.org
 Subject: [R] Sensitivity and Specificity Forest Plots
 
 Dear R Users,
 
 Do you know of an existing function that allows the production of
 sensitivity and specificity forest plots?
 See the following for an example:
 http://www.google.co.uk/imgres?q=forest+plots+of+sensitivity+and+specifici
 tyum=1hl=enauthuser=0biw=1920bih=989tbm=ischtbnid=JLxXNU7iQ2N_CM:i
 mgrefurl=http://www.medscape.com/viewarticle/717751_3docid=NnthE8_KgNQZdM
 imgurl=http://img.medscape.com/article/717/751/717751-
 fig3.jpgw=857h=734ei=UnzKTvfTGIWC8gPnq4R7zoom=1iact=hcvpx=1300vpy=2
 82dur=19hovh=208hovw=243tx=140ty=108sig=112892243842455187632page=1
 tbnh=123tbnw=144start=0ndsp=69ved=1t:429,r:20,s:0
 
 The standard meta-analysis packages (metafor etc) do not seem to have this
 type of forest plot.
 
 If I were to construct a bespoke function within R, would you recommend
 using the forest function within metafor, or the dotplot function within
 lattice, or something else entirely as a starting point for constructing
 the function?
 
 Many thanks,
 
 --
 Dr Jon Minton
 Decision Support Unit
 Health Economics  Decision Science
 School of Health and Related Research
 University of Sheffield
 Tel: 0114 222 0836
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] suggestion for proportions

2011-09-08 Thread Viechtbauer Wolfgang (STAT)
I assume you mean Cohen's kappa. This is not what the OP is asking about. The 
OP wants to know how to test for a difference in the proportions of 1's. 
Cohen's kappa will tell you what the level of agreement is between the two 
tests. This is something different.

Also, the OP has now clarified that the data are paired. Therefore, prop.test() 
and binom.test() are not appropriate. So, to answer the OPs question: yes, 
mcnemar.test() is what you should be using.

Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of csrabak
 Sent: Thursday, September 08, 2011 02:31
 To: array chip
 Cc: r-help@r-project.org
 Subject: Re: [R] suggestion for proportions
 
 Em 7/9/2011 16:53, array chip escreveu:
  Hi all, thanks very much for sharing your thoughts. and sorry for my
 describing the problem not clearly, my fault.
 
  My data is paired, that is 2 different diagnostic tests were performed
 on the same individuals. Each individual will have a test results from
 each of the 2 tests. Then in the end, 2 accuracy rates were calculated for
 the 2 tests. And I want to test if there is a significant difference in
 the accuracy (proportion) between the 2 tests. My understanding is that
 prop.test() is appropriate for 2 independent proportions,  whereas in my
 situation, the 2 proportions are not independent calculated from paired
 data, right?
 
  the data would look like:
 
  pid   test1test2
  p1  1 0
  p2  1 1
  p3  0 1
  :
  :
 
  1=test is correct; 0=not correct
 
  from the data above, we can calculate accuracy for test1 and test2, then
 to compare
 
 
  So mcnemar.test() is good for that, right?
 
  Thanks
 
 John,
 
  From above clarifying I suggest you consider the use of kappa test. For
 a list of possible ways of doing it in R try:
 RSiteSearch(kappa,restrict=functions)
 
 HTH
 
 --
 Cesar Rabak

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] predict.rma (metafor package)

2011-09-08 Thread Viechtbauer Wolfgang (STAT)
Hello Andrew,

Take a look at the following:

predict(model1, addx=T)
predict(model2, addx=T)
predict(model3, addx=T)

As you can see, the factor was turned into dummy variables. However, the 
predict.rma() function does not expand a factor passed via newmods into the 
corresponding dummy variables. At the moment, you will have to do this 
yourself. Note: the intercept is added automatically, so it should not be added 
to the newmods vector(s):

For model2:

predict(model2, newmods=c(0,0), addx=T)
predict(model2, newmods=c(1,0), addx=T)
predict(model2, newmods=c(0,1), addx=T)

or use the model.matrix() function:

newdat - model.matrix(~factor(c(1,2,3)))
predict(model2, newmods=newdat[,-1], addx=T)

For model3:

predict(model3, newmods=cbind(1:5,0,0), addx=T)
predict(model3, newmods=cbind(1:5,1,0), addx=T)
predict(model3, newmods=cbind(1:5,0,1), addx=T)

or using model.matrix():

newdat - expand.grid(mid=c(1,2,3,4,5), mod=factor(c(1,2,3)))
newdat - model.matrix(~ mid + mod, data=newdat)
predict(model3, newmods=newdat[,-1], addx=T)

Yes, I realize this takes some extra work and is not as convenient as having 
that factor expanded automatically. Something to put on the to-do list ...

Best,

Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Andrew Beckerman
 Sent: Thursday, September 08, 2011 14:22
 To: r-help@r-project.org
 Subject: [R] predict.rma (metafor package)
 
  Hi
 
 (R 2.13.1, OSX 10.6.8)
 
 I am trying to use predict.rma with continuous and categorical variables.
 The argument newmods in predict.rma seems to handle coviariates, but
 appears to falter on factors. While I realise that the coefficients for
 factors provide the answers, the goal is to eventually use predict.rma
 with ANCOVA type model with an interaction.
 
 Here is a self contained example (poached in part from the MAd package):
 
 id-c(1:20)
 n.1-c(10,20,13,22,28,12,12,36,19,12,36,75,33,121,37,14,40,16,14,20)
 n.2 - c(11,22,10,20,25,12,12,36,19,11,34,75,33,120,37,14,40,16,10,21)
 g - c(.68,.56,.23,.64,.49,-.04,1.49,1.33,.58,1.18,-
 .11,1.27,.26,.40,.49,.51,.40,.34,.42,1.16)
 var.g -
 c(.08,.06,.03,.04,.09,.04,.009,.033,.0058,.018,.011,.027,.026,.0040,.049,.
 0051,.040,.034,.0042,.016)
 mod-factor(c(rep(c(1,1,2,3),5))) # factor
 mid-c(rep(1:5,4)) # covariate
 df-data.frame(id, n.1,n.2, g, var.g,mod, mid)
 
 # Examples
 # Random Effects
 
 model1-rma(g,var.g,mods=~mid,method=REML) # covariate model
 model2-rma(g,var.g,mods=~mod,method=REML) # factor model
 model3-rma(g,var.g,mods=~mid+mod,method=REML) # multiple
 
 # example matrix for predicting against model3
 
 newdat-expand.grid(c(1,2,3,4,5),c(1,2,3))
 
 predict(model1,newmods=c(1,2,3,4,5))
 predict(model2,newmods=c(1,2,3))
 predict(model3,newmods=newdat)
 
 --
 Andrew Beckerman
 Sent with Sparrow (http://bit.ly/sigsprw)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] suggestion for proportions

2011-09-07 Thread Viechtbauer Wolfgang (STAT)
Acutally,

?mcnemar.test

since it is paired data.

Best,

Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Bert Gunter
 Sent: Wednesday, September 07, 2011 15:34
 To: John Sorkin
 Cc: r-help@r-project.org
 Subject: Re: [R] suggestion for proportions
 
 Please! ...  ?prop.test
 
 not t tests.
 
 -- Bert
 
 --
 
 On Wed, Sep 7, 2011 at 4:21 AM, John Sorkin jsor...@grecc.umaryland.edu
 wrote:
  From you description, you should not used a paired Student's t-test.
 One uses a paired test when pairs of observations come from the same
 experimental unit (and thus are correlated). You describe a study where
 each experimental unit is tested once and where there are two independent
 groups of experimental units. Look at t.test (i.e. enter ?t.test).
  John
 
  array chip arrayprof...@yahoo.com 9/7/2011 4:11 AM 
  Hi, I am wondering if anyone can suggest how to test the equality of 2
 proportions. The caveat here is that the 2 proportions were calculated
 from the same number of samples using 2 different tests. So essentially we
 are comparing 2 accuracy rates from same, say 100, samples. I think this
 is like a paired test, but don't know if really we need to consider the
 paired nature of the data, and if yes then how? Or just use prop.test()
 to compare 2 proportions?
 
  Any suggestion would be greatly appreciated.
 
  Thanks
 
  John

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] suggestion for proportions

2011-09-07 Thread Viechtbauer Wolfgang (STAT)
Indeed, the original post leaves some room for interpretation. In any case, I 
hope the OP has enough information now to figure out what approach is best for 
his data.

Best,

Wolfgang

 -Original Message-
 From: Bert Gunter [mailto:gunter.ber...@gene.com]
 Sent: Wednesday, September 07, 2011 16:47
 To: Viechtbauer Wolfgang (STAT)
 Cc: r-help@r-project.org; John Sorkin
 Subject: Re: [R] suggestion for proportions
 
 Wolfgang:
 
 On Wed, Sep 7, 2011 at 7:28 AM, Viechtbauer Wolfgang (STAT)
 wolfgang.viechtba...@maastrichtuniversity.nl wrote:
  Acutally,
 
  ?mcnemar.test
 
  since it is paired data.
 
 Actually, it is unclear to me from the OP's message whether this is the
 case.
 
 In one sentence the OP says that the _number_ of samples is the same,
 and in the next he says that essentially the samples are the same.
 So, as usual, imprecision in the problem description leads to
 imprecision in the solution.
 
 But your point is well taken, of course.
 
 -- Bert

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Change color in forest.rma (metafor)

2011-08-29 Thread Viechtbauer Wolfgang (STAT)
See ?par and its mar argument.

 Could you tell me also how to change the size of the chart? There is not
 enough space below the chart to add the arrows!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Change color in forest.rma (metafor)

2011-08-25 Thread Viechtbauer Wolfgang (STAT)
The color of the squares is also currently hard coded. 

The thing is, there are so many different elements to a forest plot (squares, 
lines, polygons, text, axes, axis labels, etc.), if I would add arguments to 
set the color of each element, things would really get out of hand (as far as I 
am concerned, there are already too many arguments to begin with). I can think 
of one possibility: I could allow the col argument to accept a vector of colors 
and then apply the different elements of that vector to the various elements in 
the plot. Of course, there is also a limit to how far that can be taken. For 
example, what if somebody wants to have a different color for *one* of the 
squares and a different color for the other squares?

Another possibility is to do some post-processing with other software. One can 
create the forest plot in R, save it for example as a postscript file, and the 
edit the plot in other software. Yes, I prefer it if I can create the plot in R 
and have it exactly the way I want it (without having to do any 
post-processing), but sometimes that may not be possible.

Note that you can always add whatever you want to a plot created by the 
forest() function after it has been drawn. You can add text, lines, squares, 
polygons, whatever in any color you desire (e.g., with the text(), segments(), 
points(), polygon() functions). So, you could also just plot over the squares 
with:

points(yi, 4:1, pch=15, col=red)

To get rid of the black squares that are drawn by the forest function, add 
psize=0 as an argument in forest() (this will make the size of squares equal to 
0, so essentially, they are invisible).

If you want to make the size of the points inversely proportional to some 
function of the precision of the estimates, use points() together with the cex 
argument. For example:

wi - 1/sqrt(vi)
psize - wi/sum(wi)
psize - (psize - min(psize)) / (max(psize) - min(psize))
psize - (psize * 1.0) + 0.5
points(yi, 4:1, pch=15, col=red, cex=psize)

Best,

Wolfgang

 -Original Message-
 From: Paola Tellaroli [mailto:paola.tellar...@gmail.com]
 Sent: Thursday, August 25, 2011 10:57
 To: Viechtbauer Wolfgang (STAT)
 Cc: r-help@r-project.org; Bernd Weiss
 Subject: Re: [R] Change color in forest.rma (metafor)
 
 Thank you for your attention and help!
 
 In this way I get the diamond coloured, but actually I would have the
 squares representing the values of the individual studies coloured. Is it
 somehow possible?
 
 Paola
 
 
 2011/8/24 Viechtbauer Wolfgang (STAT)
 wolfgang.viechtba...@maastrichtuniversity.nl
 Thank you, Bernd, for looking into this.
 
 Yes, at the moment, the color of the summary estimate for models without
 moderators is hard-coded (as black). I didn't think people may want to
 change that. I guess I was wrong =)
 
 A dirty solution for the moment is to add:
 
 addpoly(dfs, efac=6, row=-1, col=red, border=red, annotate=F, mlab=)
 
 after the call to forest(). You will get a warning message (since the
 border argument gets passed to the text() function inside addpoly() and
 that's not a par for text), but you can just ignore that.
 
 Best,
 
 --
 Wolfgang Viechtbauer
 Department of Psychiatry and Neuropsychology
 School for Mental Health and Neuroscience
 Maastricht University, P.O. Box 616
 6200 MD Maastricht, The Netherlands
 Tel: +31 (43) 368-5248
 Fax: +31 (43) 368-8689
 Web: http://www.wvbauer.com
 
 
  -Original Message-
  From: Bernd Weiss [mailto:bernd.we...@uni-koeln.de]
  Sent: Wednesday, August 24, 2011 16:22
  To: Paola Tellaroli
  Cc: w...@metafor-project.org; r-help@r-project.org
  Subject: Re: [R] Change color in forest.rma (metafor)
 
  Am 24.08.2011 07:50, schrieb Paola Tellaroli:
   My script is the following:
  
   library(metafor)
  
   yi-c(-0.1, 0.2, 0.3, 0.4)
   sei-c(0.4, 0.2, 0.6, 0.1)
   vi-sei^2
   studi-c(A, B, C, D)
   eventi.c-c(10, 5, 7, 6)
   n.c-c(11, 34, 25, 20)
   eventi.a-c(2, 7, 6, 5)
   n.a-c(11, 35, 25, 15)
   dfs-rma(yi, vi, method=DL)
   dfs
  
   windows(height=6, width=10, pointsize=10)
   windowsFonts(B=windowsFont(Bookman Old Style))
  
   forest.rma(dfs, slab=studi, xlim=c(-15, 10), ilab=cbind(eventi.c, n.c,
   eventi.a, n.a), ilab.xpos=c(-9.5, -8, -6, -4.5), cex=1.2, at=c(-2, -1,
  0, 1,
   2), family=B, xlab=Hazard Ratio (log scale), mlab=Random Effects
   Model, efac=5, col=red, border=red)
   text(-10, -1.3, paste(Heterogeneity: I-squared=,
  paste(paste(round(dfs$I2,
   2), %, sep=), paste(p, round(dfs$QEp, 4), sep==), sep=, ),
   sep=), font=4, cex=1.2, family=B)
  
   op-par(cex=1.2, font=2, family=B, oma=c(0.5, 0.5, 0.5, 0.5),
  mar=c(0.5,
   0.5, 0.5, 0.5))
   text(x=c(-9.5, -8, -6, -4.5), 6, c(Events, N, Events, N),
  cex=1.2 )
   text(c(-8.7, -5.5, 8), 6.5, c(S, A, Log))
   text(-15, 6, Trials, pos=4)
   text(10, 6, Hazard Ratio [95% CI], pos=2)
   par(op)
  
   Even if I have specified col=red, border=red, color of squares
 and
   diamond rests black! Why?
 
  As far as I know, col and border do

Re: [R] Bivariate normal regression in R

2011-08-25 Thread Viechtbauer Wolfgang (STAT)
Another way would be to consider this as a path model and use the sem or lavaan 
package to fit this model. Here is an example:

x  - rnorm(1000)
e1 - rnorm(1000)
e2 - e1 + rnorm(1000)
e1 - e1 + rnorm(1000)
y1 - 2 + 1*x + e1
y2 - 4 + 2*x + e2

dat - data.frame(x, y1, y2)

model - 'y1 ~ x
  y2 ~ x'

fit - sem(model, data=dat)
summary(fit)

However, note that you could just as well run two separate regressions:

summary(lm(y1 ~ x))
summary(lm(y2 ~ x))

The results are virtually identical. 

Best,

Wolfgang

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Dimitris Rizopoulos
 Sent: Thursday, August 25, 2011 20:28
 To: DHIMAN BHADRA
 Cc: r-help@r-project.org
 Subject: Re: [R] Bivariate normal regression in R
 
 One possibility is function gls() from package nlme.
 
 Best,
 Dimitris
 
 
 On 8/25/2011 8:22 PM, DHIMAN BHADRA wrote:
  Hello everyone,
 
  I need to fit a bivariate normal regression model to a dataset where the
  same covariate (say, X) influences two separate but correlated responses
  (say, Y1 and Y2). So, the bivariate
  model would look like :
 
  Y1 = a1 + b1*X + e1
  Y2 = a2 + b2*X + e2
 
  where e1 and e2 are error terms which can be correlated. Is there any
  package in R which can help me fit this model ? Any help will be
  appreciated.
 
  Best regards,
  Dhiman Bhadra
 
  Worcester Polytechnic Institute,
  100 Institute Road, Worcester, Ma : 01609.
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 --
 Dimitris Rizopoulos
 Assistant Professor
 Department of Biostatistics
 Erasmus University Medical Center
 
 Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
 Tel: +31/(0)10/7043478
 Fax: +31/(0)10/7043014
 Web: http://www.erasmusmc.nl/biostatistiek/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Change color in forest.rma (metafor)

2011-08-24 Thread Viechtbauer Wolfgang (STAT)
Thank you, Bernd, for looking into this. 

Yes, at the moment, the color of the summary estimate for models without 
moderators is hard-coded (as black). I didn't think people may want to change 
that. I guess I was wrong =)

A dirty solution for the moment is to add:

addpoly(dfs, efac=6, row=-1, col=red, border=red, annotate=F, mlab=)

after the call to forest(). You will get a warning message (since the border 
argument gets passed to the text() function inside addpoly() and that's not a 
par for text), but you can just ignore that.

Best,

-- 
Wolfgang Viechtbauer 
Department of Psychiatry and Neuropsychology 
School for Mental Health and Neuroscience 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
Tel: +31 (43) 368-5248 
Fax: +31 (43) 368-8689 
Web: http://www.wvbauer.com 


 -Original Message-
 From: Bernd Weiss [mailto:bernd.we...@uni-koeln.de]
 Sent: Wednesday, August 24, 2011 16:22
 To: Paola Tellaroli
 Cc: w...@metafor-project.org; r-help@r-project.org
 Subject: Re: [R] Change color in forest.rma (metafor)
 
 Am 24.08.2011 07:50, schrieb Paola Tellaroli:
  My script is the following:
 
  library(metafor)
 
  yi-c(-0.1, 0.2, 0.3, 0.4)
  sei-c(0.4, 0.2, 0.6, 0.1)
  vi-sei^2
  studi-c(A, B, C, D)
  eventi.c-c(10, 5, 7, 6)
  n.c-c(11, 34, 25, 20)
  eventi.a-c(2, 7, 6, 5)
  n.a-c(11, 35, 25, 15)
  dfs-rma(yi, vi, method=DL)
  dfs
 
  windows(height=6, width=10, pointsize=10)
  windowsFonts(B=windowsFont(Bookman Old Style))
 
  forest.rma(dfs, slab=studi, xlim=c(-15, 10), ilab=cbind(eventi.c, n.c,
  eventi.a, n.a), ilab.xpos=c(-9.5, -8, -6, -4.5), cex=1.2, at=c(-2, -1,
 0, 1,
  2), family=B, xlab=Hazard Ratio (log scale), mlab=Random Effects
  Model, efac=5, col=red, border=red)
  text(-10, -1.3, paste(Heterogeneity: I-squared=,
 paste(paste(round(dfs$I2,
  2), %, sep=), paste(p, round(dfs$QEp, 4), sep==), sep=, ),
  sep=), font=4, cex=1.2, family=B)
 
  op-par(cex=1.2, font=2, family=B, oma=c(0.5, 0.5, 0.5, 0.5),
 mar=c(0.5,
  0.5, 0.5, 0.5))
  text(x=c(-9.5, -8, -6, -4.5), 6, c(Events, N, Events, N),
 cex=1.2 )
  text(c(-8.7, -5.5, 8), 6.5, c(S, A, Log))
  text(-15, 6, Trials, pos=4)
  text(10, 6, Hazard Ratio [95% CI], pos=2)
  par(op)
 
  Even if I have specified col=red, border=red, color of squares and
  diamond rests black! Why?
 
 As far as I know, col and border do only affect the fitted values
 (diamonds), i.e. the FEM/REM estimators (see ?forest.rma: col:
 character string specifying the name of a color to use for _the fitted_
 values ('darkgray' by default).)
 
 Furthermore, I had a quick look at the source code and it might be a
 bug. If I replace in line 2770 the line
 
 cex * efac), col = black, ...)
 
 with
 
 cex * efac), col = col, ...)
 
 you can at least specify your own colour. Changing the border color
 seems a bit more tricky...
 
 However, Wolfgang Viechbauer (the package author) is always a very
 responsive and helpful person and I suggest you better wait for his
 answer.
 
 Bernd

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] questions about metafor package

2011-08-17 Thread Viechtbauer Wolfgang (STAT)
Dear Emilie,

Regarding your questions:

1) It's not the weighting that is the main issue when you do not have the SDs. 
The problem is that you need the SDs to calculate the sampling variances of the 
mean differences (I assume that this is your outcome measure for the 
meta-analysis). Those are needed to calculate the standard errors of the model 
coefficients.

There are two possible routes to take. The first would be to try your hardest 
to get your hands on as many of the missing SDs as possible. Whatever is left 
missing could be imputed, using a sensible range of values and checking for the 
robustness of the findings.

The other approach would be to choose some other weights (e.g., sample size 
weights), then fit the model by WLS, and then estimate the standard errors of 
the model coefficients using a robust method (e.g., using a sandwich 
estimator).

2) Difficult to say. I haven’t had a chance to read this article, but this will 
probably tell you more:

Ishak, K. J., Platt, R. W., Joseph, L.,  Hanley, J. A. (2008). Impact of 
approximating or ignoring within-study covariances in multivariate 
meta-analyses. Statistics in Medicine, 27(5), 670-686.

Best,

-- 
Wolfgang Viechtbauer 
Department of Psychiatry and Neuropsychology 
School for Mental Health and Neuroscience 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
Tel: +31 (43) 368-5248 
Fax: +31 (43) 368-8689 
Web: http://www.wvbauer.com 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Emilie MAILLARD
 Sent: Wednesday, August 17, 2011 17:21
 To: r-help@r-project.org
 Subject: [R] questions about metafor package
 
 Hello,
 
 I would like to do a meta-analysis with the package « metafor ». Ideally I
 would like to use a mixed model because I’m interested to see the effect
 of some moderators. But the data set I managed to collect from literature
 presents two limits.
 
 - Firstly, for each observation, I have means for a treatment and
 for a control, but I don’t always have corresponding standard deviations
 (52 of a total of 93 observations don’t have standard deviations).
 Nevertheless I have the sample sizes for all observations so I wonder if
 it was possible to weight observations by sample size in the package
 « metafor ».
 - Secondly, some observations are probably not independent as I
 have sometimes several relevant observations for a same design. More
 precisely, for these cases, the control mean is identical but treatment
 means varied. Ideally, I would not like to do a weighted average for these
 non-independent observations because these observations represent levels
 of a moderator. I know that the package « metafor » is not designed for
 the analysis of correlated outcomes. What are the dangers of using the
 package even if observations are not really independent ?
 
 Thank you for your help,
 
 Émilie.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Main-effect of categorical variables in meta-analysis (metafor)

2011-08-05 Thread Viechtbauer Wolfgang (STAT)
Dear Jokel,

If a moderator has 4 levels, then you need 3 dummy variables (one of the levels 
will become your reference level, so you do not need a dummy for that one). 
You can do the dummy-coding yourself or let R handle it. For example, if the 
moderator is called catmod, then:

rma(yi, vi, mods = ~ factor(catmod), data=some.data.frame)

should do the trick (you do not need factor() if catmod is already a factor 
variable in the data frame). R will create the dummies for you. If you do not 
like which level is chosen as the reference level, then take a look at the 
relevel() function. In particular, 

rma(yi, vi, mods = ~ relevel(factor(catmod), ref = reflevel), 
data=some.data.frame)

will set the reference level to reflevel.

If you have two categorical moderators, let's call them catmod1 and catmod2, 
then:

res0 - rma(yi, vi, mods = ~ factor(catmod1) + factor(catmod2), 
data=some.data.frame)

will give you a model without and

res1 - rma(yi, vi, mods = ~ factor(catmod1) * factor(catmod2), 
data=some.data.frame)

will give you a model with the interaction between the two factors. In the 
latter model, you will get lots of coefficients for the interaction, each 
testing whether the difference between a particular catmod2 level and the 
reference catmod2 level differs across the levels of catmod1 (and vice-versa). 
To test whether the interaction is significant in general, you can either do a 
Wald-type test with:

rma(yi, vi, mods = ~ factor(catmod1)*factor(catmod2), data=some.data.frame, 
btt=X:Y)

where X is the number of the first interaction coefficient and Y is the 
number of the last interaction coefficient (so, these are indices to indicate 
which coefficients should be tested simultaneously). In the output, you will 
the results of this test under Test of Moderators.

Alternatively, you can do a likelihood-ratio test with:

res0 - rma(yi, vi, mods = ~ factor(catmod1) + factor(catmod2), 
data=some.data.frame, method=ML)
res1 - rma(yi, vi, mods = ~ factor(catmod1) * factor(catmod2), 
data=some.data.frame, method=ML)
anova(res1, res0)

Note that you need to use ML-estimation when doing the LR-test.

Similar omnibus tests of several coefficients (full versus reduced model 
comparisons) can be done for the main effects.

An example with the BCG dataset:

data(dat.bcg)
dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
append=TRUE)
dat$ablat.cat - ifelse(dat$ablat  30, far, close)

rma(yi, vi, mods = ~ factor(alloc) * factor(ablat.cat), data=dat, btt=5:6)

res0 - rma(yi, vi, mods = ~ factor(alloc) + factor(ablat.cat), data=dat, 
method=ML)
res1 - rma(yi, vi, mods = ~ factor(alloc) * factor(ablat.cat), data=dat, 
method=ML)
anova(res0, res1)

I hope this helps!

Best,

-- 
Wolfgang Viechtbauer 
Department of Psychiatry and Neuropsychology 
School for Mental Health and Neuroscience 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
Tel: +31 (43) 368-5248 
Fax: +31 (43) 368-8689 
Web: http://www.wvbauer.com 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jokel Meyer
 Sent: Friday, August 05, 2011 10:45
 To: r-help@r-project.org
 Subject: [R] Main-effect of categorical variables in meta-analysis
 (metafor)
 
 Dear R-experts!
 
 In a meta-analysis (metafor) I would like to assess the effect of two
 categorical covariates (A  B) whereas they both have 4 levels.
 Is my understanding correct that this would require to dummy-code (0,1)
 each
 level of each covariate (A  B)?
 However I am interested in the main-effects and the interaction of these
 two
 covariates and the dummy-coding would only allow to detect the effect of
 one
 level of one factor. Would there be a way to assess main-effects and
 interactions (something like an meta-analysis-ANOVA)?
 
 Many thanks,
 Jokel
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Converting F-value from ANOVA to cohen's d in meta-analysis (metafor-package)

2011-07-27 Thread Viechtbauer Wolfgang (STAT)
Dear Jokel,

Unfortunately, this won't work. The derivation of the equation given in the 
Handbook shows why this is so. First of all, note that

d = (m1 - m2) / sp,

where m1 and m2 are the means of the two groups and sp is the pooled SD. The 
two independent samples t-test (assuming homoscedastic variances in the two 
groups) uses the test statistic

t = d / sqrt((n1 + n2) / (n1*n2)),

which we can turn around to get:

d = t * sqrt((n1 + n2) / (n1*n2))

Since t^2 = F for the one-way ANOVA for two groups, we get the equation in the 
Handbook. For three groups, this won't work (the F-statistic then has 2 df (in 
the numerator) and does not reflect a simple contrast between two groups).

If you are willing to make the assumption that m_C = m_D in those 3 group 
studies, then you can reconstruct the F value for the one-way ANOVA with two 
groups (where C and D are collapsed into a single group) from the F value for 
the one-way ANOVA with three groups. In particular,

F_two_groups = F_three_groups * 2 * (N - 2) / (N - 3),

where N = total sample size of all three groups combined. Then you can use that 
F-value in the equation given in the Handbook, where n1 = n_E and n2 = n_C + 
n_D.

This will be exactly correct if m_C = m_D (i.e., in the sample). It will be 
approximately correct if you are willing to assume that any difference between 
m_C and m_D is only due to sampling error and does not reflect a true 
difference between those two groups (i.e., the population means must be the 
same).

Best,

-- 
Wolfgang Viechtbauer 
Department of Psychiatry and Neuropsychology 
School for Mental Health and Neuroscience 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
Tel: +31 (43) 368-5248 
Fax: +31 (43) 368-8689 
Web: http://www.wvbauer.com 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Jokel Meyer
 Sent: Wednesday, July 27, 2011 13:29
 To: r-help@r-project.org
 Subject: [R] Converting F-value from ANOVA to cohen's d in meta-analysis
 (metafor-package)
 
 Dear R-experts!
 
 Running a meta-analysis (using the magnificent metafor-package), I use
 cohen's d as a main outcome measure in a random-effects model.
 For most of the samples cohen's d is derived form a comparison of two
 groups
 (A  B). However some studies report results from an ANOVA (one-factor
 with
 three levels: C,D,E) whereas two groups (C,D) correspond to one group in
 the
 other studies (B=C,D). Is there a way?
 The handbook of research synthesis and meta-analysis By Harris M. Cooper
 says that:
 d=sqrt((F*(n1+n2)/n1*n2)) for ANOVA (one-factor with two-levels)
 but does this also hold for ANOVA (one-factor with three levels)?
 
 Many thanks for your help!
 Jokel
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] compute the mean of two (or more) correlations

2011-07-26 Thread Viechtbauer Wolfgang (STAT)
And at that point, one is essentially doing a meta-analysis. For example:

library(metafor)

ri - c(.5, .4)
ni - c(40, 25)

res - rma(ri=ri, ni=ni, measure=ZCOR, method=FE)
predict(res, transf=transf.ztor, digits=2)

 pred  se ci.lb ci.ub
 0.46  NA  0.24  0.64

You also get the CI (in addition to the back-transformed average).

Best,

Wolfgang

-- 
Wolfgang Viechtbauer 
Department of Psychiatry and Neuropsychology 
School for Mental Health and Neuroscience 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
Tel: +31 (43) 368-5248 
Fax: +31 (43) 368-8689 
Web: http://www.wvbauer.com 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Michael Dewey
 Sent: Tuesday, July 26, 2011 12:23
 To: Joshua Wiley; Martin Batholdy
 Cc: r-help@r-project.org
 Subject: Re: [R] compute the mean of two (or more) correlations
 
 At 15:47 25/07/2011, Joshua Wiley wrote:
 Hi Martin,
 
 Off hand I do not know of a pre-defined function to do it, but the
 z-transformation is just the inverse hyperbolic function, the mean
 is just the mean, and the back transformation is the hypoerbolic
 function so...
 
 
 x - c(.5, .4)
 tanh(mean(atanh(x)))
 
 
 should do it.
 
 Assuming the correlations are based on the same sample size as I
 would have thought one would otherwise have wanted to weight them.
 
 
 Cheers,
 
 Josh
 
 On Mon, Jul 25, 2011 at 7:11 AM, Martin Batholdy
 batho...@googlemail.com wrote:
   Hi,
  
  
   is there a function in R that computes the mean of two (or more)
  correlations?
   (that is doing the z-transformation of the correlations,
  computing the mean of the z-values and then retransform it to a
 correlation).
  
   Or is there a fisher-table implemented?
  
  
   I have not found anything via help.search() or google so far.
  
  
   thank you!
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 
 
 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 https://joshuawiley.com/
 
 Michael Dewey
 i...@aghmed.fsnet.co.uk
 http://www.aghmed.fsnet.co.uk/home.html
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extract confidence intervals from rma object (metafor package)

2011-07-18 Thread Viechtbauer Wolfgang (STAT)
Dear Jokel,

Right now, none of the functions return that information. But it's easy to 
calculate those CIs by hand (simply take yi +- 1.96 sqrt(vi) and apply, if 
needed, some appropriate transformation). For example:

data(dat.bcg)
dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, 
  data=dat.bcg, append=TRUE)
exp(dat$yi - 1.96*sqrt(dat$vi))
exp(dat$yi + 1.96*sqrt(dat$vi))

gives you approximate 95% CIs for the RRs. The forest functions essentially do 
nothing different.

I hope this helps!

Best,

--
Wolfgang Viechtbauer
Department of Psychiatry and Neuropsychology
School for Mental Health and Neuroscience
Maastricht University, P.O. Box 616
6200 MD Maastricht, The Netherlands
Tel: +31 (43) 368-5248
Fax: +31 (43) 368-8689
Web: http://www.wvbauer.com

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Jokel Meyer [jokel.me...@googlemail.com]
Sent: Monday, July 18, 2011 6:44 PM
To: r-help@r-project.org
Subject: [R] Extract confidence intervals from rma object (metafor package)

Dear R-experts!

I am working on some meta-analysis using the metafor package. I would like
to extract values of the confidence intervals of the effect sizes of the
single studies from an rma object. Those values are printed out when
plotting a forest plot using the forest function on the rma object, however
I was not able to locate them.

Many thanks for your help!
Jokel

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >