Load Data

library(metafor)
## Warning: package 'metafor' was built under R version 4.2.3
## Loading required package: Matrix
## Loading required package: metadat
## Warning: package 'metadat' was built under R version 4.2.3
## Loading required package: numDeriv
## 
## Loading the 'metafor' package (version 4.0-0). For an
## introduction to the package please type: help(metafor)
library(meta)
## Warning: package 'meta' was built under R version 4.2.3
## Loading 'meta' package (version 6.2-1).
## Type 'help(meta)' for a brief overview.
## Readers of 'Meta-Analysis with R (Use R!)' should install
## older version of 'meta' package: https://tinyurl.com/dt4y5drs
df <- read.csv("Blended.csv")
View(df)

Perform Q Statics (Research Question 1)

meta <- rma(yi = hedges_g, sei = Standard_Error, data = df)
summary(meta)
## 
## Random-Effects Model (k = 39; tau^2 estimator: REML)
## 
##   logLik  deviance       AIC       BIC      AICc   
## -24.6847   49.3694   53.3694   56.6446   53.7122   
## 
## tau^2 (estimated amount of total heterogeneity): 0.0861 (SE = 0.0330)
## tau (square root of estimated tau^2 value):      0.2934
## I^2 (total heterogeneity / total variability):   68.17%
## H^2 (total variability / sampling variability):  3.14
## 
## Test for Heterogeneity:
## Q(df = 38) = 120.0928, p-val < .0001
## 
## Model Results:
## 
## estimate      se    zval    pval   ci.lb   ci.ub      
##   0.3729  0.0646  5.7736  <.0001  0.2463  0.4995  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Perform a descriptive analysis of effect sizes

# Calculate effect sizes
smd <- df$hedges_g
se <- df$Standard_Error
res <- rma(yi = hedges_g, sei = Standard_Error, data = df)
n <- res$k
min_g <- min(res$yi)
max_g <- max(res$yi)
mean_g <- res$b
se_mean <- res$se
sd_g <- sqrt(res$tau2)
# Create a data frame with the descriptive statistics
descriptive_stats <- data.frame(
  Statistics = c("Number of effect sizes", "Minimum Hedges' g", "Maximum Hedges' g", "Mean Hedges' g", "Standard error of the mean", "Standard deviation"),
  Value = c(n, min_g, max_g, mean_g, se_mean, sd_g)
)

# Print the data frame
descriptive_stats
##                   Statistics       Value
## 1     Number of effect sizes 39.00000000
## 2          Minimum Hedges' g -0.49000000
## 3          Maximum Hedges' g  1.94000000
## 4             Mean Hedges' g  0.37287591
## 5 Standard error of the mean  0.06458318
## 6         Standard deviation  0.29336698

Research Question 1

# Create a data frame with your effect sizes and standard errors
data <- data.frame(hedges_g = df$hedges_g,se = df$Standard_Error)
# Calculate the average effect size
avg_effect_size <- mean(data$hedges_g)

# Calculate the variance of the effect sizes
var_effect_sizes <- sum((data$hedges_g - avg_effect_size)^2) / (nrow(data) - 1)

# Calculate the standard error of the effect sizes
se_effect_sizes <- sqrt(var_effect_sizes / nrow(data))

# Calculate the z-values for each effect size
z_values <- (data$hedges_g - 0) / data$se

# Calculate the p-values for each z-value
p_values <- 2 * (1 - pnorm(abs(z_values)))

# Calculate the 95% confidence interval for the effect sizes
lower_bound <- data$hedges_g - (1.96 * data$se)
upper_bound <- data$hedges_g + (1.96 * data$se)

