Voici une fonction R suggérée qui calcule le g de Hedges (la version non biaisée du d de Cohen) ainsi que son intervalle de confiance pour la conception entre les sujets ou à l'intérieur des sujets:
gethedgesg <-function( x1, x2, design = "between", coverage = 0.95) {
# mandatory arguments are x1 and x2, both a vector of data
require(psych) # for the functions SD and harmonic.mean.
# store the columns in a dataframe: more convenient to handle one variable than two
X <- data.frame(x1,x2)
# get basic descriptive statistics
ns <- lengths(X)
mns <- colMeans(X)
sds <- SD(X)
# get pairwise statistics
ntilde <- harmonic.mean(ns)
dmn <- abs(mns[2]-mns[1])
sdp <- sqrt( (ns[1]-1) *sds[1]^2 + (ns[2]-1)*sds[2]^2) / sqrt(ns[1]+ns[2]-2)
# compute biased Cohen's d (equation 1)
cohend <- dmn / sdp
# compute unbiased Hedges' g (equations 2a and 3)
eta <- ns[1] + ns[2] - 2
J <- gamma(eta/2) / (sqrt(eta/2) * gamma((eta-1)/2) )
hedgesg <- cohend * J
# compute noncentrality parameter (equation 5a or 5b depending on the design)
lambda <- if(design == "between") {
hedgesg * sqrt( ntilde/2)
} else {
r <- cor(X)[1,2]
hedgesg * sqrt( ntilde/(2 * (1-r)) )
}
# confidence interval of the hedges g (equations 6 and 7)
tlow <- qt(1/2 - coverage/2, df = eta, ncp = lambda )
thig <- qt(1/2 + coverage/2, df = eta, ncp = lambda )
dlow <- tlow / lambda * hedgesg
dhig <- thig / lambda * hedgesg
# all done! display the results
cat("Hedges'g = ", hedgesg, "\n", coverage*100, "% CI = [", dlow, dhig, "]\n")
}
Voici comment il pourrait être utilisé:
x1 <- c(53, 68, 66, 69, 83, 91)
x2 <- c(49, 60, 67, 75, 78, 89)
# using the defaults: between design and 95% coverage
gethedgesg(x1, x2)
# changing the defaults explicitely
gethedgesg(x1, x2, design = "within", coverage = 0.90 )
J'espère que ça aide.