[R-meta] R-sig-meta-analysis Digest, Vol 35, Issue 5

Tarun Khanna kh@nn@ @end|ng |rom hert|e-@choo|@org
Mon Apr 13 13:04:28 CEST 2020


Hi,


I ended up writing the following script to format and display results from multiple Metafor models. Sharing it in case it's of use to anyone else.


# META REGRESSION MODELS

model.z = rma(yi=z_coeff, vi = var_z, method="DL", data = df,
                mods = ~ `controls Electricity use` + `controls Energy prices`+ `controls Environmental attitudes` +
                  `controls HH controls (demographics)` + `controls Residence controls` + `controls Seasonal controls` +
                  `controls Weather controls`)

model.z.f = rma(yi=z_coeff, vi = var_z, method="DL", data = df[df$Feedback == 1,],
              mods = ~ `controls Electricity use` + `controls Energy prices`+ `controls Environmental attitudes` +
                `controls HH controls (demographics)` + `controls Residence controls` + `controls Seasonal controls` +
                `controls Weather controls`)


model.z.m = rma(yi=z_coeff, vi = var_z, method="DL", data = df[df$MonetaryIncentives == 1,],
                mods = ~ `controls Electricity use` + `controls Energy prices`+ `controls Environmental attitudes` +
                  `controls HH controls (demographics)` + `controls Residence controls` + `controls Seasonal controls` +
                  `controls Weather controls`)


model.z.i = rma(yi=z_coeff, vi = var_z, method="DL", data = df[df$Information == 1,],
                mods = ~ `controls Electricity use` + `controls Energy prices`+ `controls Environmental attitudes` +
                  `controls HH controls (demographics)` + `controls Residence controls` + `controls Seasonal controls` +
                  `controls Weather controls`)

#function to extract information from the summary of rma output
tidy2.rma <- function (x, ...) {
  ret <- createTexreg(coef.names = rownames(coef(summary(x))),
               coef = coef(summary(x))$estimate,
               se = coef(summary(x))$se,
               pvalues = coef(summary(x))$pval)
  return(ret)
}

# organize the output summary in form of lists
tr    <- tidy2.rma(model.z)
tr.f  <- tidy2.rma(model.z.f)
tr.i  <- tidy2.rma(model.z.i)
tr.m  <- tidy2.rma(model.z.m)

# print regression outputs to console
screenreg(list(tr, tr.f, tr.i, tr.m),
          custom.model.names = c("All", "Feedback", "Infomation", "Monetary Incentives"),
          custom.coef.names =  c("Intercept", "Electricity use", "Energy prices", "Environmental attitudes",
                                   "Demographics", "House type", "Seasonal controls", "Weather controls")
          )

# output to word
htmlreg(list(tr, tr.f, tr.i, tr.m),
        custom.model.names = c("All", "Feedback", "Infomation", "Monetary Incentives"),
        custom.coef.names =  c("Intercept", "Electricity use", "Energy prices", "Environmental attitudes",
                               "Demographics", "House type", "Seasonal controls", "Weather controls"),
        file = "mytable.doc",
        inline.css = FALSE, doctype = TRUE, html.tag = TRUE, head.tag = TRUE, body.tag = TRUE
        )



Best

Tarun


Tarun Khanna

PhD Researcher

Hertie School


Friedrichstraße 180

10117 Berlin ∙ Germany
khanna using hertie-school.org ∙ www.hertie-school.org<http://www.hertie-school.org/>

________________________________
From: R-sig-meta-analysis <r-sig-meta-analysis-bounces using r-project.org> on behalf of r-sig-meta-analysis-request using r-project.org <r-sig-meta-analysis-request using r-project.org>
Sent: 05 April 2020 12:00:02
To: r-sig-meta-analysis using r-project.org
Subject: R-sig-meta-analysis Digest, Vol 35, Issue 5

Send R-sig-meta-analysis mailing list submissions to
        r-sig-meta-analysis using r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
or, via email, send a message with subject or body 'help' to
        r-sig-meta-analysis-request using r-project.org

