R version ( ) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN

Similar documents
Math Treibergs. Peanut Oil Data: 2 5 Factorial design with 1/2 Replication. Name: Example April 22, Data File Used in this Analysis:

R version ( ) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN

Straw Example: Randomized Block ANOVA

Pumpkin Example: Flaws in Diagnostics: Correcting Models

Spectrophotometer Example: One-Factor Random Effects ANOVA

Math Treibergs. Turbine Blade Example: 2 6 Factorial Name: Example Experiment with 1 4 Replication February 22, 2016

Beam Example: Identifying Influential Observations using the Hat Matrix

Natural language support but running in an English locale

(1) (AE) (BE) + (AB) + (CE) (AC) (BE) + (ABCE) +(DE) (AD) (BD) + (ABDE) + (CD) (ACDE) (BCDE) + (ABCD)

Answer Keys to Homework#10

Assignment 9 Answer Keys

Gas Transport Example: Confidence Intervals in the Wilcoxon Rank-Sum Test

R version ( ) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN

Suppose we needed four batches of formaldehyde, and coulddoonly4runsperbatch. Thisisthena2 4 factorial in 2 2 blocks.

Carapace Example: Confidence Intervals in the Wilcoxon Sign-rank Test

Munitions Example: Negative Binomial to Predict Number of Accidents

Horse Kick Example: Chi-Squared Test for Goodness of Fit with Unknown Parameters

R version ( ) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN

f Simulation Example: Simulating p-values of Two Sample Variance Test. Name: Example June 26, 2011 Math Treibergs

Fractional Factorial Designs

19. Blocking & confounding

Problem 4.4 and 6.16 of Devore discuss the Rayleigh Distribution, whose pdf is x, x > 0; x x 0. x 2 f(x; θ) dx x=0. pe p dp.

Basic Data Analysis. Stephen Turnbull Business Administration and Public Policy Lecture 9: June 6, Abstract. Regression and R.

ST3232: Design and Analysis of Experiments

Chapter 11: Factorial Designs

X = S 2 = 1 n. X i. i=1

2 k, 2 k r and 2 k-p Factorial Designs

Biostatistics 380 Multiple Regression 1. Multiple Regression

Fractional Factorial Designs

Variance Decomposition in Regression James M. Murray, Ph.D. University of Wisconsin - La Crosse Updated: October 04, 2017

MODELS WITHOUT AN INTERCEPT

(U 338-E) 2018 Nuclear Decommissioning Cost Triennial Proceeding A Workpapers

Amount of Weight Gained. Regained 5 lb or Less Regained More Than 5 lb Total. In Person Online Newsletter

CS 5014: Research Methods in Computer Science

23. Fractional factorials - introduction

Variance Decomposition and Goodness of Fit

Nested 2-Way ANOVA as Linear Models - Unbalanced Example

R version ( ) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN

> modlyq <- lm(ly poly(x,2,raw=true)) > summary(modlyq) Call: lm(formula = ly poly(x, 2, raw = TRUE))

Unreplicated 2 k Factorial Designs

R Output for Linear Models using functions lm(), gls() & glm()

The One-Quarter Fraction

Multiple Predictor Variables: ANOVA

CS 5014: Research Methods in Computer Science. Experimental Design. Potential Pitfalls. One-Factor (Again) Clifford A. Shaffer.

Figure 1: The fitted line using the shipment route-number of ampules data. STAT5044: Regression and ANOVA The Solution of Homework #2 Inyoung Kim

20g g g Analyze the residuals from this experiment and comment on the model adequacy.

CSCI 688 Homework 6. Megan Rose Bryant Department of Mathematics William and Mary

ST430 Exam 2 Solutions

Inference for Regression

Stat 401B Final Exam Fall 2015

ST430 Exam 1 with Answers

The 2 k Factorial Design. Dr. Mohammad Abuhaiba 1

Stat 401B Exam 2 Fall 2015

Psychology 405: Psychometric Theory

