How to create a bar graph off logistic regression results

This is how you can create a graph comparing the treatment group and the comparison group's %s  -- based on findings from the logistic regression model.

Based on the final multivariate model, you get the program effect in logit. For example:

-0.223

You also run the simpler model with the treatment program indicator only. Get the intercept value. For example:

1.7081

When this logic is converted into a %, it will be the unadjusted % of the comparison group.

Use these two numbers to derive %s for the treatment group and comparison group.

https://docs.google.com/spreadsheets/d/0B7AoA5fyqX_sN0RUc0E5aFowb00/edit?usp=sharing&ouid=116965977650967783537&resourcekey=0-nGn3k4fyPrVKP2f4Xm-fOA&rtpof=true&sd=true

The resulting graph fixes the % of the comparison group to the simple % of the comparison group and shows the % of the treatment group based on the program effect adjusted for covariates.

If you use the intercept value and the program effect value from the final multivariate model, the meaning of percentages become non-intuitive. If you center predictors (except for the treatment indicator), the intercept will represent a typical person in the dataset. But this is a bit difficult to undestand.

Without centering, the intercept value will represent someone who is, for example, female, white, etc., depending on omitted categories of the variables. If continuous variables are included and if the value of 0 in that variable is not intuitive, the meaning of the intercept is a difficult to interpret.

I recommend using the intercept from the simple model (only the treatment group is the predictor), so the comparison group % will be fixed at a simple descriptive % of the comparison group.

 

Calculating Odds Ratios from Logistic Regression Results

One can obtain odds ratios from the results of logistic regression model.  Odds ratios derived are adjusted for predictors included in the model and explains the relationship between two groups (e.g., treatment and control group) and outcome (binary outcome).  I wrote the following Excel document that calculates odds ratio based on logit coefficients from the intercept and the predictor of interest (binary ones: e.g., impact coefficient, gender effect, etc.).

https://drive.google.com/file/d/0B7AoA5fyqX_sN0RUc0E5aFowb00/view?usp=sharing

Appendix (p.27) of the following document includes description of odds ratio.

http://www.doe.k12.de.us/cms/lib09/DE01922744/Centricity/Domain/91/MA1275TAFINAL508.pdf

Using PROC LOGISTIC to Estimate the Rasch Model by Pan and Chen

http://support.sas.com/resources/papers/proceedings11/342-2011.pdf

Can this be right?  If right, it helps reduce the computational demand off the procedure.   Page 4:

"When thousands of persons take a test, the procedure takes a long time to estimate the parameters. It is well known that the Rasch model gives the same parameter estimates for each person who receives the same total score. So, variable ‘person’ is able to be replaced with variable ‘total’ when all examinees answer all items as shown by Nord (2008). After the model is fit, the estimate of the parameter for each person is equal to the estimate of the parameter of the total score corresponding to the person’s total score. The third code example and its output are shown as follows:"

Dummy variables in logistic regression models

Why do switching of values in a dummy variable and the use of class statement in PROC LOGISTIC change the coefficients in logistic regression?

(1) and (2) produce the same results. (3) and (4) produce the same results.

(1)
proc logistic data=here.asdf descending ;
model college= boy ;
run;

(2)
proc logistic data=here.asdf descending ;
class girl;
model college= girl ;
run;

(3)
proc logistic data=here.asdf descending ;
model college= girl;
run;

(4)
proc logistic data=here.asdf descending ;
class boy;
model college= boy ;
run;

(1) Estimates (2) Estimates (3) Estimates (4) Estimates
Intercept

0.5346

 Intercept

0.3645

 Intercept

0.1945

 Intercept

0.3645

boy      

-0.3401

 girl    

-0.1701

 girl

0.3401

 boy      

0.1701

               
Odds ratio

0.712

 

0.712

 

1.405

 

1.405

ROC Curve Analysis using PROC LOGISTIC

/*ROC Curve Analysis Macro*/

/*a hypothetical data set*/
data asdf;set sashelp.class;
EVENT=0;
if Weight > 100 then EVENT=1;
PREDICTOR=height;
run;

/*data name*/
%let dataname=asdf;
%let outcome=EVENT;
%let ind=PREDICTOR;
%let save_graphic=C:\Documents and Settings\19702\My Documents\sas;

ods html PATH="&save_graphic" (url=none) file="&dataname &ind .html";
ods graphics on / imagename="&dataname&ind";
proc logistic data=&dataname descending OUTEST=&dataname.result;
title "&dataname";
model &outcome =
&ind
/ outroc=&dataname.kaz2 ROCEPS=0 ;
output out = m2 p = prob xbeta = logit ;
ods output ParameterEstimates=kazcoeff
Association=kazassoc
ConvergenceStatus=kazconverg(keep= reason);
run;
ods graphics off;
ods html close;

proc transpose data=kazassoc out=T1;
var cValue1;
id label1;
run;
proc transpose data=kazassoc out=T2;
var cValue2;
id label2;
run;

data kazassoc2;
merge T1 T2;
run;

/*ods trace off;*/
/*Get descriptive statistics*/

ods listing close;
proc means data=&dataname;
var
&outcome
&ind
;
ods output summary=uekawa;
run;
ods listing;
/*get significance of the independent varible*/
data kazcoeff2;
set kazcoeff;
if Variable="&ind";
keep ProbChiSq StdErr flag;
flag=1;
label ProbChiSq="P-value for the ind var effect";
label StdErr="Stderr for the ind var effect";
run;

data &dataname.kaz2;set &dataname.kaz2;
flag=1;
run;

data &dataname.result;
set &dataname.result;
flag=1;
run;

data &dataname.kaz3;merge &dataname.kaz2 &dataname.result kazcoeff2;
by flag;
run;

data &dataname.kaz4;set &dataname.kaz3;
Distance=sqrt( (0-_1MSPEC_)**2 + (1-_SENSIT_)**2 );
suji=_n_;
run;
proc sql;
create table &dataname.kaz5 as
select *,
min(distance) as minimum_distance
from &dataname.kaz4;
run;

data optimal;
retain CUT_OFF_VALUE;
set &dataname.kaz5;
CUTOFF=0;
if distance = minimum_distance then do; CUTOFF=1; type="Dist to perfection";end;
/*if distance2 = maximum_distance2 then do; CUTOFF=1;
type="Dist to noninf";end;*/
if cutoff=1;
effect=&ind ;
LOGIT=LOG(_PROB_ / (1-_PROB_));
CUT_OFF_VALUE=((LOGIT-Intercept)/effect);
drop cutoff ;
run;
data results_of_ROC;
merge optimal uekawa kazassoc2 kazconverg;

TRUE_POSITIVE_RATE=_SENSIT_;
TRUE_NEGATIVE_RATE=1-_1MSPEC_;
AUC=C;
run;

proc print data=results_of_ROC;
title "ROC stats for &outcome";
var CUT_OFF_VALUE
TRUE_POSITIVE_RATE
TRUE_NEGATIVE_RATE
AUC ;
run;