DATA Step, Macro, Functions and more

Plotting Calibration curve

Reply
Occasional Contributor
Posts: 14

Plotting Calibration curve

I seriously need help with this. I want to get a calibration plot of Predicted probability on observed event. similar to https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/Plotting-Calibration-curve-line/td-p/82754

But I just seems not to get it. I really need the codes for the deciles too. And mine seems not to work. I am working on a logistic regression for complex survey, my data is about 60, 000 and only 10% have the event of interest.

Esteemed Advisor
Posts: 5,482

Re: Plotting Calibration curve

Please post what code you got so far. Let's start from there.

PG
Occasional Contributor
Posts: 14

Re: Plotting Calibration curve

In the Proc rank statement, not sure what variable should be in the "var" line

proc import datafile="C:\Users\Downloads\Data variablen.sav"
out=work.usa1
replace;
run;
data live;
set usa1;
WEIGHT=PERWEIGHT/1000000;
run;
**********************Logistic regression model*****************************************************;
PROC surveyLOGISTIC DATA=live ;
strata strata;
cluster PSU;
CLASS  KIDSEX  (REF="Male")KIDBORD(REF="1")AGE5YEAR(REF=("45-49")MARSTAT  (REF="Never married") AGEFIRST(ref="30-49")birth5yrs (ref="More than two")cheb1(ref="> 5")deadkids(ref="Five and above")EDUCLVL(REF="No education")HH5kids(ref="> 5")popage(ref="> 35 years")bednet(ref="No bed net")URBAN (REF="Rural")GEO (REF="NW")/param=glm;
 MODEL KIDALIVE (Event = 'No')=KIDSEX KIDBORD AGE5YEAR MARSTAT AGEFIRST birth5yrs cheb1 deadkids EDUCLVL HH5kids popage bednet URBAN GEO / 
    LINK=LOGIT expb;
output out=pred_ds p=phat;
weight WEIGHT;
RUN;QUIT;
*****************************************end of model*************************************************************;


 **********************************************Obtaining deciles*******************************************;
proc rank data=pred_ds groups=10 descending ties=low out=ranked;
var KIDALIVE;
ranks decile;
run;
**********************************************end**********************************************************;

 

Esteemed Advisor
Posts: 5,482

Re: Plotting Calibration curve

I think you need

 

proc rank data=pred_ds groups=10 descending ties=low out=ranked;
var phat;
ranks decile;
run;

proc sql;
create table graph as
select 
    *,
    mean(phat) as phatDecile
from ranked
group by decile;
quit;
PG
Occasional Contributor
Posts: 14

Re: Plotting Calibration curve

Dear PG thanks for your time, but the codes you gave is not giving me any output. the plot attach is what I hope to get as my result. I will really appreciate your help. thanks

estimated prob plot.PNG

Esteemed Advisor
Posts: 5,482

Re: Plotting Calibration curve

We can't help you unless you show us some of your code and some of your output. The code I gave you should provide you with the x axis coordinates for your graph.

PG
Occasional Contributor
Posts: 14

Re: Plotting Calibration curve

The codes I gave is what I have so far, I hoped to get codes here that will help me obtain my result since I am not too good with SAS. They codes you gave me ran without error but did not produce any output, so I am still stock 

Esteemed Advisor
Posts: 5,482

Re: Plotting Calibration curve

If there were no errors, the code should give you a table called graph with the deciles to draw your plot.

PG
Occasional Contributor
Posts: 10

Re: Plotting Calibration curve

 

How can this approach be modified to suit cox model? I will be glad also to be assisted.

Occasional Contributor
Posts: 14

Re: Plotting Calibration curve

Posted in reply to Joseph2010

I think Same approach can be followed after you have obtained your predicted values from output of PHREG

Ask a Question
Discussion stats
  • 9 replies
  • 347 views
  • 0 likes
  • 3 in conversation