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.

Slides:



Advertisements
Similar presentations
Topic 32: Two-Way Mixed Effects Model. Outline Two-way mixed models Three-way mixed models.
Advertisements

CS Example: General Linear Test (cs2.sas)
Analysis of Variance Compares means to determine if the population distributions are not similar Uses means and confidence intervals much like a t-test.
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.
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.
Multi-Factor Studies Stat 701 Lecture E. Pena.
Two-Way ANOVA in SAS Multiple regression with two or
Example: Price Analysis for Diamond Rings in Singapore Variables Response Variable: Price in Singapore dollars (Y) Explanatory Variable: Weight of diamond.
Business 205. Review Exam Least Square Regression Simple Linear Regression.
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 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 7 Chapter 15: Factorial Models (15.5) Chapter 17: Random Effects Models.
1 Experimental Statistics - week 6 Chapter 15: Randomized Complete Block Design (15.3) Factorial Models (15.5)
Multiple Comparisons.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
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.
More complicated ANOVA models: two-way and repeated measures Chapter 12 Zar Chapter 11 Sokal & Rohlf First, remember your ANOVA basics……….
1 Experimental Statistics - week 10 Chapter 11: Linear Regression and Correlation.
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.
1 Experimental Statistics - week 2 Review: 2-sample t-tests paired t-tests Thursday: Meet in 15 Clements!! Bring Cody and Smith book.
7-1 The Strategy of Experimentation Every experiment involves a sequence of activities: 1.Conjecture – the original hypothesis that motivates the.
GENERAL LINEAR MODELS Oneway ANOVA, GLM Univariate (n-way ANOVA, ANCOVA)
Randomized Block Design (Kirk, chapter 7) BUSI 6480 Lecture 6.
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.
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.
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.
Topic 26: Analysis of Covariance. Outline One-way analysis of covariance –Data –Model –Inference –Diagnostics and rememdies Multifactor analysis of covariance.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
PSYC 3030 Review Session April 19, Housekeeping Exam: –April 26, 2004 (Monday) –RN 203 –Use pencil, bring calculator & eraser –Make use of your.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
By: Corey T. Williams 03 May Situation Objective.
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.
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.
1 Experimental Statistics Spring week 6 Chapter 15: Factorial Models (15.5)
Experimental Statistics - week 3
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.
7-2 Factorial Experiments A significant interaction mask the significance of main effects. Consequently, when interaction is present, the main effects.
Example 1 (knnl917.sas) Y = months survival Treatment (3 levels)
CRD, Strength of Association, Effect Size, Power, and Sample Size Calculations BUSI 6480 Lecture 4.
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.
1 Experimental Statistics - week 8 Chapter 17: Mixed Models Chapter 18: Repeated Measures.
1 Experimental Statistics - week 12 Chapter 11: Linear Regression and Correlation Chapter 12: Multiple Regression.
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)
Today: Feb 28 Reading Data from existing SAS dataset One-way ANOVA
Topic 31: Two-way Random Effects Models
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.
Experimental Statistics - Week 4 (Lab)
ANOVA Analysis of Variance.
Experimental Statistics - week 8
Presentation transcript:

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 display (regular, wide) n = 2 (n T = 12)

Bread Example: input data bread; infile 'I:\My Documents\Stat 512\CH19TA07.DAT'; input sales height width; proc print data=bread; run; title1 h=3 'Bread Sales'; axis1 label=(h=2); axis2 label=(h=2 angle=90); Obssalesheightwidth

Bread Example: input scatterplot data bread; set bread; if height eq 1 and width eq 1 then hw='1_BR'; if height eq 1 and width eq 2 then hw='2_BW'; if height eq 2 and width eq 1 then hw='3_MR'; if height eq 2 and width eq 2 then hw='4_MW'; if height eq 3 and width eq 1 then hw='5_TR'; if height eq 3 and width eq 2 then hw='6_TW'; title2 h=2 'Sales vs. treatment'; symbol1 v=circle i=none c=blue; proc gplot data=bread; plot sales*hw/haxis=axis1 vaxis=axis2; run;

Bread Example: Scatterplot

Bread Example: ANOVA proc glm data=bread; class height width; model sales=height width height*width; means height width height*width; output out=diag r=resid p=pred; run; Class Level Information ClassLevelsValues height width21 2 Number of Observations Read12 Number of Observations Used12

Bread Example: ANOVA means Level of height N sales MeanStd Dev Level of width N sales MeanStd Dev Level of height Level of width N sales MeanStd Dev

Bread Example: Means proc means data=bread; var sales; by height width; output out=avbread mean=avsales; proc print data=avbread; run; Obsheightwidth_TYPE__FREQ_avsales

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

ANOVA Table – Two Way Source of Variation dfSSMS Factor Aa – 1 Factor Bb – 1 Interaction (AB) (a–1)(b–1) Errorab(n – 1) Totalnab – 1

Bread Example: Scatterplot

Bread Example: diagnostics proc glm data=bread; class height width; model sales=height width height*width; means height width height*width; output out=diag r=resid p=pred run; title2 h=2 'residual plots'; proc gplot data=diag; plot resid * (pred height width)/vref=0 haxis=axis1 vaxis=axis2; run; title2 'normality'; proc univariate data=diag noprint; histogram resid/normal kernel; qqplot resid/normal (mu=est sigma=est); run;

Bread Example: Residual Plots

Bread Example: Normality

ANOVA Table – Two Way Source of Variation dfSSMSF Modelab - 1SSMSSM/df M MSM/MSE Errorab(n – 1)SSESSE/df E Totalnab – 1SST Factor Aa – 1SSASSA/df A MSA/MSE Factor Bb – 1SSBSSB/df B MSB/MSE Interaction (AB) (a–1)(b–1)SSABSSAB/df AB MSAB/MSE

Strategy for Analysis

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 display (regular, wide) n = 2 (n T = 12) Questions: 1)Does the height of the display affect sales? 2)Does the width of the display affect sales? 3)Does the effect on height on sales depend on width? 4)Does the effect of the width depend on height?

Bread Example: Interaction Plots title2 'Interaction Plot'; symbol1 v=square i=join c=black; symbol2 v=diamond i=join c=red; symbol3 v=circle i=join c=blue; proc gplot data=avbread; plot avsales*height=width/haxis=axis1 vaxis=axis2; plot avsales*width=height/haxis=axis1 vaxis=axis2; run;

Bread Example: Interaction Plots (cont)

Bread Example: ANOVA table proc glm data=bread; class height width; model sales=height width height*width; means height width height*width; output out=diag r=resid p=pred; run; SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total

Bread Example: ANOVA table SourceDFType I SSMean SquareF ValuePr > F height <.0001 width height*width SourceDFType III SSMean SquareF ValuePr > F height <.0001 width height*width R-SquareCoeff VarRoot MSEsales Mean

Bread Example: Interaction Plots (cont)

Bread Example: cell means model (MSE) proc glm data=bread; class height width; model sales=height width height*width; means height width height*width; output out=diag r=resid p=pred; run; SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total

Bread Example: cell means model proc glm data=bread; class height width; model sales=height width height*width; means height width height*width; output out=diag r=resid p=pred; run; Level of height Level of width N sales MeanStd Dev

Bread Example: factor effects model (overall mean) SourceDFType I SSMean SquareF ValuePr > F height <.0001 width height*width SourceDFType III SSMean SquareF ValuePr > F height <.0001 width height*width R-SquareCoeff VarRoot MSEsales Mean

Bread Example: factor effects model (overall mean) (cont) proc glm data=bread; class height width; model sales=; output out=pmu p=muhat; proc print data=pmu;run; Obssalesheightwidthhwmuhat _BR _BR _BW _BW _MR _MR _MW _MW _TR _TR _TW _TW51

Bread Example: ANOVA means A (height) Level of height N sales MeanStd Dev

Bread Example: means A (cont) proc glm data=bread; class height width; model sales=height; output out=pA p=Amean; proc print data = pA; run; ObssalesheightwidthhwAmean _BR _BR _BW _BW _MR _MR _MW _MW _TR _TR _TW _TW42

Bread Example: ANOVA means B (width) Level of width N sales MeanStd Dev

Bread Example: ANOVA means Level of height N sales MeanStd Dev Level of width N sales MeanStd Dev Level of height Level of width N sales MeanStd Dev

Bread Example: Factor Effects Model (zero-sum constraints) title2 'overall mean'; proc glm data=bread; class height width; model sales=; output out=pmu p=muhat; proc print data=pmu; run; title2 'mean for height'; proc glm data=bread; class height width; model sales=height; output out=pA p=Amean; proc print data = pA; run; title2 'mean for width'; proc glm data=bread; class height width; model sales=width; output out=pB p=Bmean; run; title2 'mean height/ width'; proc glm data=bread; class height width; model sales=height*width; output out=pAB p=ABmean; run; data parmest; merge bread pmu pA pB pAB; alpha=Amean-muhat; beta=Bmean-muhat; alphabeta=ABmean- (muhat+alpha+beta); run; proc print;run;

Bread Example: Factor Effects Model (zero-sum constraints) (cont) ObssalesheightwidthhwmuhatAmeanBmeanABmean  _BR _BR _BW _BW _MR _MR _MW _MW _TR _TR _TW _TW

Bread Example: nknw817b.sas Y = number of cases of bread sold (sales) Factor A = height of shelf display (bottom, middle, top) Factor B = width of shelf display (regular, wide) n = 2 (n T = 12 = 3 x 2)

Bread Example: SAS constraints proc glm data=bread; class height width; model sales=height width height*width/solution; means height*width; run;

Bread Example: SAS constraints (cont) ParameterEstimateStandard Errort ValuePr > |t| Intercept B <.0001 height 1B height B height B... width B width B... height*width B height*width B... height*width B height*width B... height*width B... height*width B...

Bread Example: Means Level of height Level of width N sales MeanStd Dev

Bread Example: nknw817b.sas Y = number of cases of bread sold (sales) Factor A = height of shelf display (bottom, middle, top) Factor B = width of shelf display (regular, wide) n = 2 (n T = 12 = 3 x 2)

Bread Example: Pooling *factor effects model, SAS constraints, without pooling; proc glm data=bread; class height width; model sales=height width height*width; means height/tukey lines; run; *with pooling; proc glm data=bread; class height width; model sales=height width; means height / tukey lines; run;

Bread Example: Pooling (cont) SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total SourceDFType I SSMean SquareF ValuePr > F height <.0001 width height*width SourceDFSum of SquaresMean SquareF ValuePr > F Model <.0001 Error Corrected Total SourceDFType I SSMean SquareF ValuePr > F height <.0001 width

Bread Example: Pooling (cont) Means with the same letter are not significantly different. Tukey GroupingMeanNheight A B B B Means with the same letter are not significantly different. Tukey GroupingMeanNheight A B B B

Bread Example: ANOVA table/Means SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total Level of height Level of width N sales MeanStd Dev Level of height N sales MeanStd Dev

Bread Example (nknw864.sas): contrasts and estimates proc glm data=bread; class height width; model sales=height width height*width; contrast 'middle vs others' height height*width ; estimate 'middle vs others' height height*width ; means height*width; run; ContrastDFContrast SSMean SquareF ValuePr > F middle vs others <.0001 ParameterEstimateStandard Errort ValuePr > |t| middle vs others <.0001

Bread Example (nknw864.sas): contrasts and estimates (cont) Level of height Level of width N sales MeanStd Dev

ANOVA Table – Two Way, n = 1 Source of Variation dfSSMSF Factor Aa – 1SSASSA/df A MSA/MSE Factor Bb – 1SSBSSB/df B MSB/MSE Error(a – 1)(b – 1)SSESSE/df E Totalab – 1SST

Car Insurance Example: (nknw878.sas) Y = 3-month premium for car insurance Factor A = size of the city small, medium, large Factor B = geographic region east, west

Car Insurance: input data carins; infile 'I:\My Documents\Stat 512\CH20TA02.DAT'; input premium size region; if size=1 then sizea='1_small '; if size=2 then sizea='2_medium'; if size=3 then sizea='3_large '; proc print data=carins; run; Obspremiumsizeregionsizea _small _small _medium _medium _large _large

Car Insurance: Scatterplot symbol1 v='E' i=join c=green height=1.5; symbol2 v='W' i=join c=blue height=1.5; title1 h=3 'Scatterplot of the Car Insurance'; proc gplot data=carins; plot premium*sizea=region/haxis=axis1 vaxis=axis2; run;

Car Insurance: ANOVA proc glm data=carins; class sizea region; model premium=sizea region/solution; means sizea region / tukey; output out=preds p=muhat; run; proc print data=preds; run; Class Level Information ClassLevelsValues sizea31_small 2_medium 3_large region21 2 Number of Observations Read6 Number of Observations Used6

Car Insurance: ANOVA (cont) SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total R-SquareCoeff VarRoot MSEpremium Mean SourceDFType I SSMean SquareF ValuePr > F sizea region

Car Insurance: ANOVA (cont) ParameterEstimateStandard Errort ValuePr > |t| Intercept B sizea 1_small B sizea 2_medium B sizea 3_large B... region B region B... Obspremiumsizeregionsizeamuhat _small _small _medium _medium _large _large195

Car Insurance: ANOVA (cont) Means with the same letter are not significantly different. Tukey GroupingMeanNsizea A _large A A _medium B _small Means with the same letter are not significantly different. Tukey GroupingMeanNregion A B

Car Insurance: Plots symbol1 v='E' i=join c=green size=1.5; symbol2 v='W' i=join c=blue size=1.5; title1 h=3 'Plot of the model estimates'; proc gplot data=preds; plot muhat*sizea=region/haxis=axis1 vaxis=axis2; run;

Car Insurance: plots (cont)

Car Insurance Example: (nknw884.sas) Y = 3-month premium for car insurance Factor A = size of the city small, medium, large Factor B = geographic region east, west

Car Insurance: Overall mean proc glm data=carins; model premium=; output out=overall p=muhat; proc print data=overall; Obspremiumsizeregionmuhat

Car Insurance: Factor A treatment means proc glm data=carins; class size; model premium=size; output out=meanA p=muhatA; proc print data=meanA; run; ObspremiumsizeregionmuhatA

Car Insurance: Factor B treatment means proc glm data=carins; class region; model premium=region; output out=meanB p=muhatB; proc print data=meanB; run; ObspremiumsizeregionmuhatB

Car Insurance: Combine files data estimates; merge overall meanA meanB; alpha = muhatA - muhat; beta = muhatB - muhat; atimesb = alpha*beta; proc print data=estimates; var size region alpha beta atimesb; run; Obssizeregionalphabetaatimesb

Car Insurance: Tukey test for additivity proc glm data=estimates; class size region; model premium=size region atimesb/solution; run; SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total R-SquareCoeff VarRoot MSEpremium Mean SourceDFType I SSMean SquareF ValuePr > F size region atimesb

Car Insurance: Tukey test for additivity SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total SourceDFType I SSMean SquareF ValuePr > F size region atimesb SourceDFSum of SquaresMean SquareF ValuePr > F Model Error Corrected Total SourceDFType I SSMean SquareF ValuePr > F sizea region

Car Insurance: Tukey test for additivity ParameterEstimateStandard Errort ValuePr > |t| Intercept B size B size B size B... region B region B... atimesb ParameterEstimateStandard Errort ValuePr > |t| Intercept B sizea 1_small B sizea 2_medium B sizea 3_large B... region B region B...