Statistics GIDP Ph.D. Qualifying Exam Methodology May 26 9:00am-1:00pm

" M A #M B. Standard deviation of the population (Greek lowercase letter sigma) σ 2

Statistics GIDP Ph.D. Qualifying Exam Methodology May 26 9:00am-1:00pm

Recall that a measure of fit is the sum of squared residuals: where. The F-test statistic may be written as:

Biostatistics for physicists fall Correlation Linear regression Analysis of variance

Multiple Regression: Example

Homework 9 Sample Solution

ANOVA Randomized Block Design

General Linear Statistical Models - Part III

Ch 2: Simple Linear Regression

ANOVA (Analysis of Variance) output RLS 11/20/2016

Chapter 13 Experiments with Random Factors Solutions

Lecture 10. Factorial experiments (2-way ANOVA etc)

Simple Linear Regression

Stat 412/512 TWO WAY ANOVA. Charlotte Wickham. stat512.cwick.co.nz. Feb

Stat 411/511 ESTIMATING THE SLOPE AND INTERCEPT. Charlotte Wickham. stat511.cwick.co.nz. Nov

Design and Analysis of

Reference: Chapter 6 of Montgomery(8e) Maghsoodloo

STAT 572 Assignment 5 - Answers Due: March 2, 2007

Regression Analysis lab 3. 1 Multiple linear regression. 1.1 Import data. 1.2 Scatterplot matrix

Lecture 10: 2 k Factorial Design Montgomery: Chapter 6

Increasing precision by partitioning the error sum of squares: Blocking: SSE (CRD) à SSB + SSE (RCBD) Contrasts: SST à (t 1) orthogonal contrasts

Chapter 4. Regression Models. Learning Objectives

1 Use of indicator random variables. (Chapter 8)

MATH 644: Regression Analysis Methods

Section Least Squares Regression

Tests of Linear Restrictions

NC Births, ANOVA & F-tests

The Statistical Sleuth in R: Chapter 5

MS&E 226: Small Data

Unit 9: Confounding and Fractional Factorial Designs

Statistics and Quantitative Analysis U4320

Chapter 14 Student Lecture Notes Department of Quantitative Methods & Information Systems. Business Statistics. Chapter 14 Multiple Regression

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

USE OF COMPUTER EXPERIMENTS TO STUDY THE QUALITATIVE BEHAVIOR OF SOLUTIONS OF SECOND ORDER NEUTRAL DIFFERENTIAL EQUATIONS

Multiple Regression. Inference for Multiple Regression and A Case Study. IPS Chapters 11.1 and W.H. Freeman and Company

Statistiek II. John Nerbonne. March 17, Dept of Information Science incl. important reworkings by Harmut Fitz

Chapter 10 Exercise 10.1

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

Geometry Problem Solving Drill 08: Congruent Triangles

Factorial and Unbalanced Analysis of Variance

Extensions of One-Way ANOVA.

1.) Fit the full model, i.e., allow for separate regression lines (different slopes and intercepts) for each species

Math 2311 Written Homework 6 (Sections )

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

Linear Model Specification in R

Transcription:

Math 3080 1. Treibergs Bread Wrapper Data: 2 4 Incomplete Block Design. Name: Example April 26, 2010 Data File Used in this Analysis: # Math 3080-1 Bread Wrapper Data April 23, 2010 # Treibergs # # From Walpole, Myers, Myers, Ye "Probability and Statistics for # engineers and Scientists. 7th ed.," Prentice Hall 2002 # # Taken from a VPI study of some more bread wrapper stock. # This time, an incomplete block design was run. Four factors, A,B,C,D, # are studied that affect strength Y. The runs were done by two operators # who each perform different treatment combinations corresponding # to blocks that correspond to the defining contrast ABC. # "Comb" "Operator" "Strength" "A" "B" "C" "D" (1) 1 18.8-1 -1-1 -1 ab 1 16.5 1 1-1 -1 ac 1 17.8 1-1 1-1 bc 1 17.3-1 1 1-1 d 1 13.5-1 -1-1 1 abd 1 17.6 1 1-1 1 acd 1 18.5 1-1 1 1 bcd 1 17.6-1 1 1 1 a 2 14.7 1-1 -1-1 b 2 15.1-1 1-1 -1 c 2 14.7-1 -1 1-1 abc 2 19.0 1 1 1-1 ad 2 16.9 1-1 -1 1 bd 2 17.5-1 1-1 1 cd 2 18.2-1 -1 1 1 abcd 2 20.1 1 1 1 1 R Session: R version 2.10.1 (2009-12-14) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type license() or licence() for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type contributors() for more information and citation() on how to cite R or R packages in publications. 1

Type demo() for some demos, help() for on-line help, or help.start() for an HTML browser interface to help. Type q() to quit R. [R.app GUI 1.31 (5537) powerpc-apple-darwin9.8.0] > tt <- read.table("m3081datawrapper.txt",header=true) > attach(tt) > tt Comb Operator Strength A B C D 1 (1) 1 18.8-1 -1-1 -1 2 ab 1 16.5 1 1-1 -1 3 ac 1 17.8 1-1 1-1 4 bc 1 17.3-1 1 1-1 5 d 1 13.5-1 -1-1 1 6 abd 1 17.6 1 1-1 1 7 acd 1 18.5 1-1 1 1 8 bcd 1 17.6-1 1 1 1 9 a 2 14.7 1-1 -1-1 10 b 2 15.1-1 1-1 -1 11 c 2 14.7-1 -1 1-1 12 abc 2 19.0 1 1 1-1 13 ad 2 16.9 1-1 -1 1 14 bd 2 17.5-1 1-1 1 15 cd 2 18.2-1 -1 1 1 16 abcd 2 20.1 1 1 1 1 >#=======================================RUN ANOVA============== > f1<-aov(strength~a*b*c*d);anova(f1) Analysis of Variance Table Response: Strength Df Sum Sq Mean Sq F value Pr(>F) A 1 4.4100 4.4100 B 1 3.6100 3.6100 C 1 9.9225 9.9225 D 1 2.2500 2.2500 A:B 1 0.5625 0.5625 A:C 1 2.8900 2.8900 B:C 1 0.2500 0.2500 A:D 1 1.1025 1.1025 B:D 1 0.9025 0.9025 C:D 1 1.6900 1.6900 A:B:C 1 0.1225 0.1225 A:B:D 1 1.6900 1.6900 A:C:D 1 4.2025 4.2025 B:C:D 1 5.5225 5.5225 A:B:C:D 1 9.6100 9.6100 Residuals 0 0.0000 Warning message: In anova.lm(f1) : ANOVA F-tests on an essentially perfect fit are unreliable 2

>#====================RUN LINEAR MODEL============================= > f2 <- aov(strength~a+b+c+d+operator);anova(f2) Analysis of Variance Table Response: Strength Df Sum Sq Mean Sq F value Pr(>F) A 1 4.4100 4.4100 1.5516 0.24130 B 1 3.6100 3.6100 1.2701 0.28606 C 1 9.9225 9.9225 3.4911 0.09124. D 1 2.2500 2.2500 0.7916 0.39451 Operator 1 0.1225 0.1225 0.0431 0.83970 Residuals 10 28.4225 2.8422 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1 > Op<-factor(Operator);OA<-factor(A);OB<-factor(B);OC<-factor(C);OD<-factor(D) >#==================USUAL DIAGNOSTIC PLOTS============================== > layout(matrix(1:2,ncol=2)) > plot.design(data.frame(oa,ob,oc,od,op,strength)) > interaction.plot(c,a,strength) > layout(matrix(1:4,ncol=2)) > plot(strength~c,main="bread Wrapper Data") > plot(rstandard(f2)~fitted(f2),xlab="predicted Values", ylab="standard. Resid.", ylim=max(abs(rstandard(f2)))*c(-1,1)) > abline(h=c(0,-2,2),lty=c(2,3,3)) > plot(fitted(f2)~strength,ylab="y hat"); abline(0,1) > qqnorm(rstandard(f2), ylab="standard. Resid.", ylim=max(abs(rstandard(f2)))*c(-1,1)) > abline(h=c(0,-2,2),lty=c(2,3,3)); abline(0,1) > shapiro.test(resid(f2)) Shapiro-Wilk normality test data: resid(f2) W = 0.9195, p-value = 0.1658 3

>#===================TABLE OF CONTRASTS====================================== > AB<-A*B;AD<-A*D;AC<-A*C;BC<-B*C;BD<-B*D;CD<-C*D > ABC<-AB*C;ABD<-AB*D;ACD<-AC*D;BCD<-BC*D;ABCD<-AB*CD > One<-rep(1,times=16) > matrix(c(one,a,b,ab,c,ac,bc,abc,d,ad,bd,abd,cd,acd,bcd,abcd),ncol=16, dimnames=list(comb,comb)) (1) ab ac bc d abd acd bcd a b c abc ad bd cd abcd (1) 1-1 -1 1-1 1 1-1 -1 1 1-1 1-1 -1 1 ab 1 1 1 1-1 -1-1 -1-1 -1-1 -1 1 1 1 1 ac 1 1-1 -1 1 1-1 -1-1 -1 1 1-1 -1 1 1 bc 1-1 1-1 1-1 1-1 -1 1-1 1-1 1-1 1 d 1-1 -1 1-1 1 1-1 1-1 -1 1-1 1 1-1 abd 1 1 1 1-1 -1-1 -1 1 1 1 1-1 -1-1 -1 acd 1 1-1 -1 1 1-1 -1 1 1-1 -1 1 1-1 -1 bcd 1-1 1-1 1-1 1-1 1-1 1-1 1-1 1-1 a 1 1-1 -1-1 -1 1 1-1 -1 1 1 1 1-1 -1 b 1-1 1-1 -1 1-1 1-1 1-1 1 1-1 1-1 c 1-1 -1 1 1-1 -1 1-1 1 1-1 -1 1 1-1 abc 1 1 1 1 1 1 1 1-1 -1-1 -1-1 -1-1 -1 ad 1 1-1 -1-1 -1 1 1 1 1-1 -1-1 -1 1 1 bd 1-1 1-1 -1 1-1 1 1-1 1-1 -1 1-1 1 cd 1-1 -1 1 1-1 -1 1 1-1 -1 1 1-1 -1 1 abcd 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 >#=============================DEFINING CONTRAST IS ABC THIS TIME============ > matrix(c(operator,abc),ncol=2) [,1] [,2] [1,] 1-1 [2,] 1-1 [3,] 1-1 [4,] 1-1 [5,] 1-1 [6,] 1-1 [7,] 1-1 [8,] 1-1 [9,] 2 1 [10,] 2 1 [11,] 2 1 [12,] 2 1 [13,] 2 1 [14,] 2 1 [15,] 2 1 [16,] 2 1 4

