/*------------------------------------------------------------*/ /* */ /*SAS Example XII Stat345 Categorical Data Analysis */ /* */ /*College Football Concussion Study */ /* */ /*------------------------------------------------------------*/ Options LS=78; Data Football; INPUT Team $ O_Play $ Action $ Count; Cards; Offense Rushing Tackle 125 Offense Rushing Block 129 Offense Passing Tackle 85 Offense Passing Block 31 Defense Rushing Tackle 216 Defense Rushing Block 61 Defense Passing Tackle 62 Defense Passing Block 16 ; /*Analyze the data using Proc FREQ. */ /* The 'Data=' specification designates the data set to be */ /* analyzed. */ /* The 'Order=Data' specification maintains the ordering of */ /* the variable levels in which the data was input. */ /* The 'Weight' statement identifies the cell frequency */ /* variable. */ /* The 'RelRisk' option produces estimates for the odds ratio */ /* and the relative risk. */ /* The 'Title' statement assigns a heading to each page of output.*/ Proc FREQ Data = Football Order = data; Weight Count; Tables Team*O_Play*Action / RelRisk; Title 'College Football Concussion Study'; /*Fit a loglinear model to the data using Proc CATMOD. */ /* The 'Data=' specification designates the data set to be */ /* analyzed. */ /* The 'Order=Data' specification maintains the ordering of */ /* the variable levels in which the data was input. */ /* The 'Weight' statement identifies the cell frequency */ /* variable. */ /* The 'Loglin' statement lists the effects to be included in */ /* the model. */ /* The 'Response / Out =' Statement creates and names an output */ /* data file which contains values featured in the section */ /* of output labeled 'MAXIMUM-LIKELIHOOD PREDICTED VALUES */ /* FOR RESPONSE FUNCTIONS AND FREQUENCIES'. */ /* The 'Pred=Freq' option produces the MLE's of the expected cell */ /* counts. (The 'Pred=Prob' option produces the MLE's of */ /* the joint probabilities.) */ /* The 'NoIter' option suppresses output which features the MLE's */ /* at each iteration of the Newton-Raphson algorithm. */ /* The 'NoResponse' option suppresses the output of the response */ /* matrix. */ /* The 'Title' statement assigns a heading to each page of */ /* output. */ Proc CATMOD Data = Football Order = Data; Weight Count; Response / out = Results; Model Team * O_Play * Action = _Response_ / Pred=Freq NoIter NoResponse; Loglin Team O_Play Action Tearm*O_Play Team*Action O_Play*Action; Title 'Fit of NO Three-Way Interaction Model'; Run; /*Create a residual plot for the fitted loglinear model using */ /* Proc PLOT. */ /* The 'Data' statement is used to construct standardized */ /* residuals from the values stored in the output file */ /* produced by Proc CATMOD. */ /* The 'Title' statement is used to label the plot. */ Data Results; Set Results; If (_Type_ = 'FUNCTION') Then _Resid_ = .; If (_Type_ = 'FREQ') Then _Resid_ = _Resid_/_SEPred_; Proc PLOT Data = Results; Plot _Resid_ * _Number_; Title 'Residual Plot from Fit of No Three-Way Interaction Model'; Run;