# Print the results
cat("Average effect size:", avg_effect_size, "
")
## Average effect size: 0.5512821
cat("Variance of effect sizes:", var_effect_sizes, "
")
## Variance of effect sizes: 0.3207904
cat("Standard error of effect sizes:", se_effect_sizes, "
")
## Standard error of effect sizes: 0.09069397
cat("Average z-value of effect sizes:", mean(z_values), "
")
## Average z-value of effect sizes: 1.695974
cat("Avergae p-values of effect sizes:", mean(p_values), "
")
## Avergae p-values of effect sizes: 0.1712179
cat("Average 95% confidence interval lower bound:", mean (lower_bound), "
")
## Average 95% confidence interval lower bound: -0.2658872
cat("Average 95% confidence interval upper bound:", mean(upper_bound), "
")
## Average 95% confidence interval upper bound: 1.368451

Research Question 2

# Calculate the number of effect sizes for each institution type
n <- tapply(df$hedges_g, df$Course_Subject, length)
# Calculate the average effect size for each institution type
mean <- tapply(df$hedges_g, df$Course_Subject, mean)
# Calculate the variance of effect sizes for each institution type
variance <- tapply(df$hedges_g, df$Course_Subject, var)
# Calculate the standard error of effect sizes for each institution type
se <- sqrt(variance / n)

# Calculate the z-values for each institution type
z <- mean / se

# Calculate the p-values for each institution type (two-tailed test)
p <- 2 * (1 - pnorm(abs(z)))

# Calculate the 95% confidence interval lower bound and upper bound for each institution type
ci_lower <- mean - qt(0.975, n-1) * se
ci_upper <- mean + qt(0.975, n-1) * se

# Combine the results into a data frame
results <- data.frame(n =n ,mean = mean, variance = variance, se = se, z = z, p = p, ci_lower = ci_lower, ci_upper = ci_upper)

# Print the results
results
##                 n      mean  variance         se        z            p
## Health Science 17 0.2858824 0.1331132 0.08848836 3.230734 1.234728e-03
## ICT            12 0.4408333 0.1171538 0.09880696 4.461561 8.136460e-06
## Other          10 1.1350000 0.4467167 0.21135673 5.370068 7.870697e-08
##                 ci_lower  ci_upper
## Health Science 0.0982954 0.4734693
## ICT            0.2233607 0.6583060
## Other          0.6568779 1.6131221

Research Question 3

# Calculate the number of effect sizes for each institution type
n <- tapply(df$hedges_g, df$Institution_Type, length)
# Calculate the average effect size for each institution type
mean <- tapply(df$hedges_g, df$Institution_Type, mean)
# Calculate the variance of effect sizes for each institution type
variance <- tapply(df$hedges_g, df$Institution_Type, var)
# Calculate the standard error of effect sizes for each institution type
se <- sqrt(variance / n)

# Calculate the z-values for each institution type
z <- mean / se

# Calculate the p-values for each institution type (two-tailed test)
p <- 2 * (1 - pnorm(abs(z)))

# Calculate the 95% confidence interval lower bound and upper bound for each institution type
ci_lower <- mean - qt(0.975, n-1) * se
ci_upper <- mean + qt(0.975, n-1) * se

# Combine the results into a data frame
results <- data.frame(n = n, mean = mean, variance = variance, se = se, z = z, p = p, ci_lower = ci_lower, ci_upper = ci_upper)

# Print the results
results
##                n      mean  variance         se        z            p  ci_lower
## Graduate       9 1.2266667 0.4080250 0.21292278 5.761087 8.357396e-09 0.7356659
## Undergraduate 30 0.3486667 0.1237568 0.06422792 5.428584 5.680294e-08 0.2173058
##                ci_upper
## Graduate      1.7176675
## Undergraduate 0.4800275

Test for heterogeneity based on institution type

# fit a random-effects model with Institution_Type as the moderator
library(metafor)
model_inst <- rma(yi = hedges_g, sei = Standard_Error, mods = ~ Institution_Type, data = df, method = "REML")
Q_inst <- summary(model_inst)$QE[1]
Q_inst
## [1] 113.3078

Test for heterogeneity based on Course Subject

# fit a random-effects model with Course_Subject_Type as the moderator
model_course <- rma(yi = hedges_g, sei = Standard_Error, mods = ~ Course_Subject, data = df, method = "REML")
Q_inst <- summary(model_course)$QE[1]
Q_inst
## [1] 117.0541