options ls=72

advertisement
ANOVA in SAS
Example 12.3: In a study of workplace safety, workers were asked to rate the safety of their work
environment, and a composite score called the Safety Climate Index (SCI) was calculated. The
workers were classified according to their job category as unskilled, skilled, and supervisor.
options nodate pageno=1;
goptions colors=(none);
title 'Workplace Safety Study -- Example
12.3';
data safety;
infile 'C:\eg12_001.txt' dlm='09'x
firstobs=2;
input jobcat $ jobc SCIscore;
run;
/*Good idea to sort by groups*/
proc sort data=safety;
by jobc;
run;
proc print data=safety;
run;
Workplace Safety Study -- Example 12.3
Obs
1
2
3
...
588
589
590
jobcat
unskill
unskill
unskill
jobc
1
1
1
superv
superv
superv
3
3
3
SCIscore
76
61
56
88
81
73
/*Check normality by groups*/
-1-
1
ANOVA in SAS
symbol value = circle i=none;
proc univariate data=safety;
var SCIscore;
by jobc;
qqplot;
run;
j obc =1
j obc =3
100
100
90
80
80
S
C
I
s
c
o
r
e
S
C
I
s
c
o
r
e
60
40
70
60
20
50
0
40
- 3
- 2
- 1
0
No r ma l
1
2
3
Qu a n t i l e s
j obc =2
80
60
40
20
- 3
- 2
- 1
0
No r ma l
- 2
- 1
0
No r ma l
100
S
C
I
s
c
o
r
e
- 3
1
2
3
Qu a n t i l e s
/*Boxplots for groups*/
-2-
Qu a n t i l e s
1
2
3
ANOVA in SAS
proc boxplot data=safety;
plot SCIscore*jobc / boxstyle = skeletal;
run;
100
75
S
C
I
s
c
o
r
e
50
25
0
1
2
3
j obc
/*Code for ANOVA, must class groups*/
proc glm data=safety;
class jobc;
model SCIscore = jobc;
means jobc / bon;
run;
Workplace Safety Study -- Example 12.3
The GLM Procedure
Class Level Information
Class
jobc
Levels
3
Number of observations
-3-
Values
1 2 3
590
19
ANOVA in SAS
The GLM Procedure
Dependent Variable: SCIscore
Source
DF
Sum of
Squares
Mean Square
F Value
Pr > F
Model
2
4662.2328
2331.1164
7.14
0.0009
Error
587
191729.1977
326.6255
Corrected Total
589
196391.4305
R-Square
Coeff Var
Root MSE
SCIscore Mean
0.023739
25.30602
18.07278
71.41695
The GLM Procedure
Bonferroni (Dunn) t Tests for SCIscore
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.05
Error Degrees of Freedom
587
Error Mean Square
326.6255
Critical Value of t
2.40086
Comparisons significant at the 0.05 level are indicated by ***.
jobc
Comparison
3
3
2
2
1
1
-
2
1
3
1
3
2
Difference
Between
Means
9.301
10.086
-9.301
0.785
-10.086
-0.785
Simultaneous 95%
Confidence Limits
1.711
3.673
-16.891
-4.204
-16.498
-5.774
16.891
16.498
-1.711
5.774
-3.673
4.204
***
***
***
***
/*Note: plotting the regular data is not
very useful here*/
proc gplot data=safety;
plot SCIscore*jobc/ frame;
run;
-4-
ANOVA in SAS
S CI s c o r e
100
90
80
70
60
50
40
30
20
10
0
1
2
3
j obc
/* Using proc means we can get the group
means and output them to a dataset called
out1 */
proc means data=safety;
var SCIscore;
by jobc;
output out=out1 mean=avSCIscore;
run;
Workplace Safety Study -- Example 12.3
22
-------------------------------------------- jobc=1 --------------------------------------------The MEANS Procedure
Analysis Variable : SCIscore
N
Mean
Std Dev
Minimum
Maximum
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
448
70.4241071
18.2692649
0
100.0000000
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
-5-
ANOVA in SAS
-------------------------------------------- jobc=2 --------------------------------------------Analysis Variable : SCIscore
N
Mean
Std Dev
Minimum
Maximum
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
91
71.2087912
18.8299504
25.0000000
100.0000000
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
-------------------------------------------- jobc=3 --------------------------------------------Analysis Variable : SCIscore
N
Mean
Std Dev
Minimum
Maximum
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
51
80.5098039
14.5772049
46.0000000
100.0000000
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
-6-
ANOVA in SAS
/* Out1 looks like this*/
proc print data=out1;
run;
Workplace Safety Study -- Example 12.3
Obs
jobc
_TYPE_
_FREQ_
av
SCIscore
1
2
3
1
2
3
0
0
0
448
91
51
70.4241
71.2088
80.5098
23
/* Very useful plot, called a lines plot,
plots the means for the groups*/
symbol1 v=circle i=join;
proc gplot data=out1;
plot avSCIscore*jobc/frame;
run;
quit;
-7-
ANOVA in SAS
a v S CI s c o r e
81
80
79
78
77
76
75
74
73
72
71
70
1
2
j obc
-8-
3
Download