Dear Jeroen,
Thanks for the feedback. Remember you can always quickly review your
batch structure in the editor by typing:
>> spm_jobman('interactive',matlabbatch);
Concerning your last question, adding 'main effect' of A and B does not
add anything to your design because you also include 'everything up to
interaction' AxB. It's the same design (you should check that degrees of
freedom don't change) but it makes your life harder to specify contrasts
because of multicollinearity. Contrasts can be obtained with:
>> spm_make_contrasts([2 3])
Finally, the choice between options 1 and 3 corresponds to pooled vs
partitioned errors, see relevant section in Rik's paper for pros and
cons of both approaches:
http://www.mrc-cbu.cam.ac.uk/wp-content/uploads/2015/03/Henson_EN_15_ANOVA.pdf
Best regards,
Guillaume.
On 24/01/18 15:18, Baar, J.M. van (Jeroen) wrote:
> Hi Guillaume,
>
> Thanks for your quick response.
>
> First with respect to ‘independence’: SPM asks for ‘independence’ in the batch editor – those options are YES for subject factor and NO elsewhere. When writing my batch script, though, the struct field is called ‘dept’ and the corresponding values are 0 for subject factor and 1 elsewhere. So that matches :)
>
> When studying the batch editor vs my scripts in more detail, I noticed that when the option ‘variance’ is set to EQUAL in the batch editor gui, the corresponding struct field ‘variance’ in my batch script should be 0, not 1. I had expected this to be the opposite (i.e. 1 for EQUAL variance), but this actually makes sense given that this field is about inequality of variance, and the order of the two in the batch editor is equal first (0), then unequal (1)).
>
> This is where my error was.
>
> After fixing the equality of variance setting and removing the two main effects of factors A and B, the model came out just fine, and was estimated in a matter of seconds. Interestingly, SPM12 seems to automatically re-sort the contrast maps such that the factor that changes slowest is entered first. Whatever order I enter my factor conditions in, the design matrix contains them in the order [1,1;1,2;1,3;1,4;2,1;2,2;2,3;2,4], as you specified.
>
> Even when leaving the two main effects for the two factors in the design matrix, everything runs fine. So the misspecification of the equality of variance seems to be the only error (had put UNEQUAL instead of EQUAL everywhere by mistake). This explains why my batch crashed during the estimation of non-sphericity. If you would like to reproduce this error, let me know in a personal message and I’ll be happy to send you the contrast maps – although you might be able to reproduce it on your own if you set all variances on a similar design to unequal :)
>
> Now for my last question. If I want to test both the main effects and their interaction, is it better to:
> 1) use the partitioned errors approach as described in the wiki you mention,
> 2) build a flexible factorial with main effects subject [1], A [2], B [3] and interaction [2,3], and test each of them individually, or
> 3) build a flexible factorial model with a main effect for subject [1] and the interaction for AxB [2,3], as we have done so far in this thread, and use F-contrasts [1 1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 1 1] to get the main effect for A and [1 -1 0 0 1 -1 0 0; 0 1 -1 0 0 1 -1 0; 0 0 1 -1 0 0 1 -1] to get the main effect for B? The interaction contrast then becomes [1 -1 0 0 -1 1 0 0; 0 1 -1 0 0 -1 1 0; 0 0 1 -1 0 0 -1 1; -1 1 0 0 1 -1 0 0; 0 -1 1 0 0 1 -1 0; 0 0 -1 1 0 0 1 -1] if I’m not mistaken...
>
> Thanks again for helping me out so quickly!
>
> Best,
>
> Jeroen
>
> ________________________________________
> Van: Guillaume Flandin [[log in to unmask]]
> Verzonden: woensdag 24 januari 2018 12:06
> Aan: Baar, J.M. van (Jeroen)
> CC: [log in to unmask]
> Onderwerp: Re: [SPM] 2-way repeated-measures ANOVA
>
> Dear Jeroen,
>
> I think you should specify your second level model in a different way
> but its estimation should nevertheless not crash the way it did so it
> would be great if you could share your contrast images so that I can
> reproduce the error.
>
> That said, there are several issues with this model:
> * don't include 'main effect' of factors A and B, only 'main effect' of
> subject [1] and 'interaction' AxB [2 3].
> * the order of factors is defined such that the one that changes slowest
> is entered first so maybe enter the contrast images in the order A1B1
> A1B2 A1B3 A1B4 A2B1 A2B2 A2B3 A2B4, and for the conditions matrix, use
> [1 1;1 2;1 3;1 4;2 1;2 2;2 3;2 4].
> * just to make sure we are talking about the same thing, SPM asks for
> "Independence" in the non-sphericity options so you would enter the
> opposite of what you wrote down for "dependent".
>
> There is a wiki entry giving some examples of how to specify second
> level models:
> https://en.wikibooks.org/wiki/SPM/Group_Analysis
> I would recommend you use the approach described there (partitioned
> errors) where you will specify a different model for each question (main
> effects, interaction). Doing so, you will not have to use a flexible
> factorial design.
>
> Best regards,
> Guillaume.
>
>
> On 24/01/18 07:12, Jeroen van Baar wrote:
>> Dear SPM experts,
>>
>> Your advice would be appreciated on the following. I’m running into some trouble with a 2-way repeated-measures ANOVA in SPM12. I have 48 subjects and 2 within-subjects factors, factor A with 2 levels and factor B with 4 levels. I have created 8 contrast maps per subject at first level, each of which represents one of the 2x4 unique factor combinations. This means I have 8*48 = 384 scans as data in my GLM.
>>
>> I’ve specified a flexible factorial 2nd-level GLM as follows:
>> - Factor 1: name ‘A’, dependent YES, variance EQUAL
>> - Factor 2: name ‘B’, dependent YES, variance EQUAL
>> - Factor 3: name ‘subject’, dependent NO, variance EQUAL
>> - Each subject is added separately, with:
>> o Scans: the 8 contrast maps in order A1B1-A2B1-A1B2-etc
>> o Conds: [1,1;2,1;1,2;2,2;1,3;2,3;1,4;2,4]
>> - Main effect for factor 1 (A): 1
>> - Main effect for factor 2 (B): 2
>> - Main effect for factor 3 (subject): 3
>> - Interaction effect for factors 1 and 2: [1,2]
>> When I attempt to estimate this model, SPM crashes after about 5 or 6 steps of the ReML estimation algorithm. Error message: ‘The requested tolerance is too high.’ Find the entire error stack below.
>>
>> I’ve searched this mailing list and consulted the very helpful tutorial by Glaescher & Gitelman (2008) (http://www.sbirc.ed.ac.uk/cyril/download/contrast_weighting_glascher_gitelman_2008.pdf), but can’t figure out what I did wrong. I played around with the order of the factors, putting ‘subject’ first (G&G mention this), flipping the order of factors A and B, etc, but SPM still crashed.
>>
>> The error message makes me think that I could solve the problem by raising the tolerance of the GLM estimation algorithm somehow, but I’m not sure if that would violate any good practice, and I wouldn’t know how to go about it either.
>>
>> Did I specify my model correctly? Have you encountered this error before, what might it mean, and how can I solve it?
>>
>> Thank you very much.
>>
>> Best regards,
>>
>> Jeroen van Baar
>> PhD student @ Donders Institute, Nijmegen, The Netherlands
>>
>> ========================================================================
>>
>> SPM12: spm_est_non_sphericity (v6913) 16:21:57 - 23/01/2018
>> ========================================================================
>> Chunk 1/1 : ...done
>> Temporal non-sphericity (9079 voxels) : ...ReML estimation
>> ReML Iteration 1 : ...4.053974e+02 [+4.25]
>> ReML Iteration 1 : ...4.052294e+02 [+4.75]
>> ReML Iteration 1 : ...4.049247e+02 [+5.25]
>> ReML Iteration 1 : ...4.043815e+02 [+5.75]
>> ReML Iteration 1 : ...4.032816e+02 [+6.25]
>> ReML Iteration 1 : ...4.010746e+02 [+6.75]
>> ReML Iteration 1 : ...3.968957e+02 [+7.25]
>> Failed 'Model estimation'
>> Error using spm_dx>expv (line 279)
>> The requested tolerance is too high.
>> In file "/home/common/matlab/spm12/spm_dx.m" (v7144), function "expv" at line 279.
>> In file "/home/common/matlab/spm12/spm_dx.m" (v7144), function "spm_dx" at line 102.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 145.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 160.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 160.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 160.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 160.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 160.
>> In file "/home/common/matlab/spm12/spm_reml.m" (v7178), function "spm_reml" at line 160.
>> In file "/home/common/matlab/spm12/spm_est_non_sphericity.m" (v6913), function "spm_est_non_sphericity" at line 281.
>> In file "/home/common/matlab/spm12/spm_spm.m" (v7120), function "spm_spm" at line 433.
>> In file "/home/common/matlab/spm12_r6470_20150506/config/spm_run_fmri_est.m" (v7057), function "spm_run_fmri_est" at line 34.
>>
>> The following modules did not run:
>> Failed: Model estimation
>>
>> Error using MATLABbatch system
>>
>
> --
> Guillaume Flandin, PhD
> Wellcome Trust Centre for Neuroimaging
> University College London
> 12 Queen Square
> London WC1N 3BG
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|