>#============================CONTRASTS====================================== > SST<-sum(Strength*Strength)-(sum(Strength)^2)/16;SST [1] 48.7375 > LA<-sum(A*Strength) > LB<-sum(B*Strength) > LC<-sum(C*Strength) > LD<-sum(D*Strength) > LABC<-sum(ABC*Strength) >#===========================BUILD ANOVA TABLE "BY HAND"===================== > DF <- c(1,1,1,1,1,10,15) > SSA<-LA*LA/16;SSB<-LB*LB/16;SSC<-LC*LC/16;SSD<-LD*LD/16 > SSBlock <- LABC*LABC/16 > SSE<-SST-SSA-SSB-SSC-SSD-SSBlock > SS<-c(SSA,SSB,SSC,SSD,SSBlock,SSE,SST) > MSE<-SSE/10 > MS<-c(SSA,SSB,SSC,SSD,SSBlock,MSE,-1) > F<-MS/MSE;F[7]<--1;F[6]<--1 > P<-pf(F,1,10,lower.tail=FALSE) > matrix(c(df,ss,ms,f,p),ncol=5, dimnames=list(c("a","b","c","d","block","error","total"), c("df","ss","ms","f","p(>f)"))) DF SS MS F P(>F) A 1 4.4100 4.41000 1.55158765 0.24129587 B 1 3.6100 3.61000 1.27012050 0.28606043 C 1 9.9225 9.92250 3.49107221 0.09124138 D 1 2.2500 2.25000 0.79162635 0.39450928 Block 1 0.1225 0.12250 0.04309966 0.83970459 Error 10 28.4225 2.84225-1.00000000 1.00000000 Total 15 48.7375-1.00000-1.00000000 1.00000000 >========================================COMPARE TO=========================== > anova(f2) Analysis of Variance Table Response: Strength Df Sum Sq Mean Sq F value Pr(>F) A 1 4.4100 4.4100 1.5516 0.24130 B 1 3.6100 3.6100 1.2701 0.28606 C 1 9.9225 9.9225 3.4911 0.09124. D 1 2.2500 2.2500 0.7916 0.39451 Operator 1 0.1225 0.1225 0.0431 0.83970 Residuals 10 28.4225 2.8422 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1 5

>#====================CONTRASTS AND PCT. VARIABILITY FROM EACH FACTOR=============== > EFF<-c(LA/16,LB/16,LC/16,LD/16,LABC/16) > PCT<-c(SSA,SSB,SSC,SSD,SSBlock)/SST > matrix(c(eff,pct),ncol=2, dimnames=list(c("a","b","c","d","block"), c("effect"," Fraction Variability"))) Effect Fraction Variability A 0.5250 0.090484740 B 0.4750 0.074070274 C 0.7875 0.203590664 D 0.3750 0.046165684 Block -0.0875 0.002513465 >#=================R SQ, FRACTION OF VARIABILITY ACCOUNTED FOR BY MODEL============ > 1-SSE/SST [1] 0.4168248 >#==============COMPARE TO SAME MODEL RUN AS REGRESSION============================ > f3<-lm(strength~a+b+c+d+operator);summary(f3);anova(f3) Call: lm(formula = Strength ~ A + B + C + D + Operator) Residuals: Min 1Q Median 3Q Max -2.2875-0.7125-0.0500 0.6500 3.7625 Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) 17.3750 1.3328 13.036 1.34e-07 *** A 0.5250 0.4215 1.246 0.2413 B 0.4750 0.4215 1.127 0.2861 C 0.7875 0.4215 1.868 0.0912. D 0.3750 0.4215 0.890 0.3945 Operator -0.1750 0.8429-0.208 0.8397 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1 Residual standard error: 1.686 on 10 degrees of freedom Multiple R-squared: 0.4168,Adjusted R-squared: 0.1252 F-statistic: 1.43 on 5 and 10 DF, p-value: 0.2943 Analysis of Variance Table Response: Strength Df Sum Sq Mean Sq F value Pr(>F) A 1 4.4100 4.4100 1.5516 0.24130 B 1 3.6100 3.6100 1.2701 0.28606 C 1 9.9225 9.9225 3.4911 0.09124. D 1 2.2500 2.2500 0.7916 0.39451 Operator 1 0.1225 0.1225 0.0431 0.83970 Residuals 10 28.4225 2.8422 6

> model.tables(f2,"means") Tables of means Grand mean 17.1125 A A -1 1 16.587 17.637 B B -1 1 16.637 17.587 C C -1 1 16.325 17.900 D D -1 1 16.737 17.487 Operator Operator 1 2 17.200 17.025 >#====================FACTORS IN MAIN BLOCK GIVEN BY DEFINING CONTRAST ABC======= > I<-order(ABC) > Comb[I[1:8]] [1] (1) ab ac bc d abd acd bcd >#====================FACTORS IN OTHER BLOCK===================================== > Comb[I[9:16]] [1] a b c abc ad bd cd abcd 7

8

9