# T tests, ANOVAs and regression Tom Jenkins Ellen Meierotto SPM Methods for Dummies 2007

date post

28-Mar-2015Category

## Documents

view

220download

5

Embed Size (px)

### Transcript of T tests, ANOVAs and regression Tom Jenkins Ellen Meierotto SPM Methods for Dummies 2007

- Slide 1

T tests, ANOVAs and regression Tom Jenkins Ellen Meierotto SPM Methods for Dummies 2007 Slide 2 Why do we need t tests? Slide 3 Objectives Types of error Probability distribution Z scores T tests ANOVAs Slide 4 Slide 5 Error Null hypothesis Type 1 error (): false positive Type 2 error (): false negative Slide 6 Normal distribution Slide 7 Z scores Standardised normal distribution = 0, = 1 Z scores: 0, 1, 1.65, 1.96 Need to know population standard deviation Z=(x-)/ for one point compared to pop. Slide 8 T tests Comparing means 1 sample t 2 sample t Paired t Slide 9 Different sample variances Slide 10 2 sample t tests Pooled standard error of the mean Slide 11 1 sample t test Slide 12 The effect of degrees of freedom on t distribution Slide 13 Paired t tests Slide 14 T tests in SPM: Did the observed signal change occur by chance or is it stat. significant? Recall GLM. Y= X + 1 is an estimate of signal change over time attributable to the condition of interest Set up contrast (c T ) 1 0 for 1 : 1x 1 +0x 2 +0x n /s.d Null hypothesis: c T =0 No significant effect at each voxel for condition 1 Contrast 1 -1 : Is the difference between 2 conditions significantly non-zero? t = c T /sd[c T ] 1 sided Slide 15 Slide 16 ANOVA Variances not means Total variance= model variance + error variance Results in F score- corresponding to a p value F test = Model variance /Error variance Variance Slide 17 Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 Total =Model + (Between groups) Error (Within groups) Partitioning the variance Slide 18 T vs F tests F tests- any differences between multiple groups, interactions Have to determine where differences are post-hoc SPM- T- one tailed (con) SPM- F- two tailed (ess) Slide 19 Slide 20 Conclusions T tests describe how unlikely it is that experimental differences are due to chance Higher the t score, smaller the p value, more unlikely to be due to chance Can compare sample with population or 2 samples, paired or unpaired ANOVA/F tests are similar but use variances instead of means and can be applied to more than 2 groups and other more complex scenarios Slide 21 Acknowledgements MfD slides 2004-2006 Van Belle, Biostatistics Human Brain Function Wikipedia Slide 22 Correlation and Regression Slide 23 Topics Covered: Is there a relationship between x and y? What is the strength of this relationship Pearsons r Can we describe this relationship and use it to predict y from x? Regression Is the relationship we have described statistically significant? F- and t-tests Relevance to SPM GLM Slide 24 Relationship between x and y Correlation describes the strength and direction of a linear relationship between two variables Regression tells you how well a certain independent variable predicts a dependent variable CORRELATION CAUSATION In order to infer causality: manipulate independent variable and observe effect on dependent variable Slide 25 Scattergrams Y X Y X Y X Y YY Positive correlationNegative correlationNo correlation Slide 26 Variance vs. Covariance Do two variables change together? Covariance ~ DX * DY Variance ~ DX * DX Slide 27 Covariance When X and Y : cov (x,y) = pos. When X and Y : cov (x,y) = neg. When no constant relationship: cov (x,y) = 0 Slide 28 Example Covariance What does this number tell us? Slide 29 Example of how covariance value relies on variance High variance data Low variance data Subjectxyx error * y error xyX error * y error 1101100250054539 2818090053524 3616010052511 4 50051500 5414010050491 6212090049484 710250048479 Mean51505150 Sum of x error * y error :7000Sum of x error * y error :28 Covariance:1166.67Covariance:4.67 Slide 30 Pearsons R Covariance does not really tell us anything Solution: standardise this measure Pearsons R: standardise by adding std to equation: Slide 31 Basic assumptions Normal distributions Variances are constant and not zero Independent sampling no autocorrelations No errors in the values of the independent variable All causation in the model is one-way (not necessary mathematically, but essential for prediction) Slide 32 Pearsons R: degree of linear dependence Slide 33 Limitations of r r is actually r = true r of whole population = estimate of r based on data r is very sensitive to extreme values : Slide 34 In the real world r is never 1 or 1 interpretations for correlations in psychological research (Cohen) CorrelationNegativePositive Small-0.29 to -0.1000.10 to 0.29 Medium-0.49 to -0.300.30 to 0.49 Large-1.00 to -0.500.50 to 1.00 Slide 35 Regression Correlation tells you if there is an association between x and y but it doesnt describe the relationship or allow you to predict one variable from the other. To do this we need REGRESSION! Slide 36 Best-fit Line = , predicted value Aim of linear regression is to fit a straight line, = ax + b, to data that gives best prediction of y for any value of x This will be the line that minimises distance between data and fitted line, i.e. the residuals intercept = ax + b = residual error = y i, true value slope Slide 37 Least Squares Regression To find the best line we must minimise the sum of the squares of the residuals (the vertical distances from the data points to our line) Residual () = y - Sum of squares of residuals = (y ) 2 Model line: = ax + b we must find values of a and b that minimise (y ) 2 a = slope, b = intercept Slide 38 Finding b First we find the value of b that gives the min sum of squares b b b Trying different values of b is equivalent to shifting the line up and down the scatter plot Slide 39 Finding a Now we find the value of a that gives the min sum of squares b b b Trying out different values of a is equivalent to changing the slope of the line, while b stays constant Slide 40 Minimising sums of squares Need to minimise (y) 2 = ax + b so need to minimise: (y - ax - b) 2 If we plot the sums of squares for all different values of a and b we get a parabola, because it is a squared term So the min sum of squares is at the bottom of the curve, where the gradient is zero. Values of a and b sums of squares (S) Gradient = 0 min S Slide 41 The maths bit So we can find a and b that give min sum of squares by taking partial derivatives of (y - ax - b) 2 with respect to a and b separately Then we solve these for 0 to give us the values of a and b that give the min sum of squares Slide 42 The solution Doing this gives the following equations for a and b: a = r s y sxsx r = correlation coefficient of x and y s y = standard deviation of y s x = standard deviation of x You can see that: A low correlation coefficient gives a flatter slope (small value of a) Large spread of y, i.e. high standard deviation, results in a steeper slope (high value of a) Large spread of x, i.e. high standard deviation, results in a flatter slope (high value of a) Slide 43 The solution cont. Our model equation is = ax + b This line must pass through the mean so: y = ax + b b = y ax We can put our equation into this giving: b = y ax b = y - r s y sxsx r = correlation coefficient of x and y s y = standard deviation of y s x = standard deviation of x x The smaller the correlation, the closer the intercept is to the mean of y Slide 44 Back to the model We can calculate the regression line for any data, but the important question is: How well does this line fit the data, or how good is it at predicting y from x? Slide 45 How good is our model? Total variance of y: s y 2 = (y y) 2 n - 1 SS y df y = Variance of predicted y values (): Error variance: s 2 = ( y) 2 n - 1 SS pred df = This is the variance explained by our regression model s error 2 = (y ) 2 n - 2 SS er df er = This is the variance of the error between our predicted y values and the actual y values, and thus is the variance in y that is NOT explained by the regression model Slide 46 Total variance = predicted variance + error variance s y 2 = s 2 + s er 2 Conveniently, via some complicated rearranging s 2 = r 2 s y 2 r 2 = s 2 / s y 2 so r 2 is the proportion of the variance in y that is explained by our regression model How good is our model cont. Slide 47 Insert r 2 s y 2 into s y 2 = s 2 + s er 2 and rearrange to get: s er 2 = s y 2 r 2 s y 2 = s y 2 (1 r 2 ) From this we can see that the greater the correlation the smaller the error variance, so the better our prediction Slide 48 Is the model significant? i.e. do we get a significantly better prediction of y from our regression equation than by just predicting the mean? F-statistic: F (df ,df er ) = s2s2 s er 2 =......= r 2 (n - 2) 2 1 r 2 complicated rearranging And it follows that: t (n-2) = r (n - 2) 1 r 2 (because F = t 2) So all we need to know are r and n ! Slide 49 General Linear Model Linear regression is actually a form of the General Linear Model where the parameters are a, the slope of the line, and b, the intercept. y = ax + b + A General Linear Model is just any model that describes the data in terms of a straight line Slide 50 Multiple regression Multiple regression is used to determine the effect of a number of independent variables, x 1, x 2, x 3 etc., on a single dependent variable, y The different x variables are combined in a linear way and each has its own regression coefficient: y = a 1 x 1 + a 2 x 2 +..+ a n x n + b + The a parameters reflect the independent contribution of each independent variable, x, to the value of the dependent variable, y. i.e. the amount of variance in y that is accounted for by each x variable after all the other x variables have been accounted for Slide 51 SPM Linear regression is a GLM that models the effect of one independent variable, x, on ONE dependent variable, y Multiple Regression models the effect of several independent variables, x 1, x 2 etc, on ONE dependent variable, y Both are types of General Linear Model GLM can also allow you to analyse the effects of several independent x variables on several dependent variables, y 1, y

Recommended

*View more*