2. Regression with Interaction
Suppose we aim to conduct a random-effects model meta-analysis to explore the interaction between falls and age and investigate whether the effect of falls on hip fractures varies across different age levels. (Note: This example is for illustrative purposes only and is not intended to provide any evidence on the topic.) A Poisson regression model can be utilized to examine these effects.
The Poisson model is specified as follows:
with the following log-linear relationship:
The effect of falls can be calculated as:
If exponentiatinge , yields the rate ratio (RR) for the effect.
The effect of falls depends on
, and its
confidence interval can be calculated as:[
5]
In this model, n represents the sample size, p denotes the number of predictors, and for large samples, the t score can be approximated by the z score. The variable "age" serves as an effect modifier.
For a two-stage meta-analysis, the overall effects and variances of
and
can be calculated using the inverse-weighted average method.[
6,
7,
8,
9] Moreover, it is essential to combine these two regression coefficients to construct confidence intervals for the effect of falls at different age levels.
We present a method for combining coefficients and their covariance in a two-stage random-effects meta-analysis when interactions are present.
Suppose we have data from 10 cohort studies. For each cohort, we fit the specified Poisson regression model and obtain the following results:
In
Table 1,
represents the coefficient for falls (i.e., the main effect) in the
cohort, while
corresponds to the interaction effect of fall * age.
and
denote the variances of
and
, respectively, and
is the covariance between these coefficients. Finally,
represents the sample size for each cohort.
5. Example: Analyzing the 10 Cohort Studies in Table 1
5.1. Meta-Analysis for
We wrote custom R functions to perform meta-analysis on the data in
Table 1. The following R functions conduct both fixed-effect and random-effect meta-analyses for
.
studies <- read.csv(’https://raw.githubusercontent.com/enwuliu/
meta-analysis/main/random_effect_meta_sim.csv’, header = TRUE)
b1<-studies$b1 # beta1 from the 10 cohorts
var_b1 <- studies$var_b1 # variances of the coefficients
fixed_effect_meta <- function(B, V) {
W <- 1 / V
Beta <- sum(W * B) / sum(W)
Var <- 1 / sum(W)
resultlist <- list(’Overall beta’ = Beta, ’Overall variance’ = Var)
return(resultlist)
}
random_effect_meta <- function(B, V) {
W <- 1 / V
Q <- sum(W * B^2) - (sum(W * B))^2 / sum(W)
df <- length(B) - 1
c <- sum(W) - sum(W^2) / sum(W)
tau_square <- ifelse(Q > df, (Q - df) / c, 0)
V_star <- V + tau_square
W_star <- 1 / V_star
Beta_star <- sum(W_star * B) / sum(W_star)
Var_star <- 1 / sum(W_star)
resultlist <- list(
’Overall beta’ = Beta_star,
’Overall variance’ = Var_star)
return(resultlist)
}
fixed_b1 <- fixed_effect_meta(b1, var_b1)
fixed_b1
# $`Overall beta`
# [1] 1.040411
#
# $`Overall variance`
# [1] 0.6841809
random_b1 <- random_effect_meta(b1, var_b1)
random_b1
# $`Overall beta`
# [1] 1.014141
#
# $`Overall variance`
# [1] 0.7308388
From the results, the overall fixed-effect estimate for is 1.040411, with an overall variance of 0.6841809. The overall random-effect estimate is 1.014141, with an overall variance of 0.7308388.
5.2. Meta-Analysis for
We used the same R functions to perform meta-analysis for :
b2 <- studies$b2 # beta2 from the 10 cohorts
var_b2 <- studies$var_b2 # variances of the coefficients
fixed_b2<-fixed_effect_meta(b2, var_b2)
fixed_b2
# $`Overall beta`
# [1] -0.01140614
#
# $`Overall variance`
# [1] 0.0001403961
random_b2<-random_effect_meta(b2, var_b2)
random_b2
# $`Overall beta`
# [1] -0.01140614
#
# $`Overall variance`
# [1] 0.0001403961
Both fixed-effect and random-effect meta-analyses yield an overall interaction effect of =-0.01140614, with a variance of 0.0001403961.
5.3. Meta-Analysis for r
The following R functions were used to conduct a meta-analysis of the correlation coefficients
fixed_effect_meta_r<-function(v1,v2,cov12,sample_size){
r<-cov12/sqrt(v1*v2) #correlation coefficient
z<-0.5*log((1+r)/(1-r)) #Fisher z transformation
v<-1/(sample_size-3) #variance for z
W<-1/v #weight
z_overall<-sum(W*z)/sum(W) #overall random effect of z
r_overall<-(exp(2*z_overall)-1)/(exp(2*z_overall)+1) #transform back to r
return(r_overall)
}
random_effect_meta_r<-function(v1,v2,cov12,sample_size){
r<-cov12/sqrt(v1*v2) #correlation coefficient
z<-0.5*log((1+r)/(1-r)) #Fisher z transformation
v<-1/(sample_size-3) #variance for z
W<-1/v #weight
Q<-sum(W*z^2)-(sum(W*z))^2/sum(W) #total variance or Q statistics
c<-sum(W)-sum(W^2)/sum(W) #c is the scaling factor
df=length(v1)-1 #degree of freedom
tau_square<-ifelse(Q>df,(Q-df)/c,0) #between study variance
v_star=v+tau_square
W_star=1/v_star #new weight
z_star<-sum(W_star*z)/sum(W_star) #overall random effect of z
r_overall<-(exp(2*z_star)-1)/(exp(2*z_star)+1) #transform back to r
return(r_overall)
}
v1<-studies$var_b1
v2<-studies$var_b2
v12<-studies$cov_b1b2
sample_size<-studies$sample_size
r<-v12/sqrt(v1*v2)
fixed_meta_r<-fixed_effect_meta_r(v1,v2,v12,sample_size)
fixed_meta_r
#[1] -0.9600286
random_meta_r<-random_effect_meta_r(v1,v2,v12,sample_size)
random_meta_r
#[1] -0.9493409
The overall r for fixed-effect meta-analysis is -0.9600286, while the random-effect meta-analysis gives -0.9493409.
5.4. Overall Covaraince for and
Using Equation (
12), the overall covariance is calculated as follows:
5.5. Calculating the Dffect of Falls on Hip Fracture at Different Ages and Its 95% Confidence Intervals
Using the information derived above, we can calculate the effect of falls on hip fracture at different ages and its corresponding 95% confidence intervals using Equation (
2). Additionally, we generate a plot of the rate ratio (RR) for hip fracture, comparing fallers versus non-fallers at various ages, by exponentiating the estimated
coefficients.
To illustrate, we calculate the effect of falls on hip fracture for ages 50 to 90. First, we conduct a fixed-effect meta-analysis, followed by a random-effect meta-analysis.
The following R code calculates the interaction effect of falls with age and the corresponding 95% confidence intervals, using Equation (
2), based on the results of the fixed- and random-effect meta-analyses.
library(ggplot2)
library(ggpubr)
plot_with_interaction <- function(age, b1, v1, b2, v2, r) {
cov_b1b2 <- r * sqrt(v1 * v2)
RR <- exp(b1 + b2 * age)
RR_lower <- exp((b1+b2*age)-1.96 * sqrt(v1+age^2 * v2+2 * age*cov_b1b2))
RR_upper <- exp((b1+b2*age)+1.96*sqrt(v1+age^2 * v2+2*age*cov_b1b2))
ndata <- as.data.frame(cbind(RR, RR_lower, RR_upper, age))
ggplot(data = ndata, aes(x = age)) +
geom_line(aes(y = RR)) +
geom_line(aes(y = RR_lower), color = "steelblue", linetype = "dashed") +
geom_line(aes(y = RR_upper), color = "steelblue", linetype = "dashed") +
scale_y_continuous(name = "Rate Ratio (RR): Fallers vs. Non-Fallers",
limits = c(0, 4), expand = c(0, 0)) +
theme_bw() +
theme(axis.line = element_line(color = ’black’),
axis.title.y = element_text(size = 8),
axis.title.x = element_text(size = 8),
axis.text.y = element_text(size = 8),
axis.text.x = element_text(size = 8),
plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank())
}
# Fixed-effect model
age <- seq(50, 90, 1)
b1 <- fixed_b1$`Overall beta`
v1 <- fixed_b1$`Overall variance`
b2 <- fixed_b2$`Overall beta`
v2 <- fixed_b2$`Overall variance`
r <- fixed_meta_r
p1 <- plot_with_interaction(age, b1, v1, b2, v2, r)
p1
# Random-effect model
b1_rand <- random_b1$`Overall beta`
v1_rand <- random_b1$`Overall variance`
b2_rand <- random_b2$`Overall beta`
v2_rand <- random_b2$`Overall variance`
r_rand <- random_meta_r
p2 <- plot_with_interaction(age, b1_rand, v1_rand, b2_rand, v2_rand, r_rand)
p2
p3 <- ggarrange(p1, p2,
labels = c("Fixed Effect", "Random Effect"),
ncol = 2, nrow = 1)
p3
6. An R Package for Calculating Overall Covariance in Meta-Analysis
To facilitate these calculations, we developed an R package called ’covmeta’, available on GitHub. This package can be installed and used within the R environment. Below is the R code to install the package and calculate the overall covariance using the data in
Table 1:
#install the package
library(devtools)
install_github("enwuliu/covmeta")
library(covmeta)
# Load the dataset
studies <- read.csv(’https://raw.githubusercontent.com/enwuliu/
meta-analysis/main/random_effect_meta_sim.csv’, header = TRUE)
# Function arguments
b1 <- studies$b1 # Beta1 coefficients from the 10 cohorts
v1 <- studies$var_b1 # Variances of Beta1
b2 <- studies$b2 # Beta2 coefficients from the 10 cohorts
v2 <- studies$var_b2 # Variances of Beta2
cov_b1b2 <- studies$cov_b1b2 # Covariance between Beta1 and Beta2
sample_size <- studies$sample_size # Sample sizes
# Calculate the overall main effect, interaction effect, and covariance
# Fixed-effect meta-analysis
cov_meta(b1, v1, b2, v2, cov_b1b2, sample_size, ’fixed’)
# Random-effect meta-analysis
cov_meta(b1, v1, b2, v2, cov_b1b2, sample_size, ’random’)
7. Discussion
This paper proposes a method for calculating overall covariance for regression coefficients in the presence of interactions in a two-stage meta-analysis. The approach utilizes the statistical relationship between the correlation coefficient and variances to estimate the covariance. By conducting separate meta-analyses, the variances and correlation coefficient can be obtained. While statistical software packages provide built-in capabilities for analyzing the overall main effect, interaction effects, and their variances,[
11,
12] no studies have explicitly demonstrated how to merge covariances in meta-analysis in the presence of interactions. We present a transparent and straightforward method to synthesize covariance in meta-analysis.
Detecting interactions is crucial in medical research, as interaction analyses can help determine whether an intervention is more effective for certain individuals.[
13,
14,
15] In a two-stage meta-analysis, interactions between an exposure and covariates can be explored using meta-regression. However, the meta-regression method cannot study patient-level factors[
16] and often suffers from low statistical power.[
17] An alternative is dividing participants into subgroups (e.g., by age) and performing separate meta-analyses for each subgroup. While this avoids synthesizing interactions, it also tends to have low power.[
18]
Another method for investigating covariances in meta-analysis is multivariate meta-analysis, which synthesizes correlated effects. For instance, in hypertension trials, systolic and diastolic blood pressure outcomes can be pooled using this approach.[
19,
20,
21] In multivariate meta-analysis, the first-stage analysis estimates the effects (e.g.,
coefficients) and their covariances, which serve as inputs for the second-stage analysis conducted using mixed-model regression.[
22,
23] However, in this framework, the two correlated variables are treated as outcome variables rather than predictors.
Our method has some limitations. It assumes a linear relationship between the two regression coefficients, which may not always hold.[
24]Additionally, the estimation of the correlation coefficient may be less reliable when the number of included studies is small.[
25]
In conclusion, we have introduced a simple and transparent method for calculating covariance and confidence intervals in meta-analysis when interactions are present.