data one; input site count; cards; <data here>

advertisement
data one;
input site count;
cards;
<data here>
;
proc glm data=one;
class site;
model count=site;
output out=two residual=ehat predicted=yhat;
run;
data two; set two;
sqrtabsehat=sqrt(abs(ehat));
run;
proc univariate plot data=two;
var ehat;
run;
proc plot data=two;
plot ehat*yhat;
plot sqrtabsehat*yhat;
run;
data three; set one;
y=log(count+1/6);
run;
proc glm data=three;
class site;
model y=site;
output out=four residual=ehat predicted=yhat;
run;
data four; set four;
sqrtabsehat=sqrt(abs(ehat));
run;
proc univariate plot data=four;
var ehat;
run;
proc plot data=four;
plot ehat*yhat;
plot sqrtabsehat*yhat;
run;
1
Histogram
390+*
.
.*
.
.
.
.*
.
.
.
.*
.
.
.*
.
.*
.**
.**
.***
.********
.********************************
.********
.**********
-70+******
----+----+----+----+----+----+-* may represent up to 2 counts
Variable:
#
1
Boxplot
*
2
*
1
*
2
*
1
*
2
4
4
5
16
64
16
20
12
0
0
0
|
+--+--+
*-----*
+-----+
|
|
ehat
Normal Probability Plot
390+
*
|
|
* *
|
|
|
|
*
|
|
|
|
**
|
+++
|
+++
|
*++
|
++
|
+++ *
|
+++ **
|
+++
**
|
+++
**
|
+++
****
|
*************
|
****++
|
*******++
-70+* * ******** +++
+----+----+----+----+----+----+----+----+----+----+
-2
-1
0
+1
+2
2
Plot of ehat*yhat.
Legend: A = 1 obs, B = 2 obs, etc.
ehat ‚
393.28 ˆ
A
‚
‚
‚
A
‚
A
‚
327.28 ˆ
‚
‚
‚
‚
‚
261.28 ˆ
A
‚
‚
‚
‚
‚
195.28 ˆ
A
A
‚
‚
‚
‚
‚
A
129.28 ˆ
‚
‚
‚
‚
A A
‚
A
A
B
63.28 ˆ
‚
A
A
A
A
‚
A
‚
A
A
‚
BC
A
‚
AB D
A
-2.72 ˆ
MJ B
B
A
‚
HI P
D
A
B
‚
E
A
‚
G
C
‚
O
A
‚
G
-68.72 ˆ
I
Šƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒ
0
10
20
30
40
50
60
70
yhat
3
Plot of sqrtabsehat*yhat.
Legend: A = 1 obs, B = 2 obs, etc.
sqrtabsehat ‚
‚
20.0 ˆ
A
‚
‚
A
‚
A
‚
17.5 ˆ
‚
‚
‚
A
‚
15.0 ˆ
‚
‚
A
A
‚
‚
12.5 ˆ
‚
‚
A
‚
‚
10.0 ˆ
‚
‚
A A
‚
A
A
F
‚
H
7.5 ˆ
A
E
‚
A
A
N
‚
A
A
A
‚
E
B
‚
A
C
A
5.0 ˆ
D
A
‚
BB
A
‚
A
B
A
‚
A
J
C
B
‚
HO I
A
2.5 ˆ
HC B
A
‚
AA A
‚
BA
‚
BA
A
A
‚
0.0 ˆ
‚
Šƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒ
0
10
20
30
40
50
60
70
yhat
4
The normality assumption is clearly violated, but with
so many observations per treatment group (25) that might
not be a problem. More troubling is the clear violation
of the constant variance assumptions. Thus we seek a
transformation to alleviate the non-constant variance
problems. Because variation in the residuals is
increasing with the estimated mean, we want to try the
natural log transform. Because there are some 0 counts,
we need to add a small positive constant to every count
before taking the natural log. log(y+1/6) works well in
this case.
Note that the constant variance assumption seems to be
approximately satisfied after transformation. The
situation regarding normality has improved. Residuals
are still non-normal, but this is not a concern due to
the large sample sizes within each group.
5
Stem
4
3
3
2
2
1
1
0
0
-0
-0
-1
-1
-2
-2
-3
-3
-4
Leaf
03
557788
033
5557799
0011122333444
666677789
01222344
55566666778889999
01111223333444
3333222222211111110
99999988755
4100
665
1
8888777777666666666
55555
111100000
----+----+----+----+
Variable:
#
2
6
3
7
13
9
8
17
14
19
11
4
3
1
19
5
9
Boxplot
|
|
|
|
|
+-----+
|
|
|
|
*--+--*
|
|
|
|
+-----+
|
|
|
|
|
|
ehat
Normal Probability Plot
4.25+
+++ * *
|
******
|
**
|
+**
|
****
|
***+
|
**+
|
****
|
****
|
****
|
***+
|
**+
|
++*
|
++ *
|
+******
|
++
|
******
-4.25+* * **+
+----+----+----+----+----+----+----+----+----+----+
-2
-1
0
+1
+2
6
Plot of ehat*yhat.
Legend: A = 1 obs, B = 2 obs, etc.
ehat ‚
‚
6 ˆ
‚
‚
‚
‚
‚
‚
A
4 ˆ
A
‚ A
A
B
‚ A
A
A
A
‚
A
‚ A
A
‚
B
A
C
‚ B
A
C
A
A
2 ˆ B
A
B
‚
B
A
B
B
‚
A
A
A
A
‚
A
A
A
A
‚ B
A
B
C
A
‚ D
B
A
A
A
‚ B
A
C
C
B
0 ˆ A
E
C
A
A
‚
E
D
A
A
‚
C
‚
B
E
A
A
‚
A
A
‚
A
A
‚
B
-2 ˆ
‚
A
‚ I
F
‚
D
‚
‚
E
‚
-4 ˆ
E
D
‚
Šˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒ
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
2.4
yhat
7
Plot of sqrtabsehat*yhat.
Legend: A = 1 obs, B = 2 obs, etc.
sqrtabsehat ‚
‚
2.25 ˆ
‚
‚
‚
A
2.00 ˆ
A
E
D
‚ A
A
B
‚
A
A
E
‚ A
A
1.75 ˆ
A
‚ A
D
A
‚ I
F
B
‚
B
B
A
A
1.50 ˆ B
A
A
A
‚ A
A
B
A
‚ A
A
A
‚
A
B
1.25 ˆ
B
A
B
A
A
‚
A
A
B
‚
A
‚
A
A
A
A
1.00 ˆ A
A
A
‚
E
B
C
B
‚ A
C
‚
A
A
A
0.75 ˆ D
B
‚
C
‚
A
A
A
‚ B
D
0.50 ˆ
A
E
B
‚
A
B
‚
E
B
‚
B
0.25 ˆ A
A
A
‚
‚
A
‚
0.00 ˆ
‚
Šƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒ
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
2.4
yhat
8
Download