Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDM calculation fix #223

Closed
anthonysena opened this issue Jan 22, 2024 · 1 comment · Fixed by #224
Closed

SDM calculation fix #223

anthonysena opened this issue Jan 22, 2024 · 1 comment · Fixed by #224
Assignees
Milestone

Comments

@anthonysena
Copy link
Collaborator

          Following up on this based on a question I received. Per https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3472075/, for continuous variables it appears we should divide the SD on line 139:

m <- merge(covariates1, covariates2, all = T)
m$mean1[is.na(m$mean1)] <- 0
m$sd1[is.na(m$sd1)] <- 0
m$mean2[is.na(m$mean2)] <- 0
m$sd2[is.na(m$sd2)] <- 0
m$sd <- sqrt(m$sd1^2 + m$sd2^2)
m$stdDiff <- (m$mean2 - m$mean1) / m$sd
result <- bind_rows(result, m[, c("covariateId", "mean1", "sd1", "mean2", "sd2", "sd", "stdDiff")])

similar to what we are doing for binary covariates here on line 103:

m <- merge(covariates1, covariates2, all = T)
m$count1[is.na(m$count1)] <- 0
m$count2[is.na(m$count2)] <- 0
m$mean1 <- m$count1 / n1
m$mean2 <- m$count2 / n2
m$sd1 <- sqrt(m$mean1 * (1 - m$mean1))
m$sd2 <- sqrt(m$mean2 * (1 - m$mean2))
m$sd <- sqrt((m$sd1^2 + m$sd2^2) / 2)
m$stdDiff <- (m$mean2 - m$mean1) / m$sd
result <- bind_rows(result, m[, c("covariateId", "mean1", "sd1", "mean2", "sd2", "sd", "stdDiff")])

Tagging @schuemie for confirmation. I can then open an issue and get this patched.

Originally posted by @anthonysena in #120 (comment)

@anthonysena anthonysena added this to the V3.4.0 milestone Jan 22, 2024
@ginberg ginberg self-assigned this Jan 23, 2024
@ginberg
Copy link
Collaborator

ginberg commented Jan 23, 2024

@anthonysena thanks for reporting, I will pick this up

@anthonysena anthonysena linked a pull request Feb 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants