Outline. Analysis of Variance. Comparison of 2 or more groups. Acknowledgements. Comparison of serveral groups

Similar documents
Outline. Analysis of Variance. Acknowledgements. Comparison of 2 or more groups. Comparison of serveral groups

Analysis of variance. April 16, 2009

Analysis of variance and regression. April 17, Contents Comparison of several groups One-way ANOVA. Two-way ANOVA Interaction Model checking

Analysis of variance. April 16, Contents Comparison of several groups

Analysis of Variance

Parametrisations, splines

Analysis of variance and regression. November 22, 2007

unadjusted model for baseline cholesterol 22:31 Monday, April 19,

Multi-factor analysis of variance

Statistics for exp. medical researchers Comparison of groups, T-tests and ANOVA

6. Multiple regression - PROC GLM

SAS Commands. General Plan. Output. Construct scatterplot / interaction plot. Run full model

Outline. Topic 20 - Diagnostics and Remedies. Residuals. Overview. Diagnostics Plots Residual checks Formal Tests. STAT Fall 2013

ANALYSIS OF VARIANCE OF BALANCED DAIRY SCIENCE DATA USING SAS

Lecture 3. Experiments with a Single Factor: ANOVA Montgomery 3-1 through 3-3

Introduction to Design and Analysis of Experiments with the SAS System (Stat 7010 Lecture Notes)

Lecture 3. Experiments with a Single Factor: ANOVA Montgomery 3.1 through 3.3

Topic 23: Diagnostics and Remedies

T-test: means of Spock's judge versus all other judges 1 12:10 Wednesday, January 5, judge1 N Mean Std Dev Std Err Minimum Maximum

Answer Keys to Homework#10

Assignment 9 Answer Keys

Correlated data. Introduction. We expect students to... Aim of the course. Faculty of Health Sciences. NFA, May 19, 2014.

Comparison of a Population Means

Week 7.1--IES 612-STA STA doc

SAS Procedures Inference about the Line ffl model statement in proc reg has many options ffl To construct confidence intervals use alpha=, clm, cli, c

Lecture 4. Checking Model Adequacy

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model

Overview. Prerequisites

Biological Applications of ANOVA - Examples and Readings

The General Linear Model. April 22, 2008

The General Linear Model. November 20, 2007

BE640 Intermediate Biostatistics 2. Regression and Correlation. Simple Linear Regression Software: SAS. Emergency Calls to the New York Auto Club

171:162 Design and Analysis of Biomedical Studies, Summer 2011 Exam #3, July 16th

Chapter 16. Nonparametric Tests

22s:152 Applied Linear Regression. Chapter 8: 1-Way Analysis of Variance (ANOVA) 2-Way Analysis of Variance (ANOVA)

Answer to exercise 'height vs. age' (Juul)

Single Factor Experiments

Topic 20: Single Factor Analysis of Variance

4.8 Alternate Analysis as a Oneway ANOVA

This is a Randomized Block Design (RBD) with a single factor treatment arrangement (2 levels) which are fixed.

Regression models. Categorical covariate, Quantitative outcome. Examples of categorical covariates. Group characteristics. Faculty of Health Sciences

1) Answer the following questions as true (T) or false (F) by circling the appropriate letter.

Chapter 8 (More on Assumptions for the Simple Linear Regression)

Odor attraction CRD Page 1

Outline. Topic 19 - Inference. The Cell Means Model. Estimates. Inference for Means Differences in cell means Contrasts. STAT Fall 2013

Linear Combinations of Group Means

N J SS W /df W N - 1

Lecture notes on Regression & SAS example demonstration

Chapter 11. Analysis of Variance (One-Way)

Topic 28: Unequal Replication in Two-Way ANOVA

dm'log;clear;output;clear'; options ps=512 ls=99 nocenter nodate nonumber nolabel FORMCHAR=" = -/\<>*"; ODS LISTING;

One-way ANOVA Model Assumptions

Analysis of Covariance

Linear models Analysis of Covariance

Chapter 12. Analysis of variance

Linear models Analysis of Covariance

An Analysis of College Algebra Exam Scores December 14, James D Jones Math Section 01

Two-factor studies. STAT 525 Chapter 19 and 20. Professor Olga Vitek

Statistics for exp. medical researchers Regression and Correlation

Variance component models part I

EXST7015: Estimating tree weights from other morphometric variables Raw data print

General Linear Model (Chapter 4)

Introduction to Crossover Trials

22s:152 Applied Linear Regression. 1-way ANOVA visual:

Handout 1: Predicting GPA from SAT

Biostatistics Quantitative Data

Outline Topic 21 - Two Factor ANOVA

WITHIN-PARTICIPANT EXPERIMENTAL DESIGNS

Least Squares Analyses of Variance and Covariance

Topic 29: Three-Way ANOVA

22s:152 Applied Linear Regression. Take random samples from each of m populations.

Analysis of variance and regression. December 4, 2007

STATISTICS 479 Exam II (100 points)

Outline. Topic 22 - Interaction in Two Factor ANOVA. Interaction Not Significant. General Plan

PLS205!! Lab 9!! March 6, Topic 13: Covariance Analysis

22s:152 Applied Linear Regression. There are a couple commonly used models for a one-way ANOVA with m groups. Chapter 8: ANOVA

5.3 Three-Stage Nested Design Example

ANOVA Situation The F Statistic Multiple Comparisons. 1-Way ANOVA MATH 143. Department of Mathematics and Statistics Calvin College

COMPREHENSIVE WRITTEN EXAMINATION, PAPER III FRIDAY AUGUST 26, 2005, 9:00 A.M. 1:00 P.M. STATISTICS 174 QUESTION

Descriptions of post-hoc tests

1 Tomato yield example.

Correlation and Simple Linear Regression

One-Way ANOVA. Some examples of when ANOVA would be appropriate include:

STA2601. Tutorial letter 203/2/2017. Applied Statistics II. Semester 2. Department of Statistics STA2601/203/2/2017. Solutions to Assignment 03

Correlation. Bivariate normal densities with ρ 0. Two-dimensional / bivariate normal density with correlation 0

Topic 13. Analysis of Covariance (ANCOVA) [ST&D chapter 17] 13.1 Introduction Review of regression concepts

One-Way ANOVA Source Table J - 1 SS B / J - 1 MS B /MS W. Pairwise Post-Hoc Comparisons of Means

data proc sort proc corr run proc reg run proc glm run proc glm run proc glm run proc reg CONMAIN CONINT run proc reg DUMMAIN DUMINT run proc reg

One-Way Analysis of Variance (ANOVA) There are two key differences regarding the explanatory variable X.

Varians- og regressionsanalyse

STAT 705 Chapter 19: Two-way ANOVA

Analysis of variance (ANOVA) Comparing the means of more than two groups

Data are sometimes not compatible with the assumptions of parametric statistical tests (i.e. t-test, regression, ANOVA)

K. Model Diagnostics. residuals ˆɛ ij = Y ij ˆµ i N = Y ij Ȳ i semi-studentized residuals ω ij = ˆɛ ij. studentized deleted residuals ɛ ij =

PLS205 Lab 6 February 13, Laboratory Topic 9

PLS205 Lab 2 January 15, Laboratory Topic 3

a = 4 levels of treatment A = Poison b = 3 levels of treatment B = Pretreatment n = 4 replicates for each treatment combination

df=degrees of freedom = n - 1

Dr. Junchao Xia Center of Biophysics and Computational Biology. Fall /8/2016 1/38

1-Way ANOVA MATH 143. Spring Department of Mathematics and Statistics Calvin College

Transcription:

Outline Analysis of Variance Analysis of variance and regression course http://staff.pubhealth.ku.dk/~jufo/varianceregressionf2011.html Comparison of serveral groups Model checking Marc Andersen, mja@statgroup.dk Two-way ANOVA Analysis of variance and regression for health researchers, April 28, 2011 Interaction Advanced designs 1 / 69 2 / 69 Acknowledgements Comparison of 2 or more groups written by Lene Theil Skovgaard 1 2006, 2007 updated by Julie Lyng Forman 1 2008, November 2009 updated by Marc Andersen 2 April 2009, April 2010, November 2010, April 2011 number different same of groups individuals individual 2 unpaired paired t-test t-test 2 oneway twoway analysis of variance analysis of variance 1 Dept. of Biostatistics 2 StatGroup 3 / 69 4 / 69

One-way analysis of variance Example: ventilation during anaesthesia Data: 22 bypass-patients randomised to 3 different kinds of ventilation during anaesthesia Outcome: measurement of red cell folate (µg/l) Do the distributions differ between the groups? Do the levels differ between the groups? Group I Group II Group III 50% N 2 O, 50% O 2 for 24 hours 50% N 2 O, 50% O 2 during operation 30 50% O 2 (no N 2 O) for 24 hours Gr.I Gr.II Gr.III n 8 9 5 Mean 316.6 256.4 278.0 SD 58.7 37.1 33.8 5 / 69 6 / 69 Example: ventilation during anaesthesia One-way ANOVA Red cell folate ( g/l) 400 350 300 250 200 I II III Group One-way because we only have one critera for classification of the observations, here ventilation method ANalysis Of VAriance because we compare the variance between groups with the variance within groups 7 / 69 8 / 69

The one-way ANOVA model Hypothesis testing Notation The j th observation from group i is described by: Y ij = µ i + ε ij j th observation mean individual in group no. i group i deviation i.e. as consisting of mean of the group plus an individual deviation, with ε ij N(0, σ 2 ) or equivalently Y ij N(µ i, σ 2 ). Assumptions Observations are assumed be independent and to follow a normal distribution with mean µ i withing group i with the same variance. Model assumptions should be investigated! Investigate difference between groups Null hypothesis: group means are equal, H 0 : µ i = µ Alternative hypothesis: group means are not equal We conclude that the means are not equal when we reject the null hypothesis of equality (ref DGA, 8.5 Hypothesis Testing) 9 / 69 10 / 69 ANOVA math: Sums of squares Decomposition of deviation from grand mean y ij ȳ = (y ij ȳ i ) + (ȳ i ȳ ) Decomposition of variation (sums of squares) (y ij ȳ ) 2 = (y ij ȳ i ) 2 i,j i,j }{{}}{{} total variation within groups + i,j (ȳ i ȳ ) 2 }{{} between groups Decomposition of variation total = between + within F-test statistic SS total = SS between + SS within (n 1) = (k 1) + (n k) F = MS between = SS between/(k 1) MS within SS within /(N k) y ij ȳ i ȳ. j th observation in i th group average in i th group overall average, or grand mean Hypothesis test Reject the null hypothesis if F is large, i.e. if the variation between groups is too large compared to the variation within groups. 11 / 69 12 / 69

Analysis of variance table Analysis of variance table - Anaestesia example ANOVA table ANOVA table Variation df SS MS F P Between k 1 SS b SS b /df b MS b /MS w P(F(df b, df w ) > F obs ) Within n k SS w SS w /df w Total n 1 SS tot F test statistics The F test statistics follows and F-distribution with df b and df w degrees of freedom: F obs F (df b, df w ). df SS MS F P Between 2 15515.77 7757.9 3.71 0.04 Within 19 39716.09 2090.3 Total 21 55231.86 F test statistics F = 3.71 F (2, 19) P = 0.04 Interpretation Weak evidence of non-equality of the three means 13 / 69 14 / 69 Analysis of variance in SAS To define the anaestesia data in SAS, we write data ex_redcell; input grp redcell; cards; 1 243 1 251 1 275...... 3 293 3 328 ; The variable redcell contains all the measurements of the outcome and grp contains the method of ventilation for each individual. Descriptive statistics proc tabulate data=ex_redcell missing; title "Table of means and standard deviation and standard error"; class grp; var redcell; table redcell*(n*f=f5.0 mean*f=f5.1 std*f=f5.1), grp; title; ------------------------------------------ Group ----------------- I II III ----------------------+-----+-----+----- Red cell N 8 9 5 folate -----------+-----+-----+----- Mean 316.6 256.4 278.0 -----------+-----+-----+----- Std 58.7 37.1 33.8 ------------------------------------------ 15 / 69 16 / 69

Analysis of variance program Parameter estimates proc glm data=ex_redcell; class grp; model redcell=grp / solution; General Linear Models Procedure Dependent Variable: REDCELL Sum of Mean Source DF Squares Square F Value Pr > F Model 2 15515.7664 7757.8832 3.71 0.0436 Error 19 39716.0972 2090.3209 Corrected Total 21 55231.8636 R-Square C.V. Root MSE REDCELL Mean 0.280921 16.14252 45.7200 283.227 Source DF Type I SS Mean Square F Value Pr > F GRP 2 15515.7664 7757.8832 3.71 0.0436 Source DF Type III SS Mean Square F Value Pr > F GRP 2 15515.7664 7757.8832 3.71 0.0436 The option solution outputs parameter estimates T for H0: Pr > T Std Error of Parameter Estimate Parameter=0 Estimate INTERCEPT 278.0000000 B 13.60 0.0001 20.44661784 GRP 1 38.6250000 B 1.48 0.1548 26.06442584 2-21.5555556 B -0.85 0.4085 25.50141290 3 0.0000000 B... NOTE: The X X matrix has been found to be singular and a generalized inverse was used to solve the normal equations. Estimates followed by the letter B are biased, and are not unique estimators of the parameters. Group 3 (the last group) is the reference group The estimates for the other groups refer to differences to this reference group 17 / 69 18 / 69 Parameter estimates with confidence intervals PROC glm box plot The ods output statement stores parameter estimates proc glm data=ex_redcell; class grp; ods output ParameterEstimates=ParamEstim; model redcell=grp / noint solution CLPARM; proc print data=paramestim; Lower Upper Parameter Estimate CL CL grp I 316.63 282.79 350.46 grp II 256.44 224.55 288.34 grp III 278.00 235.20 320.80 19 / 69 20 / 69

Interpreting the estimates Multiple comparisons What is the scientific question Clinical significance Statistical significance Provide confidence interval Does it make sense? The F -test show, that there is a difference but where? Pairwise t-tests are not suitable due to risk of mass significance A significance level of α = 0.05 means 5% chance of wrongfully rejecting a true hypothesis (type I error) The chance of at least one type I error goes up with the number of tests. (for k groups, we have m = k(k 1)/2 possible tests, the actual significance level can be as bad as: 1 (1 α) m, e.g. for k=5: 0.40) 21 / 69 22 / 69 Adressing multiplicity Tukey: multiple comparisons in SAS There is no completely satisfactory solution. Approximative solutions 1. Select a (small) number of relevant comparisons in the planning stage. 2. Make a graph of the average ±2 SEM and judge visually (!), perhaps supplemented with F -tests on subsets of groups. 3. Modify the t-tests by multiplying the P-values with the number of tests, the socalled Bonferroni correction (conservative) 4. Use a correction for multiple testing (Dunnett, Tukey) or a (prespecified) multiple testing procedure proc glm data=ex_redcell; class grp; model redcell=grp / solution; lsmeans grp / adjust=tukey pdiff cl; The GLM Procedure Least Squares Means Adjustment for Multiple Comparisons: Tukey-Kramer Least Squares Means for effect grp Pr > t for H0: LSMean(i)=LSMean(j) Dependent Variable: redcell i/j 1 2 3 1 0.0355 0.3215 2 0.0355 0.6802 3 0.3215 0.6802 Least Squares Means for Effect grp Difference Simultaneous 95% Between Confidence Limits for i j Means LSMean(i)-LSMean(j) 1 2 60.180556 3.742064 116.619047 1 3 38.625000-27.590379 104.840379 2 3-21.555556-86.340628 43.229517 23 / 69 24 / 69

Visual assessment (1/3) Visual assessment (2/3) The bars represent 95 % confidence intervals for the means using the standard deviation for each group (std2mjt in symbol1 statement). The bars represent 95 % confidence intervals for the means using the pooled standard deviation for each group (std2mpjt in symbol1 statement). proc gplot data=ex_redcell; plot redcell*grp / haxis=axis1 vaxis=axis2 frame; axis1 order=(1 to 3 by 1) offset=(8,8) label=(h=3) value=(h=2) minor=none; axis2 offset=(1,1) value=(h=2) minor=none label=(a=90 R=0 H=3); symbol1 v=circle i=std2mjt l=1 h=2 w=2; Red cell folate 400 380 360 340 320 300 280 260 240 220 200 I II III Group proc gplot data=ex_redcell; plot redcell*grp / haxis=axis1 vaxis=axis2 frame; axis1 order=(1 to 3 by 1) offset=(8,8) label=(h=3) value=(h=2) minor=none; axis2 offset=(1,1) value=(h=2) minor=none label=(a=90 R=0 H=3); symbol1 v=circle i=std2mpjt l=1 h=2 w=2; Red cell folate 400 380 360 340 320 300 280 260 240 220 200 I II III Group 25 / 69 26 / 69 Visual assessment (3/3) The bars represent 95 % confidence intervals for the means using the pooled standard deviation for each group obtained from PROC glm. Model checking Check if the assumptions are reasonable: (If not the analysis is unreliable!) Variance homogeneity may be checked by performing Levenes test (or Bartletts test). In case of variance inhomogeneity, we may also perform a weighted analysis (Welch s test), just as in the T-test Normality may be checked through probability plots (or histograms) of residuals, or by a numerical test on the residuals. In case of non-normality, we may use the nonparametric Kruskal-Wallis test Transformation (often logarithms) may help to achieve variance homogeneity as well as normality 27 / 69 28 / 69

Check of variance homogeneity and normality in SAS Output from proc glm: Test for variance homogeneity proc glm data=ex_redcell; class grp; model redcell=grp; means grp / hovtest=levene welch; output out=model p=predicted r=residual; Store residuals in a dataset for further model checking proc univariate data=model normal ; var residual; histogram residual/ normal(mu=0); ppplot residual / normal(mu=0) square; Levene s Test for Homogeneity of redcell Variance ANOVA of Squared Deviations from Group Means Sum of Mean Source DF Squares Square F Value Pr > F grp 2 18765720 9382860 4.14 0.0321 Error 19 43019786 2264199 Weighted anova in case of variance heterogeneity: Welch s ANOVA for redcell Source DF F Value Pr > F grp 2.0000 2.97 0.0928 Error 11.0646 So we are not too sure concerning the group differences... 29 / 69 30 / 69 Test for normality Output from proc univariate: Histogram and probability plot Output from proc univariate Tests for Normality Test --Statistic--- -----p Value---- Shapiro-Wilk W 0.965996 Pr < W 0.6188 Kolmogorov-Smirnov D 0.107925 Pr > D >0.1500 Cramer-von Mises W-Sq 0.043461 Pr > W-Sq >0.2500 Anderson-Darling A-Sq 0.263301 Pr > A-Sq >0.2500 The 4 tests focus on different aspects of non-normality. For small data sets, we rarely get significance For large data sets, we almost always get significance Could look at a probability plot instead 31 / 69 32 / 69

Non-parametric ANOVA, the Kruskal-Wallis test SAS code proc npar1way wilcoxon; exact; class grp; var redcell; Wilcoxon Scores (Rank Sums) for Variable redcell Classified by Variable grp Sum of Expected Std Dev Mean grp N Scores Under H0 Under H0 Score ------------------------------------------------------------------- 1 8 120.0 92.00 14.651507 15.000000 2 9 77.0 103.50 14.974979 8.555556 3 5 56.0 57.50 12.763881 11.200000 Kruskal-Wallis Test Chi-Square 4.1852 DF 2 Asymptotic Pr > Chi-Square 0.1234 Exact Pr >= Chi-Square 0.1233 Two-way analysis of variance Two criterias for subdividing observations, A og B Data in two-way layout: B A 1 2 c 1 2... r. Effect of both factors Perhaps even interaction (effect modification) One factor may be individuals or experimental units (e.g. different treatments tried on same person) Again, we have lost the significance... 33 / 69 34 / 69 Repeated measurements Line plot ( Spaghettiogram ) Example: Short term effect of enalaprilate on heart rate (beats per minute) (DGM, Section 12.3.1) Time Subject 0 30 60 120 average 1 96 92 86 92 91.50 2 110 106 108 114 109.50 3 89 86 85 83 85.75 4 95 78 78 83 83.50 5 128 124 118 118 122.00 6 100 98 100 94 98.00 7 72 68 67 71 69.50 8 79 75 74 74 75.50 9 100 106 104 102 103.00 average 96.56 92.56 91.11 92.33 93.14 Ideally the time courses are parallel. 35 / 69 36 / 69

The additive model Analysis of variance table - enalaprilate example The two effects (s and t) work in an additive way. Y st = µ + α s + β t + ε st The ε st s are assumed to be independent, normally distributed with mean 0, and identical variances, ε st N(0, σ 2 ). (This assumption should be investigated!) Variational decomposition: df SS MS F P Subjects 8 8966.6 1120.8 90.64 <0.0001 Times 3 151.0 50.3 4.07 0.0180 Residual 24 296.8 12.4 Total 35 9414.3 Highly significant difference between subjects (not very interesting) Significant time differences. SS total = SS subject + SS time + SS residual 37 / 69 38 / 69 Two-way ANOVA in SAS Two-way ANOVA output proc glm data=ex_pulse; class subject times; model hrate=subject times / solution; General Linear Models Procedure Class Level Information Class Levels Values SUBJECT 9 1 2 3 4 5 6 7 8 9 TIMES 4 0 30 60 120 Number of observations in data set = 36 General Linear Models Procedure Dependent Variable: HRATE Sum of Mean Source DF Squares Square F Value Pr > F Model 11 9117.52778 828.86616 67.03 0.0001 Error 24 296.77778 12.36574 Corrected Total 35 9414.30556 R-Square C.V. Root MSE HRATE Mean 0.968476 3.775539 3.51650 93.1389 Source DF Type I SS Mean Square F Value Pr > F SUBJECT 8 8966.55556 1120.81944 90.64 0.0001 TIMES 3 150.97222 50.32407 4.07 0.0180 Source DF Type III SS Mean Square F Value Pr > F SUBJECT 8 8966.55556 1120.81944 90.64 0.0001 TIMES 3 150.97222 50.32407 4.07 0.0180 39 / 69 40 / 69

Parameter estimates T for H0: Pr > T Std Error of Parameter Estimate Parameter=0 Estimate Expected values and residuals Expected values for subject=3, times=30 INTERCEPT 102.1944444 B 50.34 0.0001 2.03024963 SUBJECT 1-11.5000000 B -4.62 0.0001 2.48653783 2 6.5000000 B 2.61 0.0152 2.48653783 3-17.2500000 B -6.94 0.0001 2.48653783 4-19.5000000 B -7.84 0.0001 2.48653783 5 19.0000000 B 7.64 0.0001 2.48653783 6-5.0000000 B -2.01 0.0557 2.48653783 7-33.5000000 B -13.47 0.0001 2.48653783 8-27.5000000 B -11.06 0.0001 2.48653783 9 0.0000000 B... TIMES 0 4.2222222 B 2.55 0.0177 1.65769189 30 0.2222222 B 0.13 0.8945 1.65769189 60-1.2222222 B -0.74 0.4681 1.65769189 120 0.0000000 B... Residuals ŷ st = ˆµ + ˆα s + ˆβ t = 102.19 17.25 + 0.22 = 85.16 NOTE: The X X matrix has been found to be singular and a generalized inverse was used to solve the normal equations. Estimates followed by the letter B are biased, and are not unique estimators of the parameters. subject 9 at time 120 minutes is the reference r st = observed expected = y st ŷ st ε st Residual for subject 3, time 30: r 32 = 86 85.16 = 0.84 41 / 69 42 / 69 Model checking Residual based diagnostics Look for: differences in variances (systematic?) Non-normality Lack of additivity (interaction). Can only be tested if there is more than one observation for each combination Serial correlation? (Neighboring observations look more alike) Use the residuals for model checking Probability plot of residuals. Plot residuals vs expected values. Plot residuals vs group. Look for outliers (a large residual means observed and expected values deviate a lot). 43 / 69 44 / 69

Enalaprilate example Interaction Example of two criterias for subdividing individuals: sex and smoking habits Outcome: FEV 1 Here, we see an interaction between sex and smoking. No systematic patterns should be present. 45 / 69 46 / 69 Possible explanations for interaction Example: The effect of smoking on birth weight Biologically different effects of smoking on males and females Perhaps the women do not smoke as much as the men Perhaps the effect is relative (to be expressed in %) 47 / 69 48 / 69

Example: The effect of smoking on birth weight Interpreting interaction There is an effect of smoking, but only for those who have been smoking for a long time. There is an effect of duration, and this effects increases with amount of smoking The effect of duration depends upon... amount of smoking and the effect of amount depends upon... duration of smoking 49 / 69 50 / 69 Example: Fibrinogen after spleen operation Example: Fibrinogen after spleen operation 34 rats are randomized, in 2 ways 17 have their spleen removed (splenectomy=yes/no) 8/17 in each group are kept in altitude chambers (corresponding to 15.000 ft) (place=altitude/control) Outcome Fibrinogen level in mg% at day 21 Fibrinogen (mg%%) 600 500 400 300 200 100 no_altitude no_control yes_altitude yes_control group Source: Rupert G. Miller: Beyond ANOVA, p. 161-162 51 / 69 52 / 69

ANOVA model with interaction The usual additive model: Y spr = µ + α s + β p + ε spr, ε spr N(0, σ 2 ) splenectomy (s=yes/no) and place (p=altitude/control) have an additive effect. Model with interaction Y spr = µ + α s + β p + γ sp + ε spr, ε spr N(0, σ 2 ) Here, we specify an interaction between splenectomy and place, i.e. the effect of living in a high altitude may be thought to depend upon whether or not you have an intact spleen. and vice versa.. Two-way ANOVA with interaction in SAS proc glm data=ex_fibrinogen; class splenectomy place; model fibrinogen=place splenectomy place*splenectomy / solution; output out=model p=predicted r=residual; The GLM Procedure Class Level Information Class Levels Values splenectomy 2 no yes place 2 altitude control Number of observations 34 53 / 69 54 / 69 Output: two-way ANOVA table Output: Parameter estimates Dependent Variable: fibrinogen Sum of Source DF Squares Mean Square F Value Pr > F Model 3 139439.2067 46479.7356 8.32 0.0004 Error 30 167573.7639 5585.7921 Corrected Total 33 307012.9706 R-Square Coeff Var Root MSE fibrinogen Mean 0.454180 20.99213 74.73816 356.0294 Source DF Type I SS Mean Square F Value Pr > F place 1 67925.25531 67925.25531 12.16 0.0015 splenectomy 1 69662.38235 69662.38235 12.47 0.0014 splenectomy*place 1 1851.56904 1851.56904 0.33 0.5691 Source DF Type III SS Mean Square F Value Pr > F Standard Parameter Estimate Error t Value Pr > t Intercept 261.6666667 B 24.91271904 10.50 <.0001 place altitude 104.3333333 B 36.31621657 2.87 0.0074 place control 0.0000000 B... splenectomy no 104.4444444 B 35.23190514 2.96 0.0059 splenectomy yes 0.0000000 B... splenectomy*place no altitude -29.5694444 B 51.35888601-0.58 0.5691 splenectomy*place no control 0.0000000 B... splenectomy*place yes altitude 0.0000000 B... splenectomy*place yes control 0.0000000 B... NOTE: The X X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter B are not uniquely estimable. place 1 67925.25531 67925.25531 12.16 0.0015 splenectomy 1 68093.92198 68093.92198 12.19 0.0015 splenectomy*place 1 1851.56904 1851.56904 0.33 0.5691 55 / 69 56 / 69

Computing expected values Expected fibrinogen levels The reference levels are place=control, splenectomy=yes (as SAS chooses the reference levels as last level based on alphabetic ordering) so the expected fibrinogen level for these animals is intercept=261.67 For all other groups, we have to add one or more extra estimates, as shown in the table below: place splenectomy control altitude 261.67 261.67 yes + 104.33 = 366.00 261.67 261.67 + 104.44 + 104.44 no + 104.33-29.57 = 366.11 = 440.87 Note: expected value for splenectomy=no, place=altitude - rounding issue 57 / 69 58 / 69 Model checking Variance homogeneity may be judged from a one-way anova Normality assumption for residuals Result from proc univariate normal) The GLM Procedure Class Level Information Class Levels Values group 4 no_altitude no_control yes_altitude yes_control Number of observations 34 Levene s Test for Homogeneity of fibrinogen Variance ANOVA of Squared Deviations from Group Means Sum of Mean Source DF Squares Square F Value Pr > F group 3 1.9078E8 63594756 1.55 0.2222 Error 30 1.2314E9 41045352 Tests for Normality Test --Statistic--- -----p Value------ Shapiro-Wilk W 0.964518 Pr < W 0.3276 Kolmogorov-Smirnov D 0.126665 Pr > D >0.1500 Cramer-von Mises W-Sq 0.091627 Pr > W-Sq 0.1424 Anderson-Darling A-Sq 0.490958 Pr > A-Sq 0.2140 Conclusion No reason to suspect non-normality No reason to suspect inhomogeneity 59 / 69 60 / 69

Model simplification In the two-way anova, the interaction was not significant (P=0.77), so we omit it from the model: proc glm data=ex_fibrinogen; class splenectomy place; model fibrinogen=place splenectomy / solution clparm; Dependent Variable: fibrinogen Sum of Source DF Squares Mean Square F Value Pr > F Model 2 137587.6377 68793.8188 12.59 <.0001 Error 31 169425.3329 5465.3333 Corrected Total 33 307012.9706 R-Square Coeff Var Root MSE fibrinogen Mean 0.448149 20.76455 73.92789 356.0294 Source DF Type III SS Mean Square F Value Pr > F place 1 67925.25531 67925.25531 12.43 0.0013 splenectomy 1 69662.38235 69662.38235 12.75 0.0012 Assessing the main effects Standard Parameter Estimate Error t Value Pr > t Intercept 268.6241830 B 21.54935559 12.47 <.0001 place altitude 89.5486111 B 25.40104253 3.53 0.0013 place control 0.0000000 B... splenectomy no 90.5294118 B 25.35705800 3.57 0.0012 splenectomy yes 0.0000000 B... Parameter 95% Confidence Limits Intercept 224.6739825 312.5743835 place altitude 37.7428433 141.3543789 place control.. splenectomy no 38.8133510 142.2454725 splenectomy yes.. Removal of spleen leads to a decrease in fibronogen of approx 90.53 mg% at day 21 Placing in altitude leads to an increase in fibronogen of approx 89.55 mg% at day 21 61 / 69 62 / 69 Residual plots More complicated analyses of variances Normality Variance homogeneity Three- or more-sided analysis of variance. Latin squares Residual 200 100 0 1 2 3 I A B C II B C A III C A B -100-200 260 280 300 320 340 360 380 400 420 440 460 Expected (Cochran & Cox (1957): Experimental Designs, 2.ed., Wiley) Cross-over designs Variance component models 63 / 69 64 / 69

