Docsity

Environmental Analysis and Modeling - Study Guide | IES 612, Study notes of Environmental Science

Toggle sidebar
bg1
* ..\classes\spring03\aov1way-meatbact-10feb03;
options nodate nocenter;
*--------------------------------------------------------------------;
title One-way ANOVA/ CRD example + contrasts + multiple comparisons;
title2 Bacteria in meat data;
data meat;
input conditn $ logcount @@;
ivac = (conditn=”vacuum”);
imix = (conditn=”mixed”);
iCO2 = (conditn=”CO2”);
cards;
plastic 7.66 plastic 6.98 plastic 7.80
vacuum 5.26 vacuum 5.44 vacuum 5.80
mixed 7.41 mixed 7.33 mixed 7.04
CO2 3.51 CO2 2.91 CO2 3.66
;
proc print data=meat;
run;
proc sort out=smeat; by conditn;
proc univariate plot; by conditn;
title3 summary statistics and boxplot;
var logcount;
run;
proc reg data=meat;
title3 Regression with indicators;
model logcount = ivac imix iCO2;
run;
proc glm data=meat order=data;
title3 One-way anova + contrast + model adequacy;
class conditn;
model logcount=conditn;
output out=new p=yhat r=resid;
contrast 'plastic vs. rest' conditn 3 -1 -1 -1;
estimate 'plastic vs. rest' conditn 3 -1 -1 -1;
contrast 'CO2 vs. plastic' conditn -1 0 0 1;
estimate 'CO2 vs. plastic' conditn -1 0 0 1;
contrast 'CO2 vs. vacuum' conditn 0 -1 0 1;
estimate 'CO2 vs. vacuum' conditn 0 -1 0 1;
contrast 'CO2 vs. mixed' conditn 0 0 -1 1;
estimate 'CO2 vs. mixed' conditn 0 0 -1 1;
lsmeans conditn / stderr pdiff;
means conditn / lsd clm;
means conditn / bon scheffe tukey;
means conditn / bon tukey cldiff;
run;
proc plot data=new;
plot logcount*conditn yhat*conditn='p' /overlay;
plot resid*conditn resid*yhat / vref=0;
run;
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Environmental Analysis and Modeling - Study Guide | IES 612 and more Study notes Environmental Science in PDF only on Docsity!

* ..\classes\spring03\aov1way-meatbact-10feb03;

options nodate nocenter;

title One-way ANOVA/ CRD example + contrasts + multiple comparisons;

title2 Bacteria in meat data;

data meat;

input conditn $ logcount @@;

ivac = (conditn=”vacuum”);

imix = (conditn=”mixed”);

iCO2 = (conditn=”CO2”);

cards;

plastic 7.66 plastic 6.98 plastic 7.

vacuum 5.26 vacuum 5.44 vacuum 5.

mixed 7.41 mixed 7.33 mixed 7.

CO2 3.51 CO2 2.91 CO2 3.

proc print data=meat;

run;

proc sort out=smeat; by conditn;

proc univariate plot; by conditn;

title3 summary statistics and boxplot;

var logcount;

run;

proc reg data=meat;

title3 Regression with indicators;

model logcount = ivac imix iCO2;

run;

proc glm data=meat order=data;

title3 One-way anova + contrast + model adequacy;

class conditn;

model logcount=conditn;

output out=new p=yhat r=resid;

contrast 'plastic vs. rest' conditn 3 -1 -1 -1;

estimate 'plastic vs. rest' conditn 3 -1 -1 -1;

contrast 'CO2 vs. plastic' conditn -1 0 0 1;

estimate 'CO2 vs. plastic' conditn -1 0 0 1;

contrast 'CO2 vs. vacuum' conditn 0 -1 0 1;

estimate 'CO2 vs. vacuum' conditn 0 -1 0 1;

contrast 'CO2 vs. mixed' conditn 0 0 -1 1;

estimate 'CO2 vs. mixed' conditn 0 0 -1 1;

lsmeans conditn / stderr pdiff;

means conditn / lsd clm;

means conditn / bon scheffe tukey;

means conditn / bon tukey cldiff;

run;

proc plot data=new;

plot logcountconditn yhatconditn='p' /overlay;

plot residconditn residyhat / vref=0;

run;

proc univariate plot;

var resid;

run;

* construct the normal scores - Z[(i-.375)/(n+.25)];

* note not multiplied by sqrt(mse);

proc rank data=new normal=blom out=rnew;

var resid;

ranks nscore;

* generate plot analogous to univariate's normal prob. plot;

proc plot;

plot resid*nscore;

run;

data moremeat; set meat;

count = exp(logcount);

title3 raw count data analyzed;

proc glm data=moremeat;

class conditn;

model count=conditn;

output out=mnew p=yhat r=resid;

lsmeans conditn / stderr pdiff;

* means conditn / clm bon scheffe lsd tukey snk;

proc plot data=mnew;

plot countconditn yhatconditn='p' /overlay;

plot residconditn residyhat / vref=0;

proc univariate data=mnew plot;

var resid;

proc rank data=mnew normal=blom out=rnew;

var resid;

ranks nscore;

proc plot;

plot resid*nscore;

proc reg data=meat;

title3 Regression with indicators;

model logcount = ivac imix iCO2;

run;

The REG Procedure Model: MODEL Dependent Variable: logcount Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 3 32.87280 10.95760 94.58 <. Error 8 0.92680 0. Corrected Total 11 33. Root MSE 0.34037 R-Square 0. Dependent Mean 5.90000 Adj R-Sq 0. Coeff Var 5. Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 7.48000 0.19651 38.06 <. ivac 1 -1.98000 0.27791 -7.12 <. imix 1 -0.22000 0.27791 -0.79 0. iCO2 1 -4.12000 0.27791 -14.83 <.

proc glm data=meat order=data;

title3 One-way anova + contrast + model adequacy;

class conditn;

model logcount=conditn;

output out=new p=yhat r=resid;

The GLM Procedure Class Level Information Class Levels Values conditn 4 plastic vacuum mixed CO Number of observations 1 The GLM Procedure Dependent Variable: logcount Sum of Source DF Squares Mean Square F Value Pr > F Model 3 32.87280000 10.95760000 94.58 <. Error 8 0.92680000 0. Corrected Total 11 33. R-Square Coeff Var Root MSE logcount Mean 0.972580 5.768940 0.340367 5. Source DF Type I SS Mean Square F Value Pr > F conditn 3 32.87280000 10.95760000 94.58 <. Source DF Type III SS Mean Square F Value Pr > F conditn 3 32.87280000 10.95760000 94.58 <. Contrast DF Contrast SS Mean Square F Value Pr > F plastic vs. rest 1 9.98560000 9.98560000 86.19 <. CO2 vs. plastic 1 25.46160000 25.46160000 219.78 <. CO2 vs. vacuum 1 6.86940000 6.86940000 59.30 <.

CO2 vs. mixed 1 22.81500000 22.81500000 196.94 <.

contrast 'plastic vs. rest' conditn 3 -1 -1 -1;

estimate 'plastic vs. rest' conditn 3 -1 -1 -1;

contrast 'CO2 vs. plastic' conditn -1 0 0 1;

estimate 'CO2 vs. plastic' conditn -1 0 0 1;

contrast 'CO2 vs. vacuum' conditn 0 -1 0 1;

estimate 'CO2 vs. vacuum' conditn 0 -1 0 1;

contrast 'CO2 vs. mixed' conditn 0 0 -1 1;

estimate 'CO2 vs. mixed' conditn 0 0 -1 1;

Dependent Variable: logcount Standard Parameter Estimate Error t Value Pr > |t| plastic vs. rest 6.32000000 0.68073490 9.28 <. CO2 vs. plastic -4.12000000 0.27790886 -14.83 <. CO2 vs. vacuum -2.14000000 0.27790886 -7.70 <. CO2 vs. mixed -3.90000000 0.27790886 -14.03 <.

lsmeans conditn / stderr pdiff;

The GLM Procedure Least Squares Means logcount Standard LSMEAN conditn LSMEAN Error Pr > |t| Number plastic 7.48000000 0.19651124 <.0001 1 vacuum 5.50000000 0.19651124 <.0001 2 mixed 7.26000000 0.19651124 <.0001 3 CO2 3.36000000 0.19651124 <.0001 4 Least Squares Means for effect conditn Pr > |t| for H0: LSMean(i)=LSMean(j) Dependent Variable: logcount i/j 1 2 3 4 1 <.0001 0.4514 <. 2 <.0001 0.0002 <. 3 0.4514 0.0002 <. 4 <.0001 <.0001 <. NOTE: To ensure overall protection level, only probabilities associated with pre-planned comparisons should be used

C 3.3600 3 CO

Scheffe's Test for logcount

NOTE: This test controls the Type I experimentwise error rate. Alpha 0. Error Degrees of Freedom 8 Error Mean Square 0. Critical Value of F 4. Minimum Significant Difference 0. Means with the same letter are not significantly different. Mean N conditn A 7.4800 3 plastic A A 7.2600 3 mixed B 5.5000 3 vacuum C 3.3600 3 CO

means conditn / bon tukey cldiff;

Tukey's Studentized Range (HSD) Test for logcount

NOTE: This test controls the Type I experimentwise error rate. Alpha 0. Error Degrees of Freedom 8 Error Mean Square 0. Critical Value of Studentized Range 4. Minimum Significant Difference 0. Comparisons significant at the 0.05 level are indicated by ***. Difference conditn Between Simultaneous 95% Comparison Means Confidence Limits plastic - mixed 0.2200 -0.6700 1. plastic - vacuum 1.9800 1.0900 2.8700 *** plastic - CO2 4.1200 3.2300 5.0100 *** mixed - plastic -0.2200 -1.1100 0. mixed - vacuum 1.7600 0.8700 2.6500 *** mixed - CO2 3.9000 3.0100 4.7900 *** vacuum - plastic -1.9800 -2.8700 -1.0900 *** vacuum - mixed -1.7600 -2.6500 -0.8700 *** vacuum - CO2 2.1400 1.2500 3.0300 *** CO2 - plastic -4.1200 -5.0100 -3.2300 *** CO2 - mixed -3.9000 -4.7900 -3.0100 *** CO2 - vacuum -2.1400 -3.0300 -1.2500 **

Bonferroni (Dunn) t Tests for logcount

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. Alpha 0. Error Degrees of Freedom 8 Error Mean Square 0. Critical Value of t 3. Minimum Significant Difference 0. Comparisons significant at the 0.05 level are indicated by ***. Difference conditn Between Simultaneous 95% Comparison Means Confidence Limits plastic - mixed 0.2200 -0.7468 1. plastic - vacuum 1.9800 1.0132 2.9468 *** plastic - CO2 4.1200 3.1532 5.0868 *** mixed - plastic -0.2200 -1.1868 0. mixed - vacuum 1.7600 0.7932 2.7268 *** mixed - CO2 3.9000 2.9332 4.8668 *** vacuum - plastic -1.9800 -2.9468 -1.0132 *** vacuum - mixed -1.7600 -2.7268 -0.7932 *** vacuum - CO2 2.1400 1.1732 3.1068 *** CO2 - plastic -4.1200 -5.0868 -3.1532 *** CO2 - mixed -3.9000 -4.8668 -2.9332 *** CO2 - vacuum -2.1400 -3.1068 -1.1732 ***

options ls=70;

proc plot data=new;

plot logcountconditn yhatconditn='p' /overlay;

plot residconditn residyhat / vref=0;

run;

Plot of resid*conditn. Legend: A = 1 obs, B = 2 obs, etc. resid ‚ ‚

Plot of resid*yhat. Legend: A = 1 obs, B = 2 obs, etc. resid ‚ ‚ 0.4 ˆ ‚ ‚ A A A ‚ ‚ 0.2 ˆ A ‚ A A ‚ ‚ A ‚ 0.0 ˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ‚ A ‚ ‚ ‚ -0.2 ˆ A ‚ A ‚ ‚ ‚ -0.4 ˆ ‚ A ‚ A ‚ ‚ -0.6 ˆ ‚ Šƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒ 3 4 5 6 7 8 yhat

proc univariate plot;

var resid;

* construct the normal scores - Z[(i-.375)/(n+.25)];

* note not multiplied by sqrt(mse);

proc rank data=new normal=blom out=rnew;

var resid;

ranks nscore;

* generate plot analogous to univariate's normal prob. plot;

proc plot;

plot resid*nscore;

Plot of resid*nscore. Legend: A = 1 obs, B = 2 obs, etc. resid ‚ ‚ 0.4 ˆ ‚ ‚ B A ‚ ‚ 0.2 ˆ A ‚ A A ‚ ‚ A ‚ 0.0 ˆ ‚ A ‚ ‚ ‚ -0.2 ˆ A ‚ A ‚ ‚ ‚ -0.4 ˆ ‚ A ‚ A ‚ ‚ -0.6 ˆ ‚ Šƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒ -2 -1 0 1 2 Rank for Variable resid

data moremeat; set meat;

count = exp(logcount);

title3 raw count data analyzed;

proc glm data=moremeat;

class conditn;

model count=conditn;

output out=mnew p=yhat r=resid;

lsmeans conditn / stderr pdiff;

* means conditn / clm bon scheffe lsd tukey snk;

run;

The GLM Procedure Dependent Variable: count Sum of Source DF Squares Mean Square F Value Pr > F Model 3 7282652.348 2427550.783 16.56 0. Error 8 1172820.616 146602. Corrected Total 11 8455472. R-Square Coeff Var Root MSE count Mean 0.861294 42.54159 382.8872 900. Source DF Type I SS Mean Square F Value Pr > F conditn 3 7282652.348 2427550.783 16.56 0. Source DF Type III SS Mean Square F Value Pr > F conditn 3 7282652.348 2427550.783 16.56 0.

Plot of resid*yhat. Legend: A = 1 obs, B = 2 obs, etc. resid ‚ 1000 ˆ ‚ ‚ ‚ ‚ ‚ ‚ A 500 ˆ ‚ ‚ ‚ ‚ A A ‚ ‚ A A 0 ˆƒƒƒCƒƒƒƒAƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ‚ A ‚ ‚ ‚ A ‚ ‚ -500 ˆ ‚ ‚ ‚ ‚ A ‚ ‚ -1000 ˆ Šƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒ 0 500 1000 1500 2000 yhat

proc rank data=mnew normal=blom out=rnew;

var resid;

ranks nscore;

proc plot;

plot resid*nscore;

run;

Plot of resid*nscore. Legend: A = 1 obs, B = 2 obs, etc. resid ‚ 1000 ˆ ‚ ‚ ‚ ‚ ‚ ‚ A 500 ˆ ‚ ‚ ‚ ‚ A A ‚ ‚ A A 0 ˆ A A A A ‚ A ‚ ‚ ‚ A ‚ ‚ -500 ˆ ‚ ‚ ‚ ‚ A ‚ ‚ -1000 ˆ Šƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒ -2 -1 0 1 2 Rank for Variable resid