Hi Lindsay, actually it should be simpler.
fit <- fastLmPure(X, y, method=2)
resids <- fit$residuals
sigma.squared <- fit$s
cohen <- gamma / sqrt(sigma.squared)
If you have vertex-level statistics, you will have to loop over "y", i.e.,
fits <- apply(y, 2, function(x) fastLmPure(X, x, method=2))
resids <- sapply(fits, with, residuals)
sigma.squared <- sapply(fits, with, s)
gamma <- result$DT[, gamma]
cohen <- sapply(seq_along(gamma), function(x) gamma[x] / sqrt(sigma.squared[x]))
I think that should work if you have a single contrast. If you have
multiple, you can wrap all of the above code in a "for" loop, by
looping over the "contrast" index:
# Each element of "cohen" is for a different contrast
cohen <- vector('list', nrow(result$con.mat))
for (i in seq_along(cohen)) {
...
gamma <- result$DT[contrast == i, gamma]
cohen[[i]] <- gamma / sqrt(sigma.squared)
}
There are "cleaner" ways to do this, but off the top of my head this
should work fine.
Chris