Example of a latin square: A rabbit experiment Example of a latin square: A rabbit experiment 6 rabbits Vaccination at 6 different spots on the back 6 different orders of vaccination Swelling is area of blister (cm 2 ) spot rabbit order swelling 1 1 3 7.9 1 2 5 8.7 1 3 4 7.4 1 4 1 7.4.. 6 4 4 5.8 6 5 1 6.4 6 6 3 7.7 65 / 69 66 / 69 Illustrations 3-way analysis of variance, with additive effects swelling 10 9 8 7 6 5 2 1 6 25 2 34 3 16 5 4 1 4 6 35 2 25 6 2 4 6 36 31 13 1 45 5 4 a b c d e f spot swelling 10 9 8 7 6 5 2 2 2 26 5 6 12 5 2 13 4 4 6 3 36 3 1 1 3 4 15 6 5 5 4 1 5 4 6 4 3 1 2 3 4 5 6 order proc glm; class rabbit spot order; model swelling=rabbit spot order; The GLM Procedure Class Level Information Class Levels Values rabbit 6 1 2 3 4 5 6 spot 6 a b c d e f order 6 1 2 3 4 5 6 Number of observations 36 67 / 69 68 / 69

3-way analysis of variance Dependent Variable: swelling Sum of Source DF Squares Mean Square F Value Pr > F Model 15 17.23000000 1.14866667 1.75 0.1205 Error 20 13.13000000 0.65650000 Corrected Total 35 30.36000000 R-Square Coeff Var Root MSE swelling Mean 0.567523 10.99883 0.810247 7.366667 Source DF Type III SS Mean Square F Value Pr > F rabbit 5 12.83333333 2.56666667 3.91 0.0124 spot 5 3.83333333 0.76666667 1.17 0.3592 order 5 0.56333333 0.11266667 0.17 0.9701 The design is balanced, so the test of the effect of one variable (covariate) does not depend on which of the others are still in the model. 69 / 69