Effect size

43 views
Skip to first unread message

y li

unread,
Oct 21, 2020, 3:57:11 AM10/21/20
to brainGraph-help
Hi Chris,
Could you please show me the code for calculating effect size in brainGraph 3.0.0?

Best,
Li

Chris Watson

unread,
Oct 21, 2020, 11:08:17 AM10/21/20
to brainGr...@googlegroups.com
Your question needs to be more specific. Effect size of what? Which kind of
effect size? There are more than one.

Chris

On Wed, Oct 21, 2020 at 02:57 AM, y li <flys...@126.com> wrote:

> from: y li <flys...@126.com>
> date: Wed, Oct 21 12:57 AM -07:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: [brainGraph-help] Effect size
> --
> You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-he...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/dc797d56-bef9-4036-938d-fb59b373f339n%40googlegroups.com.

y li

unread,
Oct 21, 2020, 8:27:05 PM10/21/20
to brainGraph-help

Hi Chris,
I mean Effect Size for brainGraph_GLM and MTPC Outputs. Thank you!

Li

Chris Watson

unread,
Oct 21, 2020, 9:07:23 PM10/21/20
to brainGr...@googlegroups.com
There are still different definitions of "effect size".

For "brainGraph_GLM", the effect size of the contrast can be seen by the
summary output in the tables, or by the return object's "DT" element.

For "mtpc", I suppose the effect sizes could be "S.mtpc" or "A.mtpc", also in
the "DT" element of the return object.

Please read the User Guide and the papers underlying these methods for more.

On Wed, Oct 21, 2020 at 07:27 PM, y li <flys...@126.com> wrote:

> from: y li <flys...@126.com>
> date: Wed, Oct 21 05:27 PM -07:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] Effect size
> To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/a699178f-19c5-4381-8b3f-830363b26a50n%40googlegroups.com.

y li

unread,
Oct 22, 2020, 8:45:19 PM10/22/20
to brainGraph-help
Hi Chris,
In brainGraph 2.7.3, I can calculate the effect size(ES) for brainGraph_GLM outputs using following command lines that you have provided in the google forum (https://groups.google.com/g/braingraph-help/c/14LpH16XkAY/m/cKBTptKoAAAJ):
 # Calculate Effect Size #
cohen <- vector('list', nrow(results_glm$con.mat)) 
subdata<- function(x){
 graph_attr(x)[[measures[1]]]
}
y<-sapply(g.glm, subdata)
fit <- RcppEigen::fastLmPure(X, y, method=2) 
for (i in seq_along(cohen)) { 
  resids <- fit$residuals 
  sigma.squared <- fit$s 
  gamma <- results_glm$DT[contrast == i, gamma]
  cohen[[i]] <- gamma / sqrt(sigma.squared) 
}

# Calculate Vertex effect size
cohen <- NULL  
subdata<- function(x){
  vertex_attr(x)[[measures[i]]]
}
y<-t(sapply(g.glm, subdata))
fit <- apply(y, 2, function(x) RcppEigen::fastLmPure(X, x, method=2)) 
for (j in seq(nrow(results_glm$con.mat))) { 
  resids <- sapply(fit,with, residuals)
  sigma.squared <- sapply(fit,with,s) 
  gamma <- results_glm$DT[contrast == j,gamma]
  cohen <- c(cohen, gamma / sqrt(sigma.squared))   #cohen[[j]] <- gamma / sqrt(sigma.squared) 
}
results_glm$DT[,cohen:=cohen]

Since brainGraph has been updated to v3.0.1, these command lines should be changed appropriately. 
Could you please help me revise the above command lines ?

Another question: In brainGraph 3.0.1,  it seems that "g.glm" has been replaced by "g[[i]]" for brainGraph_GLM which was not specified in the new userguide. Am I right?

Chris Watson

unread,
Oct 22, 2020, 10:57:11 PM10/22/20
to brainGr...@googlegroups.com
Hi Li, so you are interested in Cohen's d then? Be aware that this effect size
is specifically for mean differences. I cannot guarantee that the code I give is
the "proper" code for calculating Cohen's d for a contrast; I do not even know
if Cohen's d is the correct effect size measure for contrasts. You should ask a
statistician if it is appropriate.

For the graph-level, it should be as simple as the following:

cohen <- results_glm$DT[, gamma] / sigma(results_glm)
names(cohen) <- results_glm$con.name

For the vertex-level, it should be the following:

cohen <- matrix(0, nregions(results_glm), length(results_glm$con.name),
dimnames=list(region.names(results_glm), results_glm$con.name))
for (i in results_glm$con.name) {
cohen[, i] <- results_glm$DT[Contrast == i, gamma] / sigma(results_glm)
}

Also be aware that, according to Wikipedia, there are "50 to 100" measures of effect
size, so you should be sure that you are using the one appropriate for your analysis.
Chris

Regarding your final question, I am not sure what you mean. "g.glm" is just a
variable name for the "brainGraphList" object containing the graphs (at the
specific threshold) for which I wanted to run a GLM analysis. You should just
use the variable names specific to your code; it is not necessary to follow the
User Guide exactly if you choose to have different variable names. It may be the
case that "g[[1]]" (or "g[[2]]", etc.) is the object of interest for you.

On Thu, Oct 22, 2020 at 07:45 PM, y li <flys...@126.com> wrote:

> from: y li <flys...@126.com>
> date: Thu, Oct 22 05:45 PM -07:00 2020
> To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/5d683efc-9ee8-4322-a031-a52b7c4bcd61n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages