/* ---------------------------------------------------------------- File: loglin.asp.sas PURPOSE: (1) Demonstation of Log Linear analysis (2) Comparison of Log Linear and Logistic Regression Fabricated data based on the results of Robins & Regier *1991) ---------------------------------------------------------------- */ * - formats to label the data; proc format; value sexfmt 1='Male' 2='Female'; value racefmt 1='White' 2='Nonwhite'; value agefmt 1='Young' 2='Middle age' 3='Elderly'; value aspfmt 0='No ASP' 1='ASP'; run; title 'Antisocial Personality Disorder'; title2 'based on Robins and Regier (1991)'; data asp; input sex race age asp freq; format sex sexfmt. race racefmt. age agefmt. asp aspfmt.; cards; 1 1 1 0 2987 1 1 1 1 535 1 1 2 0 2828 1 1 2 1 385 1 1 3 0 2996 1 1 3 1 124 1 2 1 0 440 1 2 1 1 83 1 2 2 0 488 1 2 2 1 72 1 2 3 0 492 1 2 3 1 18 2 1 1 0 3537 2 1 1 1 87 2 1 2 0 3787 2 1 2 1 69 2 1 3 0 3077 2 1 3 1 25 2 2 1 0 549 2 2 1 1 13 2 2 2 0 501 2 2 2 1 9 2 2 3 0 516 2 2 3 1 5 ; run; * - A simple analysis to the two by two table of sex*asp. The parameter for sex asks whether the proportion of females = the proportion of males. The parameter asp asks whether the sample is evenly divided between asp and not asp. Finally, the paramewter for sex*asp tests whether one can predict an entry in the two by two table by the marginal probabilities. If this parameter is significant, then there is an association between sex and asp.; title3 'Log linear Analysis of Sex and ASP'; * - first print the two x two table; PROC FREQ DATA=asp; WEIGHT freq; TABLES sex*asp / chisq; RUN; title3 'Log linear Analysis of Race and ASP'; proc catmod; weight freq; model race*asp = _response_ / freq corrb prob pred=prob ml; loglin asp | race / title='Full Model'; run; loglin asp race / title='Marginal Model'; run; quit; * - not for something more substantive; title3 'Log Linear Analysis'; proc catmod; weight freq; model asp*sex*race*age=_response_; loglin asp | sex | race | age / title='Full Model';; run; loglin asp | sex | race | age @2 / title='only 2 way interactions'; run; run; *- use proc catmod for a logistic regression of the "two way interaction" model; title3 'Logistic Regression'; proc catmod; direct age; weight freq; model asp = sex race age sex*race sex*age race*age / freq ml nogls; run;