Lab 3_2014_wR.doc

advertisement

Lab 3 2014:

One way ANOVA In SAS

The following is a typical data step for putting in data: data filterdata; input filter $ flowrate; cards ;

A 8.41

A 8.19

A 8.59

A 7.97

B 7.43

B 6.97

B 7.49

B 7.03

C 7.69

C 7.22

C 7.41

C 7.84

D 7.85

D 8.31

D 8.49

D 7.75

E 8.77

E 8.82

E 8.41

E 8.36

F 6.87

F 7.25

F 7.41

F 6.87

; run ;

Finding the means: proc means data= filterdata; class filter; var flowrate; run ;

PROC GLM (for general Linear model is a powerful procedure and allows us to do ANOVA and multiple comparison. It also allows us save our residuals for plotting. proc glm data= filterdata; class filter; model flowrate=filter; lsmeans filter / alpha = 0.05

pdiff cl ;

/*All pairwise tests and confidence intervals using Tukey's method*/

lsmeans filter / alpha = 0.05

adjust =tukey pdiff cl ;

/*All pairwise tests and confidence intervals using Scheffe's method and test for equal varaince*/ lsmeans filter / alpha = 0.05

adjust =scheffe pdiff cl ;

/*All pairwise tests and confidence intervals using Bonferroni's method and test for equal varaince*/ means filter / hovtest =bf alpha = 0.05

bon cldiff ;

/*Compare all treatments to the control treatment labeled F*/ means filter / alpha = 0.05

dunnett ( 'F' ); output out =new p=predict r=resid; run ;

/*plot your residual vs predicted*/ proc gplot data =new; plot resid*predict; run ;

/*getting histograms and normal probability plot*/ proc capability data =new normaltest ; var resid; histogram ; qqplot ; run ;

Coding in R: (run ANOVA, do follow-up and diagnostics)

> mydata<-read.table("lab2_onewayanova_R.csv",header=TRUE,sep=",")

> aggregate(resp~fact,mydata,mean)

> rslt=aov(resp~fact,data=mydata)

> summary(rslt)

> TukeyHSD(rslt)

> pairwise.t.test(mydata$resp, mydata$fact, p.adj = "bon")

> pairwise.t.test(mydata$resp, mydata$fact, p.adj = "none")

> rslt2=lm(resp~fact,data=mydata)

> summary(rslt2)

> rslt3=data.frame(mydata,fit=fitted(rslt2),res=residuals(rslt2))

> plot(rslt3$fit,rslt3$res)

> abline(h=0)

> npp=qqnorm(rslt3$res)

> abline(lm(npp$y~npp$x))

>library(lmtest)

> bptest(res~fact,data=rslt3)

> dwtest(res~fact,data=rslt3)

> shapiro.test(rslt3$res)

Lab Exercise: Do the following problem using SAS:

Some investigators think that the concentration (mg/ml) of a particular antigen in supernatant fluids could be related to the onset of meningitis in infants. The accompanying data is typical of that given in plots appearing in the paper “Type-Specific Capsular Antigen is Associated with virulence in Late-Onset Group B Streptococcal Type III

Disease” (Infection and Immunity(1984):124-129)

Asymptomatic infants 1.56 1.06 .87 1.39 .71 .87 .95 1.51

1.89 1.07

.88 1.67

1.72

2.57

Infants with late onset sephis

Infants with late onset meningitis

1.51 1.78

1.21 1.34

1.45 1.13 1.87

1.95 2.00 2.27

Is there a difference among the groups?

Provide the ANOVA table?

Use Tukey’s and Fisher’s method to discuss difference among the three groups.

Discuss assumptions and violations of such.

Download