Skip to content

Instantly share code, notes, and snippets.

@sTeamTraen
Created February 7, 2022 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sTeamTraen/3a38aecd91bcce74005b6b341b206786 to your computer and use it in GitHub Desktop.
Save sTeamTraen/3a38aecd91bcce74005b6b341b206786 to your computer and use it in GitHub Desktop.
Analysis of pooled effects across 17 symptoms (excluding anosmia) in eTable7 of Matta et al., 10.1001/jamainternmed.2021.6454
# Matta et al., 10.1001/jamainternmed.2021.6454
# See Altman, 2011, 10.1136/bmj.d2304 for calculation of z-scores
# See https://en.wikipedia.org/wiki/Fisher%27s_method#Relation_to_Stouffer's_Z-score_method for Stouffer's method
eTable7 <- data.frame(name="", N=0, OR.m6=0.0, CIlo.m6=0.00, CIhi.m6=0.00, OR.m7=0, CIlo.m7=0.00, CIhi.m7=0.00)
eTable7 <- rbind(eTable7, c("Sleep problems", 54, 0.76, 0.42, 1.36, 0.92, 0.51, 1.67))
eTable7 <- rbind(eTable7, c("Joint pain", 35, 1.38, 0.69, 2.73, 1.40, 0.64, 3.03))
eTable7 <- rbind(eTable7, c("Back pain", 38, 1.58, 0.80, 3.09, 1.24, 0.60, 2.55))
eTable7 <- rbind(eTable7, c("Digestive track problems", 29, 0.61, 0.27, 1.35, 1.16, 0.50, 2.49))
eTable7 <- rbind(eTable7, c("Muscular pain/sore muscles", 27, 1.05, 0.48, 2.29, 1.40, 0.58, 3.38))
eTable7 <- rbind(eTable7, c("Fatigue", 82, 1.17, 0.73, 1.88, 1.43, 0.85, 2.39))
eTable7 <- rbind(eTable7, c("Poor attention or concentration", 53, 1.45, 0.82, 2.57, 1.73, 0.89, 3.34))
eTable7 <- rbind(eTable7, c("Skin problems", 14, 0.61, 0.20, 1.91, 0.87, 0.28, 2.65))
eTable7 <- rbind(eTable7, c("Other symptoms", 26, 1.44, 0.65, 3.18, 1.47, 0.60, 3.56))
eTable7 <- rbind(eTable7, c("Sensory symptoms", 12, 0.21, 0.04, 1.01, 0.65, 0.20, 2.08))
eTable7 <- rbind(eTable7, c("Hearing impairment", 9, 3.99, 0.82, 19.45, 1.03, 0.25, 4.22))
eTable7 <- rbind(eTable7, c("Headache", 18, 1.18, 0.45, 3.12, 1.32, 0.46, 3.79))
eTable7 <- rbind(eTable7, c("Breathing difficulties", 44, 0.85, 0.45, 1.59, 1.41, 0.71, 2.80))
eTable7 <- rbind(eTable7, c("Palpitations", 18, 0.95, 0.38, 2.37, 1.06, 0.39, 2.87))
eTable7 <- rbind(eTable7, c("Dizziness", 11, 1.37, 0.41, 4.58, 2.18, 0.46, 10.35))
eTable7 <- rbind(eTable7, c("Chest pain", 25, 1.16, 0.50, 2.67, 1.15, 0.48, 2.73))
eTable7 <- rbind(eTable7, c("Cough", 14, 0.89, 0.29, 2.70, 1.73, 0.47, 6.31))
eTable7 <- rbind(eTable7, c("Anosmia", 61, 2.99, 1.59, 5.60, 4.29, 1.92, 9.58))
eTable7 <- eTable7[-1,]
for (col in 2:ncol(eTable7)) {
eTable7[[col]] <- as.numeric(eTable7[[col]])
}
eTable7$z.m6 <- 0.00 # collect the Z-scores in the table for debugging purposes
eTable7$z.m7 <- 0.00
for (model in 6:7) {
v.OR <- paste0("OR.m", model)
v.CIlo <- paste0("CIlo.m", model)
v.CIhi <- paste0("CIhi.m", model)
v.z <- paste0("z.m", model)
z.total <- 0.00
z.items <- 0
z.total.wt <- 0.00
z.items.wt <- 0
for (rn in 1:nrow(eTable7)) {
row <- eTable7[rn,]
OR <- log(row[[v.OR]])
CIlo <- log(row[[v.CIlo]])
CIhi <- log(row[[v.CIhi]])
N <- row$N
SE <- (CIhi - CIlo) / (2 * 1.96)
z <- OR / SE
eTable7[[rn, v.z]] <- z
if (row$name != "Anosmia") {
z.total <- z.total + z
z.items <- z.items + 1
z.total.wt <- z.total.wt + (z * N)
z.items.wt <- z.items.wt + (N ^ 2)
}
}
stouffer.Z <- z.total / sqrt(z.items)
stouffer.p <- 1 - pnorm(stouffer.Z)
stouffer.Z.wt <- z.total.wt / sqrt(z.items.wt)
stouffer.p.wt <- 1 - pnorm(stouffer.Z.wt)
cat("Model ", model
, ": total z=", sprintf("%.3f", z.total)
, " Stouffer: (Unweighted) Z=", sprintf("%.3f", stouffer.Z)
, ", p=", sprintf("%.3f", stouffer.p)
, " (Weighted) Z=", sprintf("%.3f", stouffer.Z.wt)
, ", p=", sprintf("%.3f", stouffer.p.wt)
, "\n", sep="")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment