Dear Jie,
if you want to perform this test in order to decide which non-sphericity
assumptions to use with a two-sample t-test, you should maybe just go
ahead and assume unequal variance - but statisticians monitoring this
list might want to comment further. See also comments here:
http://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#statug_glm_a0000000869.htm
That said, if you want to compute a two-sample F-test for equal
variances, as in MATLAB's vartest2, for all voxels in your data, you can
use the following code:
V1 = spm_select(Inf,'image','Group 1');
V2 = spm_select(Inf,'image','Group 2');
SPM.xY.VY = strvcat(V1,V2);
SPM.VM = []; % or specify a mask image here
searchopt = struct('def','sphere','spec',0);
vartest2 = @(Y,XYZ,n1) var(Y(1:n1)) / var(Y(n1+1:end));
spm_searchlight(SPM,searchopt,vartest2,size(V1,1));
It will create an image weirdly called searchlight_0001.nii containing
an F-statistic at every voxel, with degrees of freedom
[size(V1,1)-1,size(V2,1)-1], testing the hypothesis that the subjects'
data for the two groups come from a Gaussian distribution with the same
variance. You could easily define other tests by providing a different
function handle to the spm_searchlight function.
Best regards,
Guillaume.
On 03/03/15 16:50, Jie Yu wrote:
> Dear Expert
>
> So I'd like to know if there is any significant difference between variances within 2 groups.
> (each group has its own variance, I'd like to do a statistical test to see if they are the same)
>
> I know SPM automatically perform this, but is there any script to test this? so that I can see the result?
>
> Thanks so much!
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|