slope=0; loss=floss; total=ftotal; output;

advertisement
/* This program uses features in PROC GENMOD
in SAS to fit logistic regression models
to nest predation data from a split-plot
experiment. The code is stored in the file
nestgee.sas
We currently do not have permission to
give you the data
*/
data set1;
infile 'nestall.dat';
input wshed $ loc $ round roadside $
roadtype $ adjhab $ rdepth rwidth
foreback percip mtemp ftotal floss
btotal bloss ctotal closs;
if(roadtype='grav') then rd=1; else rd=0;
if(adjhab='nrc') then ah=1; else ah=0;
if(roadside='nfen') then nf=1; else nf=0;
if(roadside='wd') then wd=1; else wd=0;
rda=rd*ah; anf=nf*ah; awd=wd*ah;
rwd=rd*wd; rnf=nf*rd;
slope=0; loss=floss;
slope=1; loss=bloss;
keep wshed loc rd ah
anf awd rwd rnf
run;
total=ftotal; output;
total=btotal; output;
nf wd rda
slope loss total;
/* Sort data with respect to the
whole plots */
proc sort data=set1; by loc slope;
run;
/* Compute parameter estimates and
the covariance matrix
for the IWM model using GENMOD */
proc genmod data=set1;
class loc slope;
model loss/total= rd ah nf wd rda
awd rnf slope rd*slope /
dist=binomial link=logit
itprint
converge=1e-8 maxit=50;
run;
1302
1301
/* Compute GEE parameter estimates for an
unstructured covariance structure for
the totals in two sub-plots corresponding
to the foreslope and backslope of each
site.
*/
/* Compute IWM parameter estimates and
the robust covariance matrix, and
a covariance matrix that just allows
for extra-binomial variation */
proc genmod data=set1;
class loc slope;
model loss/total= rd ah nf wd rda
awd rnf slope rd*slope /
dist=binomial link=logit
itprint pscale
converge=1e-8 maxit=50;
repeated subject=loc / type=ind
modelse covb corrw;
run;
proc genmod data=set1;
class loc slope;
model loss/total= rd ah nf wd rda
awd rnf slope rd*slope /
dist=binomial link=logit
itprint pscale
converge=1e-8 maxit=50;
repeated subject=loc / type=un
modelse covb corrw;
run;
1303
1304
Criteria For Assessing Goodness Of Fit
Criterion
Deviance
Scaled Deviance
Pearson Chi-Square
Scaled Pearson X2
Log Likelihood
The GENMOD Procedure
Data Set
Distribution
Link Function
Response Variable (Events)
Response Variable (Trials)
Observations Used
Number Of Events
Number Of Trials
WORK.SET1
Binomial
Logit
loss
total
272
307
1332
Levels
loc
slope
136
2
Value
Value/DF
262
262
262
262
546.2565
546.2565
489.4939
489.4939
-679.3274
2.0849
2.0849
1.8683
1.8683
Analysis Of Parameter Estimates
Class Level
Information
Class
DF
Parameter
DF
Estimate
Standard
Error
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
rd*slope
rd*slope
Scale
1
1
1
1
1
1
1
1
1
0
1
0
0
-0.8479
0.1374
-1.0003
0.1493
-0.2749
0.6509
1.3549
-1.1171
-0.5769
0.0000
-0.2586
0.0000
1.0000
0.2474
0.2771
0.3605
0.3599
0.2770
0.3884
0.3566
0.4631
0.3094
0.0000
0.3450
0.0000
0.0000
0
1
0
1
Wald 95% Confidenc
Limits
-1.3327
-0.4058
-1.7069
-0.5560
-0.8179
-0.1103
0.6560
-2.0247
-1.1833
0.0000
-0.9349
0.0000
1.0000
1305
-0.363
0.680
-0.293
0.854
0.268
1.412
2.053
-0.209
0.029
0.000
0.417
0.000
1.000
1306
Criteria For Assessing Goodness Of Fit
Criterion
Deviance
Scaled Deviance
Pearson Chi-Square
Scaled Pearson X2
Log Likelihood
DF
Value
Value/DF
262
262
262
262
546.2565
292.3820
489.4939
262.0000
-363.6077
2.0849
1.1160
1.8683
1.0000
Working Correlation Matrix
Row1
Row2
DF
Estimate
Standard
Error
Wald 95% Confidence
Limits
Intercept
1
-0.8479
0.3381
-1.5106
rd
1
0.1374
0.3788
-0.6050
ah
1
-1.0003
0.4927
-1.9660
nf
1
0.1493
0.4919
-0.8148
wd
1
-0.2749
0.3786
-1.0171
rda
1
0.6509
0.5309
-0.3896
awd
1
1.3549
0.4874
0.3996
rnf
1
-1.1171
0.6330
-2.3577
slope
0
1
-0.5769
0.4229
-1.4057
slope
1
0
0.0000
0.0000
0.0000
rd*slope
0
1
-0.2586
0.4716
-1.1829
rd*slope
1
0
0.0000
0.0000
0.0000
Scale
0
1.3669
0.0000
1.3669
NOTE: The scale parameter was estimated by the square
root of Pearson's Chi-Square/DOF.
1307
Col2
1.0000
0.0000
0.0000
1.0000
Analysis Of GEE Parameter Estimates
Empirical Standard Error Estimates
Analysis Of Initial Parameter Estimates
Parameter
Col1
-0.1852
0.8799
-0.0346
1.1135
0.4672
1.6914
2.3102
0.1235
0.2519
0.0000
0.6658
0.0000
1.3669
Parameter
Estimate
Standard
Error
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
rd*slope
rd*slope
-0.8479
0.1374
-1.0003
0.1493
-0.2749
0.6509
1.3549
-1.1171
-0.5769
0.0000
-0.2586
0.0000
0.3799
0.4203
0.4549
0.6137
0.4740
0.5099
0.5961
0.7373
0.3751
0.0000
0.4105
0.0000
0
1
0
1
95% Confidence
Limits
-1.5924
-0.6864
-1.8919
-1.0534
-1.2040
-0.3484
0.1866
-2.5622
-1.3121
0.0000
-1.0632
0.0000
-0.1034
0.9612
-0.1087
1.3521
0.6542
1.6503
2.5232
0.3281
0.1582
0.0000
0.5461
0.0000
Z Pr > |
-2.23
0.33
-2.20
0.24
-0.58
1.28
2.27
-1.52
-1.54
.
-0.63
.
1308
0.02
0.74
0.02
0.80
0.56
0.20
0.02
0.12
0.12
.
0.52
.
GEE Model Information
Correlation Structure
Subject Effect
Number of Clusters
Analysis Of GEE Parameter Estimates
Model-Based Standard Error Estimates
Parameter
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
rd*slope
rd*slope
Scale
NOTE: The
Standard
Estimate
Error
Working Correlation Matrix
95% Confidence
Limits
Z Pr > |Z|
-0.8479
0.3381 -1.5106 -0.1852
0.1374
0.3788 -0.6050
0.8799
-1.0003
0.4927 -1.9660 -0.0346
0.1493
0.4919 -0.8148
1.1135
-0.2749
0.3786 -1.0171
0.4672
0.6509
0.5309 -0.3896
1.6914
1.3549
0.4874
0.3996
2.3102
-1.1171
0.6330 -2.3577
0.1235
0 -0.5769
0.4229 -1.4057
0.2519
1
0.0000
0.0000
0.0000
0.0000
0 -0.2586
0.4716 -1.1829
0.6658
1
0.0000
0.0000
0.0000
0.0000
1.3669
.
.
.
scale parameter was held fixed.
Unstructured
loc (136 levels)
136
-2.51
0.36
-2.03
0.30
-0.73
1.23
2.78
-1.76
-1.36
.
-0.55
.
.
0.0121
0.7168
0.0423
0.7614
0.4678
0.2201
0.0054
0.0776
0.1725
.
0.5835
.
.
Col1
1.0000
0.2729
Row1
Row2
Col2
0.2729
1.0000
Analysis Of GEE Parameter Estimates
Empirical Standard Error Estimates
Parameter
Estimate
Standard
Error
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
rd*slope
rd*slope
-0.8424
0.1299
-1.0185
0.1441
-0.2481
0.6890
1.3107
-1.1354
-0.5754
0.0000
-0.2586
0.0000
0.3784
0.4193
0.4497
0.6201
0.4748
0.5100
0.5994
0.7494
0.3760
0.0000
0.4111
0.0000
0
1
0
1
95% Confidence
Limits
-1.5841
-0.6918
-1.8999
-1.0714
-1.1786
-0.3105
0.1360
-2.6042
-1.3123
0.0000
-1.0644
0.0000
-0.1008
0.9517
-0.1370
1.3595
0.6824
1.6885
2.4854
0.3334
0.1615
0.0000
0.5471
0.0000
1309
Z Pr > |
-2.23
0.31
-2.26
0.23
-0.52
1.35
2.19
-1.52
-1.53
.
-0.63
.
1310
/* This program uses features in
SAS GLMMIX macro to fit logistic
regression models to nest predation
data from a split-plot experiment.
. The code is stored in the file
Analysis Of GEE Parameter Estimates
Model-Based Standard Error Estimates
Parameter
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
rd*slope
rd*slope
Scale
NOTE: The
Standard
Estimate
Error
nestglmm.sas
95% Confidence
Limits
-0.8424
0.3530 -1.5343 -0.1506
0.1299
0.3960 -0.6461
0.9060
-1.0185
0.5555 -2.1073
0.0704
0.1441
0.5539 -0.9415
1.2296
-0.2481
0.4208 -1.0728
0.5766
0.6890
0.5982 -0.4835
1.8615
1.3107
0.5441
0.2444
2.3770
-1.1354
0.7128 -2.5325
0.2617
0 -0.5754
0.3618 -1.2845
0.1337
1
0.0000
0.0000
0.0000
0.0000
0 -0.2586
0.4035 -1.0495
0.5322
1
0.0000
0.0000
0.0000
0.0000
1.3669
.
.
.
scale parameter was held fixed.
Z Pr > |Z|
-2.39
0.33
-1.83
0.26
-0.59
1.15
2.41
-1.59
-1.59
.
-0.64
.
.
1311
0.0170
0.7428
0.0668
0.7948
0.5555
0.2494
0.0160
0.1112
0.1117
.
0.5215
.
.
We currently do not have permission
to give you the data.
*/
data set1;
infile 'nestall.dat';
input wshed $ loc round roadside $
roadtype $ adjhab $ rdepth rwidth
foreback percip mtemp ftotal floss
btotal bloss ctotal closs;
if(roadtype='grav') then rd=1; else rd=0;
if(adjhab='nrc') then ah=1; else ah=0;
if(roadside='nfen') then nf=1; else nf=0;
if(roadside='wd') then wd=1; else wd=0;
rda=rd*ah; anf=nf*ah; awd=wd*ah;
rwd=rd*wd; rnf=nf*rd;
1312
0.02
0.75
0.02
0.81
0.60
0.17
0.02
0.12
0.12
.
0.52
.
slope=0; loss=floss;
slope=1; loss=bloss;
keep wshed loc rd ah
anf awd rwd rnf
run;
total=ftotal; output;
total=btotal; output;
nf wd rda
slope loss total;
/* Sort data with respect to the
whole plots */
proc sort data=set1; by loc slope;
run;
/* Logistic regression with fixed and
random effects */
%glimmix(data=set1,
stmts=%str(
class loc slope;
model loss/total = rd ah nf wd rda
awd rnf slope /
solution ddfm=satterth;
random loc; ),
error=binomial, link=logit,
converge=1e-8, maxit=20, out=setp
)
/* Access the GLMMIX macro */
%inc 'c:\courses\st557\sas\glmm800.sas' /
nosource;
run;
1313
/* Logistic regression with homogeneous
extra-binomial variance adjustments
for the foreslope and backslope*/
%glimmix(data=set1,
stmts=%str(
class loc slope;
model loss/total = rd ah nf wd rda
awd rnf slope /
solution ddfm=satterth;
repeated / type=cs subject=loc r rcorr; ),
error=binomial, link=logit,
converge=1e-8, maxit=20, out=setp )
run;
1315
run;
proc print data=setp (obs=5); run;
1314
/* Logistic regression with heterogeneous
extra-binomial variance adjustments
for the foreslope and backslope*/
%glimmix(data=set1,
stmts=%str(
class loc slope;
model loss/total = rd ah nf wd rda
awd rnf slope /
solution ddfm=satterth;
repeated / type=un subject=loc r rcorr; ),
error=binomial, link=logit,
converge=1e-8, maxit=20, out=setp)
run;
1316
The Mixed Procedure
Data Set
Dependent Variable
Weight Variable
Covariance Structure
Estimation Method
Residual Variance Method
Fixed Effects SE Method
Degrees of Freedom Method
WORK._DS
_z
_w
Variance Components
REML
Profile
Model-Based
Satterthwaite
Dimensions
Covariance Parameters
Columns in X
Columns in Z
Subjects
Max Obs Per Subject
Observations Used
Observations Not Used
Total Observations
Class Level Information
Class
Levels
loc
Values
136
slope
1 2 3 4 5 6
14 15 16 17
24 25 26 27
34 35 36 37
44 45 46 47
54 55 56 57
64 65 66 67
74 75 76 77
84 85 86 87
94 95 96 97
103 104 105
110 111 112
117 118 119
124 125 126
131 132 133
0 1
2
2
10
136
1
272
272
0
272
Covariance Parameter
Estimates
7 8 9 10 11 12 13
18 19 20 21 22 23
28 29 30 31 32 33
38 39 40 41 42 43
48 49 50 51 52 53
58 59 60 61 62 63
68 69 70 71 72 73
78 79 80 81 82 83
88 89 90 91 92 93
98 99 100 101 102
106 107 108 109
113 114 115 116
120 121 122 123
127 128 129 130
134 135 136
Cov Parm
loc
Residual
Estimate
0.8976
1.1101
Fit Statistics
-2 Res Log Likelihood
AIC (smaller is better)
AICC (smaller is better)
BIC (smaller is better)
1009.8
1013.8
1013.9
1019.6
1318
1317
Solution for Fixed Effects
Effect
slope
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
0
1
GLIMMIX Model Statistics
Estimate
Standard
Error
DF
t Value
Pr > |t|
-0.8411
0.05224
-0.9555
0.07775
-0.2970
0.6061
1.4078
-1.0421
-0.8574
0
0.3672
0.4053
0.5675
0.6250
0.4565
0.6211
0.5969
0.7551
0.1520
.
130
122
151
126
132
143
124
141
143
.
-2.29
0.13
-1.68
0.12
-0.65
0.98
2.36
-1.38
-5.64
.
0.0236
0.8976
0.0943
0.9012
0.5164
0.3308
0.0199
0.1697
<.0001
.
Type 3 Tests of Fixed Effects
Effect
rd
ah
nf
wd
rda
awd
rnf
slope
Num
DF
Den
DF
F Value
Pr > F
1
1
1
1
1
1
1
1
122
151
126
132
143
124
141
143
0.02
2.83
0.02
0.42
0.95
5.56
1.90
31.83
0.8976
0.0943
0.9012
0.5164
0.3308
0.0199
0.1697
<.0001
1319
Description
Value
Deviance
Scaled Deviance
Pearson Chi-Square
Scaled Pearson Chi-Square
Extra-Dispersion Scale
Obs
1
2
3
4
5
_y _offset _wght _orig loss total rd ah nf wd rda
0.0
0.0
0.2
0.5
0.2
0
0
0
0
0
5
5
5
4
5
Obs awd rnf loc slope
1
2
3
4
5
293.6245
264.5070
216.8653
195.3597
1.1101
0
0
0
0
0
1
1
1
1
0
1
1
2
2
3
0
1
0
1
0
y
y
y
y
y
0
0
1
2
1
5
5
5
4
5
1
1
1
1
1
1
1
0
0
0
1
1
1
1
0
0
0
0
0
0
1
1
0
0
0
Pred
StdErr
Pred
DF
Lower
-3.38955
-2.53219
-1.73766
-0.88030
-1.77242
0.87007
0.86535
0.67314
0.66962
0.63269
108.262
105.925
228.003
224.742
203.581
-5.11414
-4.24784
-3.06403
-2.19983
-3.01989
1320
Model Information
Data Set
Dependent Variable
Weight Variable
Covariance Structure
Subject Effect
Estimation Method
Residual Variance Method
Fixed Effects SE Method
Degrees of Freedom Method
WORK._DS
_z
_w
Compound Symmetry
loc
REML
Profile
Model-Based
Satterthwaite
Fit Statistics
-2 Res Log Likelihood
AIC (smaller is better)
AICC (smaller is better)
BIC (smaller is better)
Estimated R Matrix for
loc 1/Weighted by _w
Row
1
2
Col1
7.1765
1.4589
Solution for Fixed Effects
Col2
1.4589
3.7234
Effect
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
Estimated R Correlation
Matrix for loc 1/Weighted
by _w
Row
1
2
Col1
1.0000
0.2822
1000.8
1004.8
1004.9
1010.7
Col2
0.2822
1.0000
slope
0
1
Estimate
Standard
Error
DF
t Value
Pr > |t|
-0.7647
0.03355
-1.0361
0.1476
-0.2431
0.7053
1.3074
-1.1345
-0.7843
0
0.3326
0.3683
0.5628
0.5615
0.4230
0.6057
0.5472
0.7206
0.1600
.
146
134
137
133
139
136
136
135
140
.
-2.30
0.09
-1.84
0.26
-0.57
1.16
2.39
-1.57
-4.90
.
0.0229
0.9275
0.0678
0.7930
0.5664
0.2463
0.0183
0.1177
<.0001
.
Covariance Parameter Estimates
Cov Parm
CS
Residual
Subject
loc
Estimate
0.5314
1.3516
1321
1322
Model Information
Type 3 Tests of Fixed Effects
Effect
rd
ah
nf
wd
rda
awd
rnf
slope
Num
DF
Den
DF
F Value
Pr > F
1
1
1
1
1
1
1
1
134
137
133
139
136
136
135
140
0.01
3.39
0.07
0.33
1.36
5.71
2.48
24.04
0.9275
0.0678
0.7930
0.5664
0.2463
0.0183
0.1177
<.0001
GLIMMIX Model Statistics
Description
Deviance
Scaled Deviance
Pearson Chi-Square
Scaled Pearson Chi-Square
Extra-Dispersion Scale
Value
546.8622
404.6179
491.6979
363.8024
1.3516
Data Set
Dependent Variable
Weight Variable
Covariance Structure
Subject Effect
Estimation Method
Residual Variance Method
Fixed Effects SE Method
Degrees of Freedom Method
Estimated R Matrix for
loc 1/Weighted by _w
Row
1
2
Col1
6.2378
1.4630
Col2
1.4630
4.2165
Estimated R Correlation
Matrix for loc 1/Weighted
by _w
Row
1
2
Col1
1.0000
0.2853
Col2
0.2853
1.0000
Covariance Parameter Estimates
Cov Parm
UN(1,1)
UN(2,1)
UN(2,2)
1323
WORK._DS
_z
_w
Unstructured
loc
REML
None
Model-Based
Satterthwaite
Subject
loc
loc
loc
Estimate
1.6352
0.5326
2.1321
1324
Fit Statistics
Type 3 Tests of Fixed Effects
-2 Res Log Likelihood
AIC (smaller is better)
AICC (smaller is better)
BIC (smaller is better)
998.2
1004.2
1004.3
1012.9
Effect
Solution for Fixed Effects
Effect
Intercept
rd
ah
nf
wd
rda
awd
rnf
slope
slope
slope
0
1
Estimate
Standard
Error
DF
t Value
Pr > |t|
-0.7582
0.02370
-1.0199
0.1615
-0.2280
0.6558
1.3425
-1.1119
-0.7851
0
0.3380
0.3717
0.5667
0.5644
0.4280
0.6098
0.5526
0.7251
0.1571
.
160
158
251
154
181
222
165
218
183
.
-2.24
0.06
-1.80
0.29
-0.53
1.08
2.43
-1.53
-5.00
.
0.0263
0.9492
0.0731
0.7751
0.5949
0.2833
0.0162
0.1266
<.0001
.
1325
rd
ah
nf
wd
rda
awd
rnf
slope
Num
DF
Den
DF
F Value
Pr > F
1
1
1
1
1
1
1
1
158
251
154
181
222
165
218
183
0.00
3.24
0.08
0.28
1.16
5.90
2.35
24.96
0.9492
0.0731
0.7751
0.5949
0.2833
0.0162
0.1266
<.0001
GLIMMIX Model Statistics
Description
Deviance
Scaled Deviance
Pearson Chi-Square
Scaled Pearson Chi-Square
Extra-Dispersion Scale
Value
546.8712
546.8712
491.4987
491.4987
1.0000
1326
Download