
Exploratory Analysis for Logit Transformation
"Explore the estimation of logits using logistic models and Logit transformation. Conduct simple exploratory analysis to calculate and plot estimated logits. Utilize PROC RANK and other SAS procedures for data ranking and grouping by age for statistical analysis."
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
A macro for Graphing Logits
The Logistic Model x 1 e e + i = = = = Pr( 1| ) p y x i i i + x x 1 1 e i i = = (1, , ,..., ) x x x x 1 2 i p ( , , ,..., ) 0 1 2 p
The Univariate Version p + = x i e 0 1 1 p i p = = = + log odds i logit log x 0 1 1 p i The Logit Transform
A simple exploratory analysis. Form groups: For each group , Determine # # i M observations = k = 1,..., i i k = m events i Calculate Estimated Logits Plot the estimated logits versus a representative value of x
Estimated Logits = = + 1 m log i + 1 M m i i Number of events Number of observations m i M i 5
PROC RANK (from SAS help) data data golf; input person $ strokes @@ ; datalines; Jack 279 Jerry 283 Mike 274 Randy 296 Tito 302 ; proc proc print print data=golf; proc proc rank rank data=golf out=ranks; var strokes; ranks finished; proc proc print print data=ranks; run run;
Form groups based on ascending age proc proc rank var Age; ranks Bin; run run; rank data=s5238.chd5238 groups=10 10 out=Ranks; proc proc means means data=ranks; class bin; var age; run run;
Calculate average age and logit for each group. proc proc sql create table toplot as select avg(age) as mean label="Mean of group", sum(chd10yr) as num_chd label="Number of Events", count(*) as binsize label="Number at Risk", log((calculated num_chd+1 1)/ (calculated binsize-calculated num_chd+1 1)) as logit from ranks group by bin; select * from toplot; quit quit; sql;
Plot estimated logits proc proc sgscatter sgscatter data=toplot; plot Logit*mean / reg markerattrs=(symbol=asterisk color=blue size=15 title "Estimated Logit Plot of chd vs Age"; run run; title; 15);
Put it all together and run proc proc rank var Age; ranks Bin; run run; proc proc sql sql; create table toplot as select avg(age) as mean label="Mean of group", sum(chd10yr) as num_chd label="Number of Events", count(*) as binsize label="Number at Risk", log((calculated num_chd+1 1)/ (calculated binsize-calculated num_chd+1 1)) as logit from ranks group by bin; quit quit; proc proc sgscatter sgscatter data=toplot; plot Logit*mean / reg markerattrs=(symbol=asterisk color=blue size=15 title "Estimated Logit Plot of chd vs Age"; run run; title; rank data=s5238.chd5238 groups=10 10 out=Ranks; 15);
Parmeters for macro proc proc rank var Age; ranks Bin; run run; proc proc sql sql; create table toplot as select avg(age) as mean label="Mean of group", sum(chd10yr) as num_chd label="Number of Events", count(*) as binsize label="Number at Risk", log((calculated num_chd+1 1)/ (calculated binsize-calculated num_chd+1 1)) as logit from ranks group by bin; quit quit; proc proc sgscatter sgscatter data=toplot; plot Logit*mean / reg markerattrs=(symbol=asterisk color=blue size=15 title "Estimated Logit Plot"; run run; title; rank data=s5238.chd5238 groups=10 10 out=Ranks; 15);
Macro variables %let indata=s5238.chd5238; %let numgrp=10; %let indepvar=age; %let depvar=chd10yr; proc proc rank rank data=&indata groups=&numgrp out=Ranks; var &indepvar; ranks Bin; run run; proc proc sql sql; create table toplot as select avg(&indepvar) as mean label="Mean of group", sum(&depvar) as num_chd label="Number of Events", count(*) as binsize label="Number at Risk", log((calculated num_chd+1 1)/ (calculated binsize-calculated num_chd+1 1)) as logit from ranks group by bin; quit quit; proc proc sgscatter sgscatter data=toplot; plot Logit*mean / reg markerattrs=(symbol=asterisk color=blue size=15 title "Estimated Logit Plot"; run run; title; 15);
A Macro %macro %macro PlotLogits(indata=,numgrp=7 7,indepvar=,depvar=); proc rank data=&indata groups=&numgrp out=Ranks; var &indepvar; ranks Bin; run; proc sql; create table toplot as select avg(&indepvar) as mean label="Mean of group", sum(&depvar) as num_chd label="Number of Events", count(*) as binsize label="Number at Risk", log((calculated num_chd+1 1)/ (calculated binsize-calculated num_chd+1 1)) as logit from ranks group by bin; quit; proc sgscatter data=toplot; plot Logit*mean / reg markerattrs=(symbol=asterisk color=blue size=15 title "Estimated Logit Plot"; run; title; %mend %mend PlotLogits; 15);
Save and test after restart %PlotLogits PlotLogits(indata=s5238.chd5238,numgrp=10 %PlotLogits PlotLogits(indata=dis.dislipid,numgrp=9 9,indepvar=hdl,depvar=inc_chd) 10,indepvar=age,depvar=chd10yr)