lab_4_iml_reg.doc

advertisement
Lab 4: IML and REG
Example:
1. Dowdy and Wearden (1983) presented a set of data containing 14 measurements on the following variables, with
results as shown in the table that follows.
C1 : the number of larvae of the Chaoborus (which resembles the mosquito in appearance but not in blood-sucking
behavior) collected in a grab sample of the sediment from an area of approximately 225 cm 2 of lake bottom
C2 : the depth(m) of the lake at sampling point
C3 : the brackishness (conductivity, recorded in mhos per decimeter) of the water at the bottom
C4 : the dissolved oxygen (mg/l) in the water at the bottom
Sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Number of
Larvae
35
10
9
30
20
23
28
8
29
4
18
14
32
6
Depth of lake
8.4
2.0
3.5
10.4
6.5
6.2
12.4
7.0
5.8
3.0
6.0
5.5
9.0
1.1
Based on the output answer the following questions:
1. Give the regression equation in terms of the data.
Brackishness
of water
8
6.5
6.2
5.0
6.5
7.3
6.4
6.0
6.1
5.4
7.3
6.6
6.5
5.8
Dissolved
Oxygen
1
8.5
6.5
1.5
7.5
4.5
4.0
10.0
3.0
11.0
4.5
5.5
2.5
7.0
THE PROC IML for the estimation:
data abc;
input Int y x1 x2
cards;
1
35
8.4
1
10
2.0
1
9
3.5
1
30
10.4
1
20
6.5
1
23
6.2
1
28
12.4
1
8
7.0
1
29
5.8
1
4
3.0
1
18
6.0
1
14
5.5
1
32
9.0
1
6
1.1
run;
x3;
8
6.5
6.2
5.0
6.5
7.3
6.4
6.0
6.1
5.4
7.3
6.6
6.5
5.8
1
8.5
6.5
1.5
7.5
4.5
4.0
10.0
3.0
11.0
4.5
5.5
2.5
7.0
proc iml;
/*invoking iml*/
use abc;
read all var{Int x1 x2 x3} into x;
read all var{y} into y;
n=nrow(x);
k=ncol(x);
tx=t(x);
/*taking transpose*/
xtx=t(x)*x;
print xtx x tx;
/*X'X*/
d1=det(xtx);
/*finding inverse*/
s1=inv(xtx);
est=s1*tx*y;
print d1 s1 est;
e=y-x*est;
sse=t(e)*e;
mse=sse/(n-k-1);
print e sse mse;
var=mse*s1;
print est var;
run;
In REG this would be:
PROC REG DATA=ABC;
MODEL y=x1 x2 x3;
RUN;
Download