JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for SPM Archives


SPM Archives

SPM Archives


SPM@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  October 2015

SPM October 2015

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: flexible factorial ANOVA model and contrast

From:

"H. Nebl" <[log in to unmask]>

Reply-To:

H. Nebl

Date:

Mon, 19 Oct 2015 16:58:55 +0100

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (50 lines) , d1.png (50 lines) , d2.png (50 lines) , d3.png (50 lines) , d4.png (50 lines) , mspec_d4.m (225 lines)

Dear Ping, 

Concerning the attached design matrix, this is because you have set variance to unequal, which affects the covariance structure and the design matrix. For factor "subject" variance should be set to equal (at least this is the assumption for the other repeated measurement designs in SPM, namely the "Paired t-test" and the "One-way ANOVA - within subject").

Concerning the other study/model, first of all, given the two levels for each of the factors means you could set up all the relevant contrasts on single-subject level and forward each of the con images into a separate one-sample t-tests which facilitates the issue to a large extent. This would correspond to results from an ANOVA with partitioned error terms.

Your current design matrix only includes columns for main effects and two-way interactions. If you explicitely don't want to add a term for the three-way interaction to the model this is alright, but if it's due to the limitations within the GUI then I would suggest to rely on the latest SPM12 version. Thanks to Guillaume Flandin r6470 onward allows three-way interactions (and higher). For that purpose download r6470, enable the option by altering spm_cfg_factorial_design.m in spm12\config folder, instead of fnums.num = [2 1]; (line 579) it must read fnums.num = [Inf 1]; Within the SPM GUI you can now specify three-way interactions by adding an "Interaction" defined as e.g. [1 2 3].

In general, for a model with three within-subject (and terms for two-way and three-way interactions) you would need e.g.
- one column coding a constant term
- one column coding the difference between A1 and A2
- one column coding the difference between B1 and B2
- one column coding the difference between C1 and C2
- one column coding the interaction A x B
- one column coding the interaction A x C
- one column coding the interaction B x C
- one column coding the interaction A x B x C
... thus 8 columns for the experimental factors/interactions. 

I guess this is also what the statistician had in mind who Donald talked to ("main effects should be in the model"). However, there are other ways to set up equivalent design matrices (think of effect vs. dummy coding). The options are limited within the SPM GUI though. 

With SPM's Flexible factorial (which relies on a single, pooled error term) you obtain overdetermined design matrices when including both main effects and interactions. This is because you don't get something like 
- one column coding a constant term
- one column coding the difference between A1 and A2
- one column coding the difference between B1 and B2
- one column coding the difference between C1 and C2
- one column coding the interaction A x B
- one column coding the interaction A x C
- one column coding the interaction B x C
but rather, the included interactions are implemented as a series of columns that code the different factor level combinations, e.g. for the two-way interaction A x B you get four (dummy coding) columns A1B1, A1B2, A2B1, A2B2. Based on these columns you could already test for A1-A2 or B1-B2. Thus, the terms "interaction" and "main effect" within the GUI are misleading. Adding "only" e.g. the interaction A x B does not mean your model only has the interaction term, but rather, the interaction term but also two terms for the corresponding main effects. More generally, adding the highest-order interaction will result in a series of columns (that usually correspond to the "conditions" from the single-subject models) which automatically allow to test for all lower-order interactions and main effects. In contrast, lower order interactions don't allow to test for higher order interactions.

In your current design matrix (as in attached d1) some of the columns are linear dependent. The first two columns are linear dependent anyway (could be collapsed into a single column with ones and minus ones). But e.g. the first column (coding A1) is also the sum of the columns A1B1 and A1B2, or the sum of A1C1 and A1C2. This is accounted for during model specification/estimation, thus in the plotted design matrix, "leaving x degrees of freedom from y images" corresponds to the "correct" loss of df and not the no. of (redundant) columns. The statistical solution for overdetermined models like that is explained in http://www.fil.ion.ucl.ac.uk/spm/doc/books/hbf2/pdfs/Ch7.pdf on page 6f.

In any case, and as it usually facilitates setting up the contrast vectors, you could leave out the three main effects (losing the first six columns) right from the beginning & just include the three two-way interactions. When testing for A1 vs. A2 results are identical to the model in which main effects were explicitely included via the GUI (see attached d2 and d1 for comparison). 

