Welcome back to Principles of fMRI. In this module, we're going to introduce the general linear model, which is the bread and butter work horse of statistical analysis. In this module and the following series, we'll walk you through how to construct the GLM and how to use it for fMRI. So there are multiple goals in the analysis of fMRI data. And they include localizing areas activated by a task or in relation to a process of interest, determining networks corresponding to brain function, functional connectivity, and effective connectivity, and making predictions about psychological or disease states or other outcomes from functional imaging data. All of these can be handled in certain ways in the general linear modeling framework. So in terms of situating us in where we are in the whole process, we are here in the data analysis portion. And to give you a little bit more detailed view and an overview of the GLM analysis process, it's typically a two level hierarchical analysis, and we analyze within subject effects, individual by individual case, that's the first level, and secondly we do analysis across subjects or across groups in a group analysis or a second level analysis. We can do this in stages and that's one approach, a common approach. Also hierarchical models combine both those levels into one integrated model. So where we are in the processing stream and the steps are first, design specification, or building a model. Secondly, that model is combined with real data and estimated, and effects are estimated at each voxel. And contrast images are calculated, we'll talk more about those later, those are combined with images from other subjects into a group analysis. And then finally, we can make inferences about the areas that are activated in that group and localize them anatomically, talk about them. So let's first introduce the GLM family of tests. The general linear model approach treats the data as a linear combination of model functions, predictors, plus noise, or error. So you can think of it as breaking the data up into the part that I can explain with the model, and the part that I can't explain. These model functions are assumed to have known shapes, the simplest one being a straight line. But their amplitudes, or their slopes are unknown and those are what need to be estimated when I fit the model. I'm not limited to straight lines, I can also fit smooth, pre-specified curves or other functions, and we'll look at more examples of that later on. The GLM encompasses many techniques that affirm our data analysis, and also data analysis more generally, so chances are you've used some version of this in your research before. Let's look now at the entire GLM family. While many of you might be familiar with simple regression, one outcome, one predictor, or with ANOVA, an analysis of multiple categories, and those are both instances of the general linear model, so they fit with the broad GLM framework. And in fact, they're instances of another subclass of the general linear model multiple regression, which is a case where you have one outcome and multiple predictors. And in fact, any analysis that I can do in a ANOVA framework, I can do that exact same ANOVA analysis in regression, multiple regression, framework. So those are actually interchangeable at a mechanistic level. They're all examples of the GLM. And more broadly, in multiple regression is an instance or class of instances of the general linear model more broadly. And that encompasses models like mixed effects and the hierarchical models, timeseries models with autoregressive complements to them, and other advanced tweaks, like robust models, penalized regression models. Many of you have heard of LASSO or Ridge. Those kinds of things. And finally, there's this broad category of generalized linear models, where I can incorporate ideas non-normal errors, different error distributions, and logistic regression is one example of that. So all of these are different instances of the general linear model. In many cases there is a simple close form algebraic solution so I can solve the equations, an estimate that model in one step and many other cases require iterative solutions so I have to alternate between estimating the mile per minute and estimating the air structure for example. So this is the simplest example, simple linear regression, one predictor, one outcome. And for our purposes here, we'll just talk about four stages that we go through. One is we specify the model. In this case, it's very simple. We posit that there is a linear relationship between the predictor and the outcome. That's the model, the simplification of this complex data into a compact form. Then we estimate the model. In this case, this means that we have to estimate the slope and the intercept of that model, or where it crosses the y axis. Third, is the statistical inference. I'd like to cast the significance of that slope and get a P value, which relates to how likely is it that I've observed a slope like this under the null hypothesis that there is no actual true relationship. That the line is actually flat. And finally, when I find significant effects I want to make a scientific interpretation, which has to do with the meaning of this relationship. So this is another view of the GLM family, I think it's a useful to situate us. All the GLM models are characterized by the use of one variable, which is a continuous variable as the dependent variable of the outcome. So one continuous DV, and depending on what the structure of the predictors are, then one is doing different kinds of tests. All GLM tests, all with the same fundamental linear algebraic equations. So, if I have one continuous predictors, that's simple regression. If I have two continuous predictors, that's multiple regression. Let's say I have a categorical predictor with two levels, male or female. And that's what I'm using to break the outcome, that ends up being a two sample t-test. If you have a categorical predictor with three or more levels, basketball players, football players, baseball players, and then the outcome might be memories, core performance, that's a one way ANOVA. If I have two or more categorical predictors, arranged in factors, that's a factorial ANOVA. And we'll look at examples of that later as we go on. Another important extension of the GLM is the case where we have multiple observations on the same people, or repeated measures. So all of these in blue here are repeated measures designs and they involve essentially then correlations in the error structure, so fight has to one person at time one, time two, time three, that's repeated measures. And because I have multiple observations on the same people, then those observations are linked by the person. They're no longer independent from all the other observations. Or, sorry, from one another, I should say. So that's repeated measures design and if you have a within-person predictor, one within-person predictor, that's a paired T test, time one, time two, two levels. If you have multiple repeated measures, time one, time two, time three, time four, we're doing a one way repeated measures ANOVA. We can also use MANOVA to analyze such data. If I have four more repeated measures organized in a factor structure. For example, I might have a memory experiment where I have words that are highly image-able or not, and they're presented in visual or auditory modality, that's a two by two factorial design, and that's a factorial repeated measures ANOVA design. That's very common in functional neuroimaging experiments. And if I have repeated measures, the same with a repeated measure structure, but now I start to add between person predictors, like a moderation of that effect correlation with age or with performance, or with group status, patient versus control, then we'll just call that a GLM. And this illustrates that I can mix and match with in-person and between-person factors and variables, and all within the same analysis framework. Another important extension is this idea of introducing other kinds of correlated error structures. So one example is that time series correlations. Events that occur at one time point depend on what happens at time points before that. A quintessential example is the stock market. Things happen in the stock market and influence multiple time points. So each measurement across time is not independent from each other one. And we can use the generalized lead squares framework with iterative models to model that kind of structure. This is the basic structural model for the GLM. And we'll first break it down and then show it in one compact equation. So up on top here, what you see is, y is the dependent variable throughout the course, and x is going to refer to predictors. And here I've got time point i, so we've got the outcome at time point i, is broken down into beta not, which is an intercept parameter that captures the average across time, constant across time, plus beta one, times vector one, plus beta two, times vector two, plus beta three and so on for as many predictors as I have in the model. Those beta's are regression slopes. When I estimate them they become beta hats, we always use hat for an estimate. So this breaks down the model into the part that I can explain with the model. Some combination of beta values are slopes times the predictors plus errors. The residuals are everything left over. And the job then, when I estimate the GLM is to solve for that beta vector the series of beta naught, beta one, beta two, beta three. I do that typically by minimizing the sum of squared residuals, although there are other options as well. Now what you see on the bottom here is if I write that same equation sort of messy equation in matrix form, I get one very compact, beautiful equation. Y = X time beta plus error. And let's take a closer look at this and break this down again. So, Y = X beta plus error. That's decomposed into Y is a column of observed data, and that's modeled in terms of a design matrix, which is the intercept plus all the other predictors. And the intercept is usually a constant value, in this case it's just a column of ones, plus a column for each predictor or regressor in the model together. That's X, times beta, beta is a vector of the model parameters all the regression slopes in the model plus error, all the residuals, or everything left over. So here's a non-fMRI example, and later, we'll map this onto the fMRI context. So in this non-fMRI example, I'm interest in whether exercise predicts life-span. So the outcome, this is made up data, [LAUGH] the outcome is going to be life-span, a predictor is going to be exercise intensity level, or amount, which is a continuous variable and we'll introduce one other variable which may or may not be important here. Let's say it's a covariate. And this is going to be gender, male or female. And so now I've got two predictors in my model. Let's look at how this works. Well first, let's look at the data. This is an example of what the data might look like. Exercise is a predictor on the x-axis, and lifespan is to outcome on the y axis. And now I've got the group of females and the group of males. I can see that females and males are different. And that categorical variable is going to be an additional predictor. So I can look at the effect of exercise controlling for gender, gender controlling for exercise. And let's look at how this works in terms of our design matrix and outcome. So the outcome data is the life span which is continuous variable distributed across the series of observations. In this case observations are subjects, so this is what the life-span data might look like. And that's decomposed into the part that I can model with the design matrix, and there's the design matrix itself. There's the intercept, which is a constant, effect of exercise is continuous, and now sex is included as a categorical variable. Because there are two levels, I can code that in regression with values of one and negative one, for example, maybe one for female, negative one for male, or vice versa. And that looks like that as a predictor and that design matrix is going to be multiplied by the model parameters, which I estimate when I fit the model, plus the error residuals, everything left over. So this example illustrates how I can do a rather complex design very simply using the general linear model. And this design would be called an ANCOVA, analysis of covariance design in the traditional behavior literature. So, that's the end of this module. In the next module we'll begin to map GLM onto fMRI data specifically.