Closed martinig closed 11 months ago
Use formula 3 and 5 in this paper - you can write your own function 1471-2288-14-135.pdf
@itchyshin Can you look over these functions and let me know if they are correct?
Convert median and min/max value to mean and SD:
#function to convert median and min/max value to mean and SD
calculate_mean_sd <- function(n, med, min, max) {
mean_val <- (2 * med + (max + min)) / 4
sd_val <- (max - min) / 4
return(list(mean = mean_val, sd = sd_val))
}
#calculation
n <- 32
med <- 2356
min_val <- 190
max_val <- 19913
result <- calculate_mean_sd(n, med, min_val, max_val)
cat("Mean:", result$mean, "\n")
cat("Standard Deviation:", result$sd, "\n")
#output: Mean: 6203.75 and Standard Deviation: 4930.75
Convert median and IQR to mean and SD:
# function for getting mean and sd from median, IQR, and sample size
mean_sd_from_iqr <- function(n, med, iqr) {
mean_val <- med
sd_val <- iqr / (2 * qnorm(0.75))
return(list(mean = mean_val, sd = sd_val))
}
# estimation:
n <- 78
med <- 28
iqr <- 20.5
result <- mean_sd_from_iqr(n, med, iqr)
cat("Mean:", result$mean, "\n")
cat("Standard Deviation:", result$sd, "\n")
#output Mean: 28, Standard Deviation: 15.19667
can you presents what it calcuates please - also what formula are you basing this on - send me the formula and then I can check - I do not know these off the top of my head (i.e., more info required)
@itchyshin I added the output above.
I tried to use the formulas in the PDF you linked above, but I found it was taking me hours to understand. I ended up using stackoverflow. I'll try to find the original posts!