# 2nd level analysis – design matrix, contrasts and inference

## Presentation on theme: "2nd level analysis – design matrix, contrasts and inference"— Presentation transcript:

2nd level analysis – design matrix, contrasts and inference
Deborah Talmi & Sarah White

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

Fixed effects Fixed effect: A variable with fixed values
E.g. levels of an experimental variable. Random effect: A variable with values that can vary. E.g. the effect ‘list order’ with lists that are randomized per subject The effect ‘Subject’ can be described as either fixed or random Subjects in the sample are fixed Subjects are drawn randomly from the population Typically treated as a random effect in behavioural analysis

Fixed effects analysis
Experimental conditions The factor ‘subject’ treated like other experimental variable in the design matrix. Within-subject variability across condition onsets represented across rows. Between-subject variability ignored Case-studies approach: Fixed-effects analysis can only describe the specific sample but does not allow generalization. Constants Regressors Covariates S1 S2 S3 S4 S5

Random effects analysis
Generalization to the population requires taking between-subject variability into account. The question: Would a new subject drawn from this population show any significant activity? Mixed models: the experimental factors are fixed but the ‘subject’ factor is random. Mixed models take into account both within- and between- subject variability.

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

Relationship between 1st & 2nd levels
1st-level analysis: Fit the model for each subject using different GLMs for each subject. Typically, one design matrix per subject Define the effect of interest for each subject with a contrast vector. The contrast vector produces a contrast image containing the contrast of the parameter estimates at each voxel. 2nd-level analysis: Feed the contrast images into a GLM that implements a statistical test.

1st level X values Convolved with HRF Convolution with the HRF changes the onsets we enter (1,0) to a gradient of values X values are then ordered on the x-axis to predict BOLD data on the Y axis.

1st level parameter estimate
Y=data ŷ = ax + b slope (beta) intercept = ŷ, predicted value = y i , true value The values on the X axis correspond to values in the design matrix (effects related to peristimulus time). The intercept is the constant term, unless the regressor is mean-corrected. If the regressor is mean-corrected, the constant term represents average activation. ε = residual error Mean activation

Contrasts = combination of beta values
Vowel - baseline Vowel - baseline Tone - baseline 1 1 Vowel =23.356 .con =23.356 Vowel beta =23.356 Tone beta2 = .con =8.9309 Contrasts can represent the beta value of a single regressors, or a combination of beta values: typically, the difference between two regressors (e.g. experimental task>control task).

Vowel - baseline Tone - baseline Vowel - Tone Contrast images for the two classes of stimuli vs. baseline and vs. each other (linear combination of all relevant betas)

Difference from behavioral analysis
The ‘1st level analysis’ typical to behavioural data is relatively simple: A single number: categorical or frequency A summary statistic, resulting from a simple model of the data, typically the mean. SPM 1st level is an extra step in the analysis, which models the response of one subject. The statistic generated (β) then taken forward to the GLM. This is possible because βs are normally distributed. A series of 3-D matrices (β values, error terms) A single number: categorical or frequency Whether the subject reports pain or not; the number of times the subject reported feeling pain A summary statistic, resulting from a simple model of the data, typically the mean: The mean reaction time in a classification task.

Similarities between 1st & 2nd levels
Both use the GLM model/tests and a similar SPM machinery Both produce design matrices. The columns in the design matrices represent explanatory variables: 1st level: All conditions within the experimental design 2nd level: The specific effects of interest The rows represent observations: 1st level: Time (condition onsets); within-subject variability 2nd level: subjects; between-subject variability

Similarities between 1st & 2nd levels
The same tests can be used in both levels (but the questions are different) .Con images: output at 1st level, both input and output at 2nd level There is typically only 1 1st-level design matrix per subject, but multiple 2nd level design matrices for the group – one for each statistical test.

Multiple 2nd level analyses
1-sample t-tests: Vowel vs. baseline [1 0] Tone vs. baseline [0 1] Vowel > Tone [1 -1] Vowel or tone >baseline [1 1] Vowel Tone

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test Masking Covariates 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

1-Sample t-test Enter 1 .con image per subject
All subjects weighted equally – all modeled with a ‘1’

2nd level design matrix for 1-sample t-test
The question: is mean activation significantly greater than zero? Y = data (parameter estimates) ŷ = 1*x +β 0 Because all subjects are modeled with only one value (=1), the slope is 0. This GLM model cannot be entered as a linear regression in SPSS. Instead, the SPM t-statistic corresponds to a 1-sample t-test on the beta values. This test asks whether the intercept is significantly greater than 0. Values from the design matrix 1