You can reach the person managing the list at
        r-sig-meta-analysis-owner using r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-meta-analysis digest..."


Today's Topics:

   1. Formatting output from Metafor and performing Clustered
      Robust Variance Estimation (Tarun Khanna)
   2. Re:  Formatting output from Metafor and performing Clustered
      Robust Variance Estimation (Michael Dewey)

----------------------------------------------------------------------

Message: 1
Date: Sat, 4 Apr 2020 14:13:42 +0000
From: Tarun Khanna <khanna using hertie-school.org>
To: "r-sig-meta-analysis using r-project.org"
        <r-sig-meta-analysis using r-project.org>
Subject: [R-meta] Formatting output from Metafor and performing
        Clustered Robust Variance Estimation
Message-ID: <d63132ef994b4aec9f17e3f0bd9b4186 using hertie-school.org>
Content-Type: text/plain; charset="utf-8"

Dear All,

I am using Metafor package for meta analysis in economics. I have a couple of questions though:

1. Are there any packages available that can take output from the rma function in Metafor and format them neatly and easily? For example the Stargazer package that can be used with OLS regression but doesn't work for Metafor package.

2. Is there guidance available on how to correct for bias emerging from multiple effect sizes originating from the same study in the metafor package? How would you for example example estimate the model using the cluster function provide Clustered Robust Variance Estimation?

Thanks in advance,
Tarun

Tarun Khanna
PhD Researcher

Hertie School

Friedrichstraße 180
10117 Berlin ∙ Germany
khanna using hertie-school.org ∙ www.hertie-school.org<http://www.hertie-school.org/<http://www.hertie-school.org<http://www.hertie-school.org/>>

        [[alternative HTML version deleted]]



------------------------------

Message: 2
Date: Sat, 4 Apr 2020 15:42:09 +0100
From: Michael Dewey <lists using dewey.myzen.co.uk>
To: Tarun Khanna <khanna using hertie-school.org>,
        "r-sig-meta-analysis using r-project.org"
        <r-sig-meta-analysis using r-project.org>
Subject: Re: [R-meta]  Formatting output from Metafor and performing
        Clustered Robust Variance Estimation
Message-ID: <6c8d5c08-2124-11ef-80dc-b0a3973dabfd using dewey.myzen.co.uk>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

See in-line

On 04/04/2020 15:13, Tarun Khanna wrote:
> Dear All,
>
> I am using Metafor package for meta analysis in economics. I have a couple of questions though:
>
> 1. Are there any packages available that can take output from the rma function in Metafor and format them neatly and easily? For example the Stargazer package that can be used with OLS regression but doesn't work for Metafor package.
>

Not as far as I know. The output has a number of sections with different
layouts so I think writing a general function to specify how to format
each one would be unwieldy. You could always extract the parts you need
ad use xtable() for instance as many of them are data.frames or ould be
coerced to data frames.

> 2. Is there guidance available on how to correct for bias emerging from multiple effect sizes originating from the same study in the metafor package? How would you for example example estimate the model using the cluster function provide Clustered Robust Variance Estimation?
>

I do not see a cluster() function in metafor. Do you mean robust()? If
you do perhaps you could specify exactly which part of the documentation
you do not understand as people can help you better.

Michael

> Thanks in advance,
> Tarun
>
> Tarun Khanna
> PhD Researcher
>
> Hertie School
>
> Friedrichstraße 180
> 10117 Berlin ∙ Germany
> khanna using hertie-school.org ∙ www.hertie-school.org<http://www.hertie-school.org/<http://www.hertie-school.org<http://www.hertie-school.org/>>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-meta-analysis mailing list
> R-sig-meta-analysis using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
>
>

--
Michael
http://www.dewey.myzen.co.uk/home.html




------------------------------

Subject: Digest Footer

_______________________________________________
R-sig-meta-analysis mailing list
R-sig-meta-analysis using r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis


------------------------------

End of R-sig-meta-analysis Digest, Vol 35, Issue 5
**************************************************

	[[alternative HTML version deleted]]



More information about the R-sig-meta-analysis mailing list