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.viechtbauer at 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.can at 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.viechtbauer at 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-bounces at r-project.org] On Behalf Of John > > > Peterson > > > Sent: Monday, December 07, 2015 01:39 > > > To: r-help at 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] > >[[alternative HTML version deleted]]
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.can at gmail.com] > Sent: Tuesday, December 08, 2015 14:25 > To: Viechtbauer Wolfgang (STAT) > Cc: R-help at 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.viechtbauer at 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.can at 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.viechtbauer at 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-bounces at r-project.org] On Behalf Of John > > > Peterson > > > Sent: Monday, December 07, 2015 01:39 > > > To: r-help at 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]
Hi Dr. Viechtbauer, Thank you very much. Putting in sei=se in forest() fixed the problem. Thanks for your help. On 8 December 2015 at 08:37, Viechtbauer Wolfgang (STAT) < wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:> 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.can at gmail.com] > > Sent: Tuesday, December 08, 2015 14:25 > > To: Viechtbauer Wolfgang (STAT) > > Cc: R-help at 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.viechtbauer at 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.can at 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.viechtbauer at 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-bounces at r-project.org] On Behalf Of John > > > > Peterson > > > > Sent: Monday, December 07, 2015 01:39 > > > > To: r-help at 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] >[[alternative HTML version deleted]]