Estimation and results
The T statistic of a simple 1-sample t-test, without covariates, corresponds to the t statistic of a 1-sample t-test on the beta values (per subject, per voxel). In SPSS, this value can be reproduced with a 1-sample t-test and cannot be analyzed with a regression model.

1-Sample t-test figures
These data (e.g. beta values) are available in the workspace – useful to create more complex figures

Statistical inference: imaging vs. behavioural data
Inference of imaging data uses some of the same statistical tests as used for analysis of behavioral data: t-tests, ANOVA The effect of covariates for the study of individual-differences Some tests are more typical in imaging: Conjunction analysis Multiple comparisons poses a greater problem in imaging

Masking Implicit mask: the default, excluding voxels with ‘NaN’ or ‘0’ values Threshold masking: Images are thresholded at a given value and only voxels at which all images exceed the threshold Explicit mask: only user-defined voxels are included in the analysis

A sensible option here is to use a segmentation of structural images to specify a within-brain mask. Explicit masks are other images containing (implicit) masks that are to be applied to the current analysis. Single subject mask Group mask ROI mask

Covariates in 1-Sample t-test
An additional regressor in the design matrix specifying subject-specific information (e.g. age). Nuisance covariates, covariate of interest: Included in the model in the same way. Nuisance: Contrast [1 0] focuses on mean, partialing out activation due to a variable of no interest Covariate of interest: contrast [0 1] focuses on the covariate. The parameter estimate represents the magnitude of correlation between task-specific activations and the subject-specific measure. It is easier to see the 1-sample t-test as a simple GLM model when covariates are included. SPM T statistics can be reproduced in SPSS by entering the covariates as predictors and the beta values as the dependent variable in a regression model. The T statistic for the covariates is tabulated as the T statistic for coefficients. The T statistic for the mean activation is the T statistic for the constant term.

Covariate options Entering single number per subject.
Centering: the vector will be mean- corrected The appropriate centering option is usually the one that corresponds to the interaction chosen, and ensures that main effects of the interacting factor aren’t affected by the covariate. More info on centering by condition:

Covariate results Parameter estimate
Slope: Parameter estimate of 2nd level covariate Mean activation Covariate Centred covariate mean

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

Factorial design First…back to first level analysis
1 2 3 A2 4 5 6 First…back to first level analysis here, 2 factors with 2/3 levels making 6 conditions For each subject we could create a number of effects of interest, eg. each condition separately each level separately contrast between levels within a factor interaction between factors [1,1,1,-1,-1,-1,0] [1,0,0,0,0,0,0] [1,1,1,0,0,0,0] [1,-1,0,-1,1,0,0]

Paired t-tests This is when we start being interested in contrasts at 2nd level Within group between subject variance is greater than within subject variance better use of time to have more subjects for shorter scanning slots than vice versa

B1 B2 B3 Paired t-tests A1 1 2 3 A2 4 5 6 This is when we start being interested in contrasts at 2nd level Within group whether, across subjects, one effect of interest (A1) is significantly greater than another effect of interest (A2) contrast vector [1,-1] one-tailed / directional asks specific Q, eg. is A1>A2? You could equally do this same analysis by creating the contrast at the 1st level analysis and then running a one-sample t-test at the 2nd level A A2

B1 B2 B3 Factorial design A1 1 2 3 A2 4 5 6 This is when we start being interested in contrasts at 2nd level Within group whether, across subjects, one effect of interest (A1) is significantly greater than another effect of interest (A2) contrast vector [1,1,1,-1,-1,-1] one-tailed / directional asks specific Q, eg. is A1>A2?

Factorial design Conjunction analysis Simple example within group
B1 B2 B3 Factorial design A1 1 2 3 A2 4 5 6 Conjunction analysis Simple example within group whether, across subjects, those voxels significantly activated in one contrast are also significantly activated in another eg. whether the difference between A1 and A2 is significant across all three conditions B1, B2 and B3 contrast vector ??? [1,1,1,-1,-1, -1] given [1,0,0,-1,0,0] & [0,1,0,0,-1,0] and [0,0,1,0,0,-1] basically testing whether there is a main effect in the absence of an interaction

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

Two sample t-tests This is a contrast again Between groups
but can’t be done at the 1st level of analysis this time Between groups both groups must have same design matrix