Now, consider the suggested model with a term for the three-way interaction (see attached batch, as stated, you'll need r6470 plus the manual adjustment). Adding the three-way interaction to the design (via e.g. [1 2 3]) plus a main effect for subjects (e.g. [4]) will result in eight columns A1B1C1 A1B1C2 A1B2C1 A1B2C2 A2B1C1 A2B1C2 A2B2C1 A2B2C2 plus those for the Subjects Sub1 Sub2 ... (as in d4). This is sufficient. Correct contrast vectors would be (please double-check yourself):
Main effect A: 1/4 1/4 1/4 1/4 -1/4 -1/4 -1/4 -1/4 ...
Main effect B: 1/4 1/4 -1/4 -1/4 1/4 1/4 -1/4 -1/4 ...
Main effect C: 1/4 -1/4 1/4 -1/4 1/4 -1/4 1/4 -1/4 ...
Interaction A x B: 1/2 1/2 -1/2 -1/2 -1/2 -1/2 1/2 1/2 ...
Interaction A x C: 1/2 -1/2 1/2 -1/2 -1/2 1/2 -1/2 1/2 ...
Interaction B x C: 1/2 -1/2 -1/2 1/2 1/2 -1/2 -1/2 1/2 ...
Three-way A x B x C: 1 -1 -1 1 -1 1 1 -1 ...
Again, results are identical to the model with three main effects (plus main effect subject), three two-way interactions, the three-way interaction (see d3 vs. d4).

Hope this helps

Helmut



%----------------------------------------------------------------------- % Job saved on ...1 by cfg_util (rev $Rev: 6460 $) % spm SPM - SPM12 (6470) % cfg_basicio BasicIO - Unknown %----------------------------------------------------------------------- matlabbatch{1}.spm.stats.factorial_design.dir = {'C:\Data\...\test'}; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(1).name = 'A'; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(1).dept = 1; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(1).variance = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(1).gmsca = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(1).ancova = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(2).name = 'B'; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(2).dept = 1; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(2).variance = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(2).gmsca = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(2).ancova = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(3).name = 'C'; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(3).dept = 1; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(3).variance = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(3).gmsca = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(3).ancova = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(4).name = 'Subject'; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(4).dept = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(4).variance = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(4).gmsca = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fac(4).ancova = 0; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(1).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1' % A1B1C1                                                                                   'C:\Data\...\beta_0004.nii,1' % A1B1C2                                                                                   'C:\Data\...\beta_0007.nii,1' % A1B2C1                                                                                   'C:\Data\...\beta_0010.nii,1' % A1B2C2                                                                                   'C:\Data\...\beta_0002.nii,1' % A2B1C1                                                                                   'C:\Data\...\beta_0005.nii,1' % A2B1C2                                                                                   'C:\Data\...\beta_0008.nii,1' % A2B2C1                                                                                   'C:\Data\...\beta_0011.nii,1' % A2B2C2                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(1).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(2).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(2).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(3).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(3).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(4).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(4).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(5).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(5).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(6).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(6).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(7).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(7).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(8).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(8).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(9).scans = {                                                                                   'C:\Data\...\beta_0001.nii,1'                                                                                   'C:\Data\...\beta_0004.nii,1'                                                                                   'C:\Data\...\beta_0007.nii,1'                                                                                   'C:\Data\...\beta_0010.nii,1'                                                                                   'C:\Data\...\beta_0002.nii,1'                                                                                   'C:\Data\...\beta_0005.nii,1'                                                                                   'C:\Data\...\beta_0008.nii,1'                                                                                   'C:\Data\...\beta_0011.nii,1'                                                                                   }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(9).conds = [1 1 1                                                                                   1 1 2                                                                                   1 2 1                                                                                   1 2 2                                                                                   2 1 1                                                                                   2 1 2                                                                                   2 2 1                                                                                   2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(10).scans = {                                                                                    'C:\Data\...\beta_0001.nii,1'                                                                                    'C:\Data\...\beta_0004.nii,1'                                                                                    'C:\Data\...\beta_0007.nii,1'                                                                                    'C:\Data\...\beta_0010.nii,1'                                                                                    'C:\Data\...\beta_0002.nii,1'                                                                                    'C:\Data\...\beta_0005.nii,1'                                                                                    'C:\Data\...\beta_0008.nii,1'                                                                                    'C:\Data\...\beta_0011.nii,1'                                                                                    }; matlabbatch{1}.spm.stats.factorial_design.des.fblock.fsuball.fsubject(10).conds = [1 1 1                                                                                    1 1 2                                                                                    1 2 1                                                                                    1 2 2                                                                                    2 1 1                                                                                    2 1 2                                                                                    2 2 1                                                                                    2 2 2]; matlabbatch{1}.spm.stats.factorial_design.des.fblock.maininters{1}.fmain.fnum = 4; matlabbatch{1}.spm.stats.factorial_design.des.fblock.maininters{2}.inter.fnums = [1                                                                                   2                                                                                   3]; matlabbatch{1}.spm.stats.factorial_design.cov = struct('c', {}, 'cname', {}, 'iCFI', {}, 'iCC', {}); matlabbatch{1}.spm.stats.factorial_design.multi_cov = struct('files', {}, 'iCFI', {}, 'iCC', {}); matlabbatch{1}.spm.stats.factorial_design.masking.tm.tm_none = 1; matlabbatch{1}.spm.stats.factorial_design.masking.im = 1; matlabbatch{1}.spm.stats.factorial_design.masking.em = {''}; matlabbatch{1}.spm.stats.factorial_design.globalc.g_omit = 1; matlabbatch{1}.spm.stats.factorial_design.globalm.gmsca.gmsca_no = 1; matlabbatch{1}.spm.stats.factorial_design.globalm.glonorm = 1; matlabbatch{2}.spm.stats.fmri_est.spmmat(1) = cfg_dep('Factorial design specification: SPM.mat File', substruct('.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}), substruct('.','spmmat')); matlabbatch{2}.spm.stats.fmri_est.write_residuals = 0; matlabbatch{2}.spm.stats.fmri_est.method.Classical = 1;

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager