ANOVA: Graphical. Cereal Example: nknw677.sas Y = number of cases of cereal sold (CASES) X = design of the cereal package (PKGDES) r = 4 (there were 4.

Slides:



Advertisements
Similar presentations
CS Example: General Linear Test (cs2.sas)
Advertisements

Analysis of Variance Compares means to determine if the population distributions are not similar Uses means and confidence intervals much like a t-test.
EPI 809/Spring Probability Distribution of Random Error.
Topic 3: Simple Linear Regression. Outline Simple linear regression model –Model parameters –Distribution of error terms Estimation of regression parameters.
Partial Regression Plots. Life Insurance Example: (nknw364.sas) Y = the amount of life insurance for the 18 managers (in $1000) X 1 = average annual income.
Some Terms Y =  o +  1 X Regression of Y on X Regress Y on X X called independent variable or predictor variable or covariate or factor Which factors.
Multiple regression analysis
Chapter 9: The Analysis of Variance (ANOVA)
ANOVA notes NR 245 Austin Troy
Matrix A matrix is a rectangular array of elements arranged in rows and columns Dimension of a matrix is r x c  r = c  square matrix  r = 1  (row)
Be humble in our attribute, be loving and varying in our attitude, that is the way to live in heaven.
Chapter 3 Experiments with a Single Factor: The Analysis of Variance
Experimental design and statistical analyses of data Lesson 4: Analysis of variance II A posteriori tests Model control How to choose the best model.
Example: Price Analysis for Diamond Rings in Singapore Variables Response Variable: Price in Singapore dollars (Y) Explanatory Variable: Weight of diamond.
Distribution of X: (nknw096) data toluca; infile 'H:\CH01TA01.DAT'; input lotsize workhrs; seq=_n_; proc print data=toluca; run; Obslotsizeworkhrsseq
SAS Lecture 5 – Some regression procedures Aidan McDermott, April 25, 2005.
Topic 16: Multicollinearity and Polynomial Regression.
Topic 28: Unequal Replication in Two-Way ANOVA. Outline Two-way ANOVA with unequal numbers of observations in the cells –Data and model –Regression approach.
1 Experimental Statistics - week 6 Chapter 15: Randomized Complete Block Design (15.3) Factorial Models (15.5)
Multiple Comparisons.
Topic 2: An Example. Leaning Tower of Pisa Construction began in 1173 and by 1178 (2 nd floor), it began to sink Construction resumed in To compensate.
1 Experimental Statistics - week 10 Chapter 11: Linear Regression and Correlation.
Topic 7: Analysis of Variance. Outline Partitioning sums of squares Breakdown degrees of freedom Expected mean squares (EMS) F test ANOVA table General.
Lecture 4 SIMPLE LINEAR REGRESSION.
Topic 14: Inference in Multiple Regression. Outline Review multiple linear regression Inference of regression coefficients –Application to book example.
1 Experimental Statistics - week 10 Chapter 11: Linear Regression and Correlation Note: Homework Due Thursday.
6-3 Multiple Regression Estimation of Parameters in Multiple Regression.
GENERAL LINEAR MODELS Oneway ANOVA, GLM Univariate (n-way ANOVA, ANCOVA)
5-5 Inference on the Ratio of Variances of Two Normal Populations The F Distribution We wish to test the hypotheses: The development of a test procedure.
Nonlinear Models. Learning Example: knnl533.sas Y = relative efficiency of production of a new product (1/expected cost) X 1 : Location A : X 1 = 1, B:
Topic 17: Interaction Models. Interaction Models With several explanatory variables, we need to consider the possibility that the effect of one variable.
6-1 Introduction To Empirical Models Based on the scatter diagram, it is probably reasonable to assume that the mean of the random variable Y is.
1 Fourier Series (Spectral) Analysis. 2 Fourier Series Analysis Suitable for modelling seasonality and/or cyclicalness Identifying peaks and troughs.
The Completely Randomized Design (§8.3)
Topic 6: Estimation and Prediction of Y h. Outline Estimation and inference of E(Y h ) Prediction of a new observation Construction of a confidence band.
6-3 Multiple Regression Estimation of Parameters in Multiple Regression.
Topic 13: Multiple Linear Regression Example. Outline Description of example Descriptive summaries Investigation of various models Conclusions.
Hormone Example: nknw892.sas Y = change in growth rate after treatment Factor A = gender (male, female) Factor B = bone development level (severely depressed,
Topic 23: Diagnostics and Remedies. Outline Diagnostics –residual checks ANOVA remedial measures.
1 Experimental Statistics - week 14 Multiple Regression – miscellaneous topics.
Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference.
Topic 25: Inference for Two-Way ANOVA. Outline Two-way ANOVA –Data, models, parameter estimates ANOVA table, EMS Analytical strategies Regression approach.
Bread Example: nknw817.sas Y = number of cases of bread sold (sales) Factor A = height of shelf display (bottom, middle, top) Factor B = width of shelf.
Topic 26: Analysis of Covariance. Outline One-way analysis of covariance –Data –Model –Inference –Diagnostics and rememdies Multifactor analysis of covariance.
PSYC 3030 Review Session April 19, Housekeeping Exam: –April 26, 2004 (Monday) –RN 203 –Use pencil, bring calculator & eraser –Make use of your.
Xuhua Xia Correlation and Regression Introduction to linear correlation and regression Numerical illustrations SAS and linear correlation/regression –CORR.
Simple Linear Regression. Data available : (X,Y) Goal : To predict the response Y. (i.e. to obtain the fitted response function f(X)) Least Squares Fitting.
1 Experimental Statistics - week 9 Chapter 17: Models with Random Effects Chapter 18: Repeated Measures.
Topic 24: Two-Way ANOVA. Outline Two-way ANOVA –Data –Cell means model –Parameter estimates –Factor effects model.
Sigmoidal Response (knnl558.sas). Programming Example: knnl565.sas Y = completion of a programming task (1 = yes, 0 = no) X 2 = amount of programming.
Topic 20: Single Factor Analysis of Variance. Outline Analysis of Variance –One set of treatments (i.e., single factor) Cell means model Factor effects.
Today: March 7 Data Transformations Rank Tests for Non-Normal data Solutions for Assignment 4.
Example 1 (knnl917.sas) Y = months survival Treatment (3 levels)
Chapter 11: The ANalysis Of Variance (ANOVA)
1 Experimental Statistics - week 13 Multiple Regression Miscellaneous Topics.
1 An example of a more complex design (a four level nested anova) 0 %, 20% and 40% of a tree’s roots were cut with the purpose to study the influence.
Experimental Statistics - week 9
Topic 29: Three-Way ANOVA. Outline Three-way ANOVA –Data –Model –Inference.
Interview Example: nknw964.sas Y = rating of a job applicant Factor A represents 5 different personnel officers (interviewers) n = 4.
Topic 27: Strategies of Analysis. Outline Strategy for analysis of two-way studies –Interaction is not significant –Interaction is significant What if.
Topic 22: Inference. Outline Review One-way ANOVA Inference for means Differences in cell means Contrasts.
Simple ANOVA Comparing the Means of Three or More Groups Chapter 9.
1 Experimental Statistics - week 12 Chapter 11: Linear Regression and Correlation Chapter 12: Multiple Regression.
1 Experimental Statistics - week 11 Chapter 11: Linear Regression and Correlation.
Lesson 10 - Topics SAS Procedures for Standard Statistical Tests and Analyses Programs 19 and 20 LSB 8:16-17.
1 Experimental Statistics - week 5 Chapter 9: Multiple Comparisons Chapter 15: Randomized Complete Block Design (15.3)
After ANOVA If your F < F critical: Null not rejected, stop right now!! If your F > F critical: Null rejected, now figure out which of the multiple means.
6-1 Introduction To Empirical Models
Experimental Statistics - Week 4 (Lab)
ANOVA Analysis of Variance.
Presentation transcript:

ANOVA: Graphical

Cereal Example: nknw677.sas Y = number of cases of cereal sold (CASES) X = design of the cereal package (PKGDES) r = 4 (there were 4 designs tested) n i = 5, 5, 4, 5 (one store had a fire) n T = 19

Cereal Example: input data cereal; infile ‘H:\My Documents\Stat 512\CH16TA01.DAT'; input cases pkgdes store; proc print data=cereal; run; ObscasespkgdesstoreObscasespkgdesstore

Cereal Example: Scatterplot title1 h=3 'Types of packaging of Cereal'; title2 h=2 'Scatterplot'; axis1 label=(h=2); axis2 label=(h=2 angle=90); symbol1 v=circle i=none c=purple; proc gplot data=cereal; plot cases*pkgdes /haxis=axis1 vaxis=axis2; run;

Cereal Example: ANOVA proc glm data=cereal; class pkgdes; model cases=pkgdes/xpx inverse solution; means pkgdes; run; Class Level Information ClassLevelsValues pkgdes Level of pkgdes N cases MeanStd Dev

Cereal Example: Means proc means data=cereal; var cases; by pkgdes; output out=cerealmeans mean=avcases; proc print data=cerealmeans; run; title2 h=2 'plot of means'; symbol1 v=circle i=join; proc gplot data=cerealmeans; plot avcases*pkgdes/haxis=axis1 vaxis=axis2; run; Types of packaging of Cereal plot of means Obspkgdes_TYPE__FREQ_avcases

Cereal Example: Means (cont)

ANOVA Table Source of Variation dfSSMS Model (Regression) r – 1 Errorn T – r Totaln T – 1

ANOVA test

Cereal Example: ANOVA table proc glm data=cereal; class pkgdes; model cases=pkgdes; run; SourceDFSum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEcases Mean

Cereal Example: Design Matrix

Cereal Example: Inverse proc glm data=cereal; class pkgdes; model cases=pkgdes/ xpx inverse solution; means pkgdes; run;

Cereal Example: /xpx The X'X Matrix Interceptpkgdes 1pkgdes 2pkgdes 3pkgdes 4cases Intercept pkgdes pkgdes pkgdes pkgdes cases

Cereal Example: /inverse X'X Generalized Inverse (g2) Interceptpkgdes 1pkgdes 2pkgdes 3pkgdes 4cases Intercept pkgdes pkgdes pkgdes pkgdes cases

Cereal Example: /solution ParameterEstimateStandard Errort ValuePr > |t| Intercept B <.0001 pkgdes B <.0001 pkgdes B <.0001 pkgdes B pkgdes 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.

Cereal Example: ANOVA Level of pkgdes N cases MeanStd Dev

Cereal Example: Means (nknw698.sas) proc means data=cereal printalltypes; class pkgdes; var cases; output out=cerealmeans mean=mclass; run; Analysis Variable : cases N ObsNMeanStd DevMinimumMaximum Analysis Variable : cases pkgdesN ObsNMeanStd DevMinimumMaximum The MEANS Procedure

Cereal Example: Means (cont) proc print data=cerealmeans; run; Obspkgdes_TYPE__FREQ_mclass

Cereal Example: Explanatory Variables data cereal; set cereal; x1=(pkgdes eq 1)-(pkgdes eq 4); x2=(pkgdes eq 2)-(pkgdes eq 4); x3=(pkgdes eq 3)-(pkgdes eq 4); proc print data=cereal; run;

Cereal Example: Explanatory Variables (cont) Obscasespkgdesstorex1x2x

Cereal Example: Regression proc reg data=cereal; model cases=x1 x2 x3; run;

Cereal Example: Regression (cont) Analysis of Variance SourceDF Sum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var Parameter Estimates VariableDF Parameter Estimate Standard Error t ValuePr > |t| Intercept <.0001 x x x

Cereal Example: ANOVA proc glm data=cereal; class pkgdes; model cases=pkgdes; run; SourceDF Sum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEcases Mean

Cereal Example: Comparison Regression ANOVA Analysis of Variance SourceDF Sum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var SourceDF Sum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEcases Mean

Cereal Example: Regression (cont) Analysis of Variance SourceDF Sum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var Parameter Estimates VariableDF Parameter Estimate Standard Error t ValuePr > |t| Intercept <.0001 x x x

Cereal Example: Means proc means data=cereal printalltypes; class pkgdes; var cases; output out=cerealmeans mean=mclass; run; Analysis Variable : cases N ObsNMeanStd DevMinimumMaximum Analysis Variable : cases pkgdesN ObsNMeanStd DevMinimumMaximum The MEANS Procedure

Cereal Example: nknw677a.sas Y = number of cases of cereal sold (CASES) X = design of the cereal package (PKGDES) r = 4 (there were 4 designs tested) n i = 5, 5, 4, 5 (one store had a fire) n T = 19

Cereal Example: Plotting Means title1 h=3 'Types of packaging of Cereal'; proc glm data=cereal; class pkgdes; model cases=pkgdes; output out=cerealmeans p=means; run; title2 h=2 'plot of means'; axis1 label=(h=2); axis2 label=(h=2 angle=90); symbol1 v=circle i=none c=blue; symbol2 v=none i=join c=red; proc gplot data=cerealmeans; plot cases*pkgdes means*pkgdes/overlay haxis=axis1 vaxis=axis2; run;

Cereal Example: Means (cont)

Cereal Example: CI (1) (nknw711.sas) proc means data=cereal mean std stderr clm maxdec=2; class pkgdes; var cases; run; The MEANS Procedure Analysis Variable : cases pkgdesN ObsMeanStd DevStd Error Lower 95% CL for Mean Upper 95% CL for Mean

Cereal Example: CI (2) proc glm data=cereal; class pkgdes; model cases=pkgdes; means pkgdes/t clm; run; The GLM Procedure t Confidence Intervals for cases Alpha0.05 Error Degrees of Freedom15 Error Mean Square Critical Value of t pkgdesNMean95% Confidence Limits

Cereal Example: CI pkdgesMeanStd ErrorCI (means)CI (glm) (11.74, 17.46)(11.504, ) (8.87, 17.93)(10.304, ) (15.29, 23.71)(16.039, ) (22.28, 32.12)(24.104, )

Cereal Example: CI Bonferroni Correction proc glm data=cereal; class pkgdes; model cases=pkgdes; means pkgdes/bon clm; run; The GLM Procedure Bonferroni t Confidence Intervals for cases Alpha0.05 Error Degrees of Freedom15 Error Mean Square Critical Value of t pkgdesNMean Simultaneous 95% Confidence Limits

Cereal Example: CI – Bonferroni Correction pkdgesMeanCICI (Bonferroni) 427.2(24.104, )(23.080, ) 319.5(16.039, )(14.894, ) 114.6(11.504, )(10.480, ) 213.4(10.304, )(9.280, )

Cereal Example: Significance Test proc means data=cereal mean std stderr t probt maxdec=2; class pkgdes; var cases; run; Analysis Variable : cases pkgdesN ObsMeanStd DevStd Errort ValuePr > |t|

Cereal Example: CI for  i -  j proc glm data=cereal; class pkgdes; model cases=pkgdes; means pkgdes/cldiff lsd tukey bon scheffe dunnett("2"); means pkgdes/lines tukey; run;

Cereal Example: CI for  i -  j - LSD t Tests (LSD) for cases Note: This test controls the Type I comparisonwise error rate, not the experimentwise error rate. Alpha0.05 Error Degrees of Freedom15 Error Mean Square Critical Value of t

Cereal Example: CI for  i -  j – LSD (cont) Comparisons significant at the 0.05 level are indicated by ***. pkgdes Comparison Difference Between Means 95% Confidence Limits *** *** *** *** *** *** *** *** *** ***

Cereal Example: CI for  i -  j - Tukey Tukey's Studentized Range (HSD) Test for cases Note: This test controls the Type I experimentwise error rate. Critical Value of Studentized Range Comparisons significant at the 0.05 level are indicated by ***. pkgdes Comparison Difference Between Means Simultaneous 95% Confidence Limits *** *** *** *** *** ***

Cereal Example: CI for  i -  j - Scheffé Scheffe's Test for cases Note: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than Tukey's for all pairwise comparisons. Critical Value of F Comparisons significant at the 0.05 level are indicated by ***. pkgdes Comparison Difference Between Means Simultaneous 95% Confidence Limits *** *** *** *** *** ***

Cereal Example: CI for  i -  j - Bonferroni Bonferroni (Dunn) t Tests for cases Note: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than Tukey's for all pairwise comparisons. Critical Value of t Comparisons significant at the 0.05 level are indicated by ***. pkgdes Comparison Difference Between Means Simultaneous 95% Confidence Limits *** *** *** *** *** ***

Cereal Example: CI for  i -  j - Dunnett Dunnett's t Tests for cases Note: This test controls the Type I experimentwise error for comparisons of all treatments against a control. Alpha0.05 Error Degrees of Freedom15 Error Mean Square Critical Value of Dunnett's t Comparisons significant at the 0.05 level are indicated by ***. pkgdes Comparison Difference Between Means Simultaneous 95% Confidence Limits *** ***

Cereal Example: CI for  i -  j – Tukey (lines) Critical Value of Studentized Range Minimum Significant Difference Harmonic Mean of Cell Sizes Note:Cell sizes are not equal. Means with the same letter are not significantly different. Tukey GroupingMeanNpkgdes A B B B B B

Cereal Example: Contrasts proc glm data=cereal; class pkgdes; model cases = pkgdes; contrast '(u1+u2)/2-(u3+u4)/2' pkgdes ; estimate '(u1+u2)/2-(u3+u4)/2' pkgdes ; run; ParameterEstimateStandard Errort ValuePr > |t| (u1+u2)/2-(u3+u4)/ <.0001 ContrastDFContrast SSMean SquareF ValuePr > F (u1+u2)/2-(u3+u4)/ <.0001

Cereal Example: Multiple Contrasts proc glm data=cereal; class pkgdes; model cases = pkgdes; contrast 'u1-(u2+u3+u4)/3' pkgdes ; estimate 'u1-(u2+u3+u4)/3' pkgdes /divisor=3; contrast 'u2=u3=u4' pkgdes , pkgdes ; run; ContrastDFContrast SSMean SquareF ValuePr > F u1-(u2+u3+u4)/ u2=u3=u <.0001 ParameterEstimateStandard Errort ValuePr > |t| u1-(u2+u3+u4)/

Training Example: (nknw742.sas) Y = number of acceptable pieces X = hours of training (6 hrs, 8 hrs, 10 hrs, 12 hrs) n = 7

Training Example: input data training; infile 'I:\My Documents\STAT 512\CH17TA06.DAT'; input product trainhrs; proc print data=training; run; data training; set training; hrs=2*trainhrs+4; hrs2=hrs*hrs; proc print data=training; run; Obsproducttrainhrshrshrs

Training Example: ANOVA proc glm data=training; class trainhrs; model product=hrs trainhrs / solution; run; ParameterEstimateStandard Errort ValuePr > |t| Intercept B <.0001 hrs B trainhrs B trainhrs B trainhrs B... trainhrs B...

Training Example: ANOVA (cont) SourceDFSum of SquaresMean SquareF ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEproduct Mean SourceDFType I SSMean SquareF ValuePr > F hrs <.0001 trainhrs

Training Example: Scatterplot Title1 h=3 'product vs. hrs'; axis1 label=(h=2); axis2 label=(h=2 angle=90); symbol1 v = circle i = rl; proc gplot data=training; plot product*hrs/haxis=axis1 vaxis=axis2; run;

Training Example: Quadratic proc glm data=training; class trainhrs; model product=hrs hrs2 trainhrs; run; SourceDFSum of SquaresMean SquareF ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEproduct Mean SourceDFType I SSMean SquareF ValuePr > F hrs <.0001 hrs trainhrs

Rust Example: (nknw712.sas) Y = effectiveness of the rust inhibitors coded score, the higher means less rust X has 4 levels, the brands are A, B, C, D n = 10

Rust Example: input data rust; infile 'H:\My Documents\Stat 512\CH17TA02.DAT'; input eff brand$; proc print data=rust; run; data rust; set rust; if brand eq 1 then abrand='A'; if brand eq 2 then abrand='B'; if brand eq 3 then abrand='C'; if brand eq 4 then abrand='D'; proc print data=rust; run; proc glm data=rust; class abrand; model eff = abrand; output out=rustout r=resid p=pred; run;

Rust Example: data vs. factor title1 h=3 'Rust Example'; title2 h=2 'scatter plot (data vs factor)'; axis1 label=(h=2); axis2 label=(h=2 angle=90); symbol1 v=circle i=none c=blue; proc gplot data=rustout; plot eff*abrand/haxis=axis1 vaxis=axis2; run;

Rust Example: residuals vs. factor, predictor title2 h=2 'residual plots'; proc gplot data=rustout; plot resid*(pred abrand)/haxis=axis1 vaxis=axis2; run; brandpredicted value

Rust Example: Normality title2 'normality plots'; proc univariate data = rustout; histogram resid/normal kernel; qqplot resid / normal (mu=est sigma=est); run;

Solder Example (nknw768.sas) Y = strength of joint X = type of solder flux (there are 5 types in the study) n = 8

Solder Example: input/diagnostics data solder; infile 'I:\My Documents\Stat 512\CH18TA02.DAT'; input strength type; proc print data=solder; run; title1 h=3 'Solder Example'; title2 h=2 'scatterplot'; axis1 label=(h=2); axis2 label=(h=2 angle=90); symbol1 v=circle i=none c=red; proc gplot data=solder; plot strength*type/haxis=axis1 vaxis=axis2; run;

Solder Example: scatterplot

Solder Example: Modified Levene proc glm data=solder; class type; model strength=type; means type/hovtest=levene(type=square); run;

Solder Example: Modified Levene (cont) SourceDFSum of SquaresMean SquareF ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEstrength Mean SourceDFType I SSMean SquareF ValuePr > F type <.0001 Levene's Test for Homogeneity of strength Variance ANOVA of Squared Deviations from Group Means SourceDFSum of SquaresMean SquareF ValuePr > F type Error

Solder Example: Modified Levene (cont) Level of type N strength MeanStd Dev

Solder Example: Weighted Least Squares proc means data=solder; var strength; by type; output out=weights var=s2; run; data weights; set weights; wt=1/s2;

Solder Example: Weighted Least Squares (cont) data wsolder; merge solder weights; by type; proc print;run; proc glm data=wsolder; class type; model strength=type; weight wt; output out = weighted r = resid p = predict; run;

Solder Example: Weighted Least Squares (cont) Dependent Variable: strength Weight: wt From before: F = 41.93, R 2 = SourceDFSum of SquaresMean SquareF ValuePr > F Model <.0001 Error Corrected Total R-SquareCoeff VarRoot MSEstrength Mean

Solder Example: Weighted Least Squares (cont) data residplot; set weighted; resid1 = sqrt(wt)*resid; title2 h=2 'Weighted data - residual plot'; symbol1 v=circle i=none; proc gplot data=residplot; plot resid1*(predict type)/vref=0 haxis=axis1 vaxis=axis2; run;

Solder Example: Weighted Least Squares (cont)