Two sample t-tests This is a contrast again Between groups
1 2 3 A2 4 5 6 This is a contrast again but can’t be done at the 1st level Between groups whether, across conditions, the difference between two groups of subjects (M & F) is significant one-tailed / directional asks specific Q, eg. is M>F? contrast vector [1,-1] Unlike the paired samples t-test, there’s no other way to do this analysis as you haven’t been able to collapse data across subjects before B1 B2 B3 A1 1 2 3 A2 4 5 6 M F

Factorial design This is a contrast again Between groups
1 2 3 A2 4 5 6 This is a contrast again but can’t be done at the 1st level Between groups whether, across conditions, the difference between two groups of subjects (M & F) is significant one-tailed / directional asks specific Q, eg. is M>F? contrast vector [1,1,1,1,1,1,-1,-1,-1 ,-1 ,-1 ,-1] B1 B2 B3 A1 1 2 3 A2 4 5 6 M F

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: F-tests Multiple comparisons

F-tests This is for multiple contrasts Within and between groups
1 2 3 A2 4 5 6 This is for multiple contrasts Within and between groups whether, across conditions and/or subjects, a number of different contrasts are significant gives differences in both directions (+ve & -ve) equivalent to lots of 2-tailed t-test asks general question: A1 ≠ A2 contrast vector for main effect of A: [1,-1,0,0] [0,0,1,-1] B1 B2 B3 A1 1 2 3 A2 4 5 6 M F A1 A2 A1 A2

F-tests This is for multiple contrasts Within and between groups M F
1 2 3 A2 4 5 6 This is for multiple contrasts Within and between groups whether, across conditions and/or subjects, a number of different contrasts are significant gives differences in both directions (+ve & -ve) equivalent to lots of 2-tailed t-test asks general question: A1 ≠ A2 contrast vector for main effect of A: [1,0,0,-1,0,0,0,0,0,0,0,0] [0,1,0,0,-1,0,0,0,0,0,0,0] [0,0,1,0,0,-1,0,0,0,0,0,0] [0,0,0,0,0,0,1,0,0,-1,0,0] [0,0,0,0,0,0,0,1,0,0,-1,0] [0,0,0,0,0,0,0,0,1,0,0,-1] B1 B2 B3 A1 1 2 3 A2 4 5 6 M F

F-tests This is for multiple contrasts Within and between groups M F
1 2 3 A2 4 5 6 This is for multiple contrasts Within and between groups whether, across conditions and/or subjects, a number of different contrasts are significant gives differences in both directions (+ve & -ve) equivalent to lots of 2-tailed t-test asks general question: M ≠ F contrast vector for main effect of sex: [1,0,0,1,0,0,0,0,0,0,0,0] [0,1,0,0,1,0,0,0,0,0,0,0] [0,0,1,0,0,1,0,0,0,0,0,0] [0,0,0,0,0,0,-1,0,0,-1,0,0] [0,0,0,0,0,0,0,-1,0,0,-1,0] [0,0,0,0,0,0,0,0,-1,0,0,-1] B1 B2 B3 A1 1 2 3 A2 4 5 6 M F

F-tests This is for multiple contrasts Within and between groups M F
1 2 3 A2 4 5 6 This is for multiple contrasts Within and between groups whether, across conditions and/or subjects, a number of different contrasts are significant gives differences in both directions (+ve & -ve) equivalent to lots of 2-tailed t-test asks general question: M(A1-A2) ≠ F(A1-A2) contrast vector for interaction between A and sex: [1,0,0,-1,0,0,0,0,0,0,0,0] [0,1,0,0,-1,0,0,0,0,0,0,0] [0,0,1,0,0,-1,0,0,0,0,0,0] [0,0,0,0,0,0,-1,0,0,1,0,0] [0,0,0,0,0,0,0,-1,0,0,1,0] [0,0,0,0,0,0,0,0,-1,0,0,1] B1 B2 B3 A1 1 2 3 A2 4 5 6 M F

Overview Fixed, random, and mixed models
From 1st to 2nd level analysis 2nd level analysis: 1-sample t-test 2nd level analysis: Paired t-test 2nd level analysis: 2-sample t-test 2nd level analysis: ANOVA Multiple comparisons

Multiple comparisons we’re still doing these comparisons for each voxel involved in the analysis (even though we’ve collapsed across time) -> lots of comparisons also multiple contrasts problem of false positives correction for multiple comparisons cf talk on random field theory

References Previous MFD presentations
SPM5 Manual, The FIL Methods Group (2007) Poline, Kherif, Pallier & Penny, Chapter 9, Statistical Parametric Mapping (2007) Penny & Holmes, Chapter 12, Human Brain function (2nd edition)