# Analysis of Variance Compares means to determine if the population distributions are not similar Uses means and confidence intervals much like a t-test.

## Presentation on theme: "Analysis of Variance Compares means to determine if the population distributions are not similar Uses means and confidence intervals much like a t-test."— Presentation transcript:

Analysis of Variance Compares means to determine if the population distributions are not similar Uses means and confidence intervals much like a t-test Test statistic used is called an F statistic (F-test)

Normal Distribution Most characteristics follow a normal distribution –For example: height, length, speed, etc. One of the assumptions of the ANOVA test is that the sample data is ‘normally distributed.’

Sample Distribution Approaches Normal Distribution With Sample Size

Proc Univariate Tests for normality Gives you a ‘visual’ of your sample distribution SAS code: proc sort; by location proc univariate plot normal; by location; var length; run;

Tests for Normality Test --Statistic--- -----p Value------ Shapiro-Wilk W 0.951978 Pr < W 0.6919 Kolmogorov-Smirnov D 0.156907 Pr > D >0.1500 Cramer-von Mises W-Sq 0.03281 Pr > W-Sq >0.2500 Anderson-Darling A-Sq 0.223707 Pr > A-Sq >0.2500 Important Univariate Output Each of the four above tests are testing for normality. The Shapiro-Wilk and Kolmogorov-Smirnov are the two most common. Because all p values are >0.05, none of the tests indicate that our sample is significantly different than a normal distribution.

Variance =  (x-x) 2 N-1  i= x N N Mean = x = Standard Deviation =  (x-x) 2 N-1  Mean = 169/6 = 28.17 Range = 25 – 32 SOS = 40.83 Variance = 40.83 / 5 = 8.16 Std. Dev. =  40.83/5 = 2.86 Std. Err. = 2.86 / √ 6 = 1.17 Standard Error = SD √N

Calculate a SOS based on an overall mean (total SOS) ANOVA – Analysis of Variance

TrtmntReplicateLengthOverall MeanSOS Total Pond13457.7561.69 Pond27857.7412.09 Pond34857.794.09 Pond42457.71135.69 Pond56457.739.69 Pond65857.70.09 Pond73457.7561.69 Pond86657.768.89 Pond92257.71274.49 Pond104457.7187.69 Lake13857.7388.09 Lake28257.7590.49 Lake35857.70.09 Lake47657.7334.89 Lake56057.75.29 Lake67057.7151.29 Lake79957.71705.69 Lake84057.7313.29 Lake96857.7106.09 Lake109157.71108.89 9040.2 This provides a measure of the overall variance (Total SOS).

Calculate a SOS based for each treatment (Treatment or Error SOS).

TrtmntReplicateLengthTrtmnt MeanSOS Error Pond13447.2174.24 Pond27847.2948.64 Pond34847.20.64 Pond42447.2538.24 Pond56447.2282.24 Pond65847.2116.64 Pond73447.2174.24 Pond86647.2353.44 Pond92247.2635.04 Pond104447.210.24 Lake13868.2912.04 Lake28268.2190.44 Lake35868.2104.04 Lake47668.260.84 Lake56068.267.24 Lake67068.23.24 Lake79968.2948.64 Lake84068.2795.24 Lake96868.20.04 Lake109168.2519.84 6835.2 This provides a measure of the reduction of variance by measuring each treatment separately (Treatment or Error SOS). What happens to Error SOS when the variability w/in each treatment decreases?

Calculate a SOS for each predicted value vs. the overall mean (Model SOS)

TrtmntReplicateLengthTrtmnt MeanOverall MeanSOS Model Pond13447.257.7110.25 Pond27847.257.7110.25 Pond34847.257.7110.25 Pond42447.257.7110.25 Pond56447.257.7110.25 Pond65847.257.7110.25 Pond73447.257.7110.25 Pond86647.257.7110.25 Pond92247.257.7110.25 Pond104447.257.7110.25 Lake13868.257.7110.25 Lake28268.257.7110.25 Lake35868.257.7110.25 Lake47668.257.7110.25 Lake56068.257.7110.25 Lake67068.257.7110.25 Lake79968.257.7110.25 Lake84068.257.7110.25 Lake96868.257.7110.25 Lake109168.257.7110.25 2205 This provides a measure of the distance between the mean values (Model SOS). What happens to Model SOS when the two means are close together? What if the means are equal?

Detecting a Difference Between Treatments Model SOS gives us an index on how far apart the two means are from each other. – Bigger Model SOS = farther apart Error SOS gives us an index of how scattered the data is for each treatment. –More variability = larger Error SOS = more possible overlap between treatments

Magic of the F-test The ratio of Model SOS to Error SOS (Model SOS divided by Error SOS) gives us an overall index (the F statistic) used to indicate the relative ‘distance’ and ‘overlap’ between two means. –A large Model SOS and small Error SOS = a large F statistic. Why does this indicate a significant difference? –A small Model SOS and a large Error SOS = a small F statistic. Why does this indicate no significant difference?? Based on sample size and alpha level (P-value), each F statistic has an associated P-value. –P < 0.05 (Large F statistic) there is a significant difference between the means –P ≥ 0.05 (Small F statistic) there is NO significant difference

Data chicken; input location\$ replicate length; cards; Data Set not shown ; proc print; run; proc sort; by location; /* proc means mean n var stddev cv stderr clm; by location; var length; run; */ proc anova; {Tells SAS to do the analysis of variance procedure} class location; {Tells SAS that location is a class variable} model length=location; (Tells SAS to compare length between locations} run; Tells SAS to ignore everything between /* and */ SAS Program with ANOVA added

The SAS System 10:10 Monday, June 19, 2006 1 Obs location replicate length 1 Pond 1 34 2 Pond 2 78 3 Pond 3 48 4 Pond 4 24 5 Pond 5 64 6 Pond 6 58 7 Pond 7 34 8 Pond 8 66 9 Pond 9 22 10 Pond 10 44 11 Lake 1 38 12 Lake 2 82 13 Lake 3 58 14 Lake 4 76 15 Lake 5 60 16 Lake 6 70 17 Lake 7 99 18 Lake 8 40 19 Lake 9 68 20 Lake 10 91 Data Set: 20 total observations Two locations with 10 replicates each Individual lengths

The ANOVA Procedure Class Level Information Class Levels Values location 2 Lake Pond Number of Observations Read 20 Number of Observations Used 20 SAS ANOVA Output 1 st Page This tell us that SAS understands that there are two classes: Lake and Pond. We also are told that SAS can use all 20 values in this ANOVA procedure.

SAS ANOVA Output 2 nd Page The SAS System 10:10 Monday, June 19, 2006 4 The ANOVA Procedure Dependent Variable: length Sum of Source DF Squares Mean Square F Value Pr > F Model 1 2205.000000 2205.000000 5.81 0.0269 Error 18 6835.200000 379.733333 Corrected Total 19 9040.200000 R-Square Coeff Var Root MSE length Mean 0.243911 33.77253 19.48675 57.70000 Source DF Anova SS Mean Square F Value Pr > F location 1 2205.000000 2205.000000 5.81 0.0269 What are some ways to make the F Value larger? ÷ ÷ = = P-value

Data Set; 3 treatments with 5 replicates per treatment What about analysis of variance with three treatments: TreatmentMean 126.4 217.2 329.0

The SAS System 13:17 Monday, October 4, 2004 2 The ANOVA Procedure Class Level Information Class Levels Values treat 3 1 2 3 Number of observations 15 Variable nameVariable labels

The SAS System 13:17 Monday, October 4, 2004 3 The ANOVA Procedure Dependent Variable: size Sum of Source DF Squares Mean Square F Value Pr > F Model 2 384.4000000 192.2000000 18.30 0.0002 Error 12 126.0000000 10.5000000 Corrected Total 14 510.4000000 R-Square Coeff Var Root MSE size Mean 0.753135 13.38996 3.240370 24.20000 Source DF Anova SS Mean Square F Value Pr > F treat 2 384.4000000 192.2000000 18.30 0.0002 P-valueF-value   = = TreatmentMean 126.4 217.2 329.0 Which means are different/similar?

proc anova; {Tells SAS to do the analysis of variance procedure} class treatment; {Tells SAS that treatment is a class variable} model weight=treatment; (Tells SAS to compare weight among treatments} means treatment / tukey lines; {Tells SAS to delineate the means with a Tukey test and use the lines method to show differences. run; Delineating the Means With SAS

The SAS System 13:17 Monday, October 4, 2004 7 The ANOVA Procedure Tukey's Studentized Range (HSD) Test for size NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than REGWQ. Alpha 0.05 Error Degrees of Freedom 12 Error Mean Square 10.5 Critical Value of Studentized Range 3.77278 Minimum Significant Difference 5.4673 Means with the same letter are not significantly different. Tukey Grouping Mean N treat A 29.000 5 3 A A 26.400 5 1 B 17.200 5 2 Treat 1 and 3 are not different, 1 and 3 are different than 2

A B A Showing Results

Download ppt "Analysis of Variance Compares means to determine if the population distributions are not similar Uses means and confidence intervals much like a t-test."

Similar presentations