/* 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 The data are stored in a different file we currently do not have permission to give to you. */ options linesize=64; data set1; infile 'c:\mydocuments\courses\st557\sas\nestall.dat'; input wshed $ loc $ round roadside $ roadtype $ adjhab $ rdepth rwidth foreback percip mtemp ftotal floss btotal bloss ctotal closs; if(roadtype='grav') then x1=1; else x1=0; if(adjhab='nrc') then x2=1; else x2=0; if(roadside='nfen') then x3=1; else x3=0; if(roadside='wd') then x4=1; else x4=0; x5=x1*x2; x6=x2*x4; x7=x1*x3; slope=0; loss=floss; total=ftotal; output; slope=1; loss=bloss; total=btotal; output; keep wshed loc x1 x2 x3 x4 x5 x6 x7 slope loss total; run; /* Sort data with respect to the transects and sub-transects */ 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; model loss/total= x1 x2 x3 x4 x5 x6 x7 slope/ dist=binomial link=logit itprint converge=1e-8 maxit=50; run; /* Compute GEE parameter estimates for an unstructured covariance structure. With only two sub-plots this is equivalent to the exchangeable correlation model */ proc genmod data=set1; class loc ; model loss/total= x1 x2 x3 x4 x5 x6 x7 slope / dist=binomial link=logit itprint converge=1e-8 maxit=50; repeated subject=loc / type=un modelse covb corrw; run;