Annotated R Code for Gonzalez-Mulé and Aguinis (2018, Journal of Management)

Below is the R code used for analyses described in the following article:

Gonzalez-Mulé, E., & Aguinis, H. 2018. Advancing theory by assessing boundary conditions with meta-regression: A critical review and best-practice recommendations. Journal of Management, 44(6): 2246–2273.[copyright notice: You may download this article for one-time personal use only; please obtain publisher permission for any further distribution, publication, or commercial use.] [pdf]

  • Click here to download the Extraversion and Job Satisfaction data file
  • Click here to download the Extraversion and Job Performance data file

The following R syntax produces meta-regression analyses using raw data. This example refers to the two illustrative meta-regression studies described in the Journal of Management article.

Before running the syntax, load the data into R. The data in this example are structured with 5 columns, with each row pertaining to information from each individual study, as shown in the following table:

ES

v

x1

x2

x3

.15

.010

3.29

3.80

4.91

.25

.005

4.92

4.39

4.50

20

.005

3.80

4.12

4.80

.25

.003

4.04

4.50

4.77

where ES refers to the effect sizes from the primary studies (in this case, correlation coefficients); v refers to the estimate of within-study variance for the study; and x1, x2, and x3 refer to the moderator values from the primary studies. In our particular example, x1 corresponds to leading others, x2 corresponds to impact on others, and x3 corresponds to contact with others.

Note that this format is identical to the one used for power analyses detailed in Appendix C except that no column corresponds to expected effect sizes. The rest of the data are from our raw data files and continues down to the number of studies in the data. The syntax is then as follows:

*Load the metafor program.

library(metafor)

 

*Run the ME meta-regression model. ES and v specify the effect sizes and within-study variances, respectively, moderators are specified in the cbind() command, data refers to the name of the dataset in R, and the knh command instructs the program to use the Knapp and Hartung (2003) method for the significance of model coefficients. Note that the program automatically uses the REML estimator to calculate the residual heterogeneity, defaults to the ME model, and automatically calculates R2Meta. Also, note that the second res command is necessary to display results.

> res <- rma(ES, v, mods = cbind(x1, x2, x3), data = dataset, knha = TRUE)

> res

 

*Run the FE meta-regression model. Note that the program automatically uses the Hedges and Olkin (2014) method for the significance of model coefficients.

> res <- rma(ES, v, mods = cbind(x1, x2, x3), data = dataset, method = "FE")

> res
                                    

Please refer to Viechtbauer (2010) for additional options and syntax information.