Table 5.1 on page 80 based on the data set in Chapter 4. We showed two ways of creating the table. One is to use the result from Poisson distribution using identity link. The other way is to use the result from the result in Chapter 4.
data table4_3; input y x; cards;y x 2 -1 3 -1 6 0 7 0 8 0 9 0 10 1 12 1 15 1 ; run; /*method 1*/ proc genmod data = table4_3; model y = x /d=poi link=identity; output out = table5_1 p=yhat; run; quit; data table5_1; set table5_1; col3 = y*log(y/yhat); proc print data = table5_1; run; Obs y x yhat col3 1 2 -1 2.5163 -0.45931 2 3 -1 2.5163 0.52743 3 6 0 7.4516 -1.30004 4 7 0 7.4516 -0.43766 5 8 0 7.4516 0.56807 6 9 0 7.4516 1.69912 7 10 1 12.3869 -2.14057 8 12 1 12.3869 -0.38083 9 15 1 12.3869 2.87112 /*method 2*/ proc iml; use table4_3; read all; n = nrow(y); x1 = j(n, 1, 1); xall = x1 || x; xwx = j(2,2,1); xwz = j(2,1,1); b = {7,5}; m = 1; do while (m <=4); mydenom = (xall*b)##(-1); xwx[1,1] = sum(mydenom); xwx[1,2] = sum(x#mydenom); xwx[2,1] = xwx[1,2]; xwx[2,2] = sum(x#x#mydenom); xwz[1,1] = sum(y#mydenom); xwz[2,1] = sum(x#y#mydenom); b = inv(xwx)*xwz; m = m + 1; end; yhat = xall*b; col3 = y#log(y/yhat); print x y yhat[format = 10.5] col3[format=10.5]; quit;
X Y YHAT COL3 -1 2 2.51633 -0.45931 -1 3 2.51633 0.52743 0 6 7.45163 -1.30004 0 7 7.45163 -0.43766 0 8 7.45163 0.56807 0 9 7.45163 1.69912 1 10 12.38693 -2.14057 1 12 12.38693 -0.38083 1 15 12.38693 2.87112
Example on hypothesis testing on page 82. This is testing if the interaction term of age and female is significant. Proc glm gives t-test on each of the parameters. The t-value shown below can be converted to an F-value by squaring it: .44^2 = .1936.
data birthweight; input female age weight; cards; 0 40 2968 0 38 2795 0 40 3163 0 35 2925 0 36 2625 0 37 2847 0 41 3292 0 40 3473 0 37 2628 0 38 3176 0 40 3421 0 38 2975 1 40 3317 1 36 2729 1 40 2935 1 38 2754 1 42 3210 1 39 2817 1 40 3126 1 37 2539 1 36 2412 1 38 2991 1 39 2875 1 40 3231 ; run; proc glm data = birthweight ; model weight = age female age*female /solution; run; quit;
Standard Parameter Estimate Error t Value Pr > |t| Intercept -1268.672414 1114.638402 -1.14 0.2685 age 111.982759 29.045695 3.86 0.0010 female -872.994253 1611.330856 -0.54 0.5940 age*female 18.417241 41.755817 0.44 0.6639