BookmarkSubscribeRSS Feed
shahd
Quartz | Level 8

Hi

I need to plot two plots one for deviance residuals versus predicted values and the other for probability plot of deviance residual. Could you please help me with that. below is my code

data prog;

input x1 x2 x3 x4 y;

datalines;

0     0     0     0     12.60

1     0     0     0     18.70

0     1     0     0     3.28

1     1     0     0     3.44

0     0     1     0     4.98

1     0     1     0     5.70

0     1     1     0     9.97

1     1     1     0     9.07

0     0     0     1     2.07

1     0     0     1     2.44

0     1     0     1     4.09

1     1     0     1     4.53

0     0     1     1     7.77

1     0     1     1     9.43

0     1     1     1     11.75

1     1     1     1     16.30

 

proc genmod;

model y = x1 x2 x3 x4/ dist =gamma link = log type1 type3;

run;

 

  ods graphics on;

   

   proc genmod plots=all PLOTS=PREDICTED

   PLOTS=(PREDICTED RESCHI)

   PLOTS(UNPACK)=DFBETA;

  

      model y = x1 x2 x3 x4;

   run;

16 REPLIES 16
Reeza
Super User
For #1 the same method as in the previous post will work. For #2, if I understand it correctly, use PROC UNIVARIATE and pprob to get the plot. Or use it to generate the data you need for the plot and then plot it using SGPLOT again.
shahd
Quartz | Level 8

could you please help me modify my code as i tried different scenarios and it didn't show me these plots

Reeza
Super User
Please show the scenarios that you tried, including your full code.
shahd
Quartz | Level 8

using this code , I got the plot of deviance residual versus observation but I need the second probability plot

data
rate;

input x1 x2 x3 x4 rate;

datalines;

0     0     0     0     12.60

1     0     0     0     18.70

0     1     0     0     3.28

1     1     0     0     3.44

0     0     1     0     4.98

1     0     1     0     5.70

0     1     1     0     9.97

1     1     1     0     9.07

0     0     0     1     2.07

1     0     0     1     2.44

0     1     0     1     4.09

1     1     0     1     4.53

0     0     1     1     7.77

1     0     1     1     9.43

0     1     1     1     11.75

1     1     1     1     16.30

 

proc genmod;

model rate = x1 x2 x3 x4/ dist =gamma link = log type3 ;

run;

 

ods graphics on;

 

proc genmod data=rate plots(unpack)=all;

 

model rate=x1 x2 x3 x4/dist=gamma link=log type1 typ3;

 

run;

 

ods graphics on;

 

proc genmod data=rate plots=resdev;

 

model rate=x1 x2 x3 x4/dist=gamma link=log type1 typ3;

 

run;

Reeza
Super User
Its not part of the PROC GENMOD that I can see so you need to use the methodology I demonstrated in your previous question, where you have to capture the data and use SGPLOT or PROC UNIVARIATE. PROC UNIVARIATE works for me.
shahd
Quartz | Level 8

I am beginner in SAS, could you elaborate more where should I write this in my code

Reeza
Super User
You use the same approach as here:
https://communities.sas.com/t5/SAS-Programming/plot-a-graph-for-Poisson-regression/m-p/514866#M13887..., except replace the SGPLOT with PROC UNIVARIATE. Check the documentation on the PROBPLOT statement to get your graph.
shahd
Quartz | Level 8

and how can I get the pp plot for deviance residuals

Reeza
Super User
You use the same approach as here:
https://communities.sas.com/t5/SAS-Programming/plot-a-graph-for-Poisson-regression/m-p/514866#M13887..., except replace the SGPLOT with PROC UNIVARIATE. Check the documentation on the PROBPLOT statement to get your graph.

Get the deviance residuals from PROC GENMOD.
Graph them using PROC UNIVARIATE or SGPLOT.
shahd
Quartz | Level 8

proc genmod data = prog plots;
model rate=x1 x2 x3 x4/dist=gamma link=log type1 typ3;
output out=want predicted=p;
run;

proc PROC UNIVARIATE data=want;
plot=pplot;
run;

 

This doesn't work for me could you please modify it

Reeza
Super User
Check the documentation for the OUTPUT statement. You aren't getting the residual deviance metric and you need to add that.
shahd
Quartz | Level 8

proc UNIVARIATE data=want plots=resdev ;
run;
This give me error
Reeza
Super User
Did you check the documentation - check the examples under PROC UNIVARIATE?

There are 36 examples listed, and one is how to create a probability plot (pplot).
https://documentation.sas.com/?docsetId=procstat&docsetVersion=9.4&docsetTarget=procstat_univariate_...
shahd
Quartz | Level 8
I tried this code proc univariate data=rate noprint;

ppplot rate / normal(mu=10 sigma=0.3)
square
odstitle = title;
run;
but i need the p-plot for deviance residuals so it doesnot work

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 2083 views
  • 2 likes
  • 2 in conversation