BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhr-q
Pyrite | Level 9

I want to compare the median of a continuous variable  b/n two groups using quantile regression, as you see below, when I set the quantile to 0.75, I receive output that includes p-values and difference estimates table. However, adjusting the quantile to 0.5 does not yield the second table with these details. Could you please advise on how to address this issue?

 

bhrq_0-1720459730008.pngbhrq_1-1720459802788.png

 

here is my code:

proc quantreg data=both_MIS ci=resampling;
class trtgroup;
model LOS_hours = trtgroup/ quantile=0.5 ;
estimate 'Diff in Medians' trtgroup 1 -1 / CL;
run;

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Are you getting any warnings in the log? For example, you might see

WARNING: The bootstrap covariance is close to 0.
WARNING: The ESTIMATE statement is ignored because the
covariance could not be computed at QUANTILE= 0.5

 

These results make me think that a large proportion of your data is tied at the median value. Study the following example. In the example, the LOS_hours response variable is binned to the nearest hour and most of the values are tied values at the median. When the QUANTREG procedure estimates the median for each class, there is no variation. (Notice in your output that the standard error of each estimate is 0 and the confidence interval has zero length.) 

 

I suggest you study (graph) your data to determine if your data are similar. 

data Have;
input trtgroup LOS_hours @@;
datalines;
 1 10 1 12 1 18 1 22 1 24 1 24 1 24 1 24 1 24 1 24 1 25 1 27 1 30 
 1 24 1 24 1 24 1 24 1 24 1 24
 0 12 0 16 0 20 0 26 0 30 0 30 0 30 0 30 0 30 0 30 0 32 0 35 0 36
 0 30 0 30 0 30 0 30 0 30 0 30
;

proc quantreg data=Have ci=resampling;
class trtgroup;
model LOS_hours = trtgroup/ quantile=0.5 ;
estimate 'Diff in Medians' trtgroup 1 -1 / CL;
run;

 

View solution in original post

2 REPLIES 2
cici0017
SAS Employee

You can try add an ODS OUTPUT statement to output the parameter estimation on quantile 0.75. For example -

 

proc quantreg data=KeepSmoking ci=resampling;
class sex Race Education Activity Exercise;
model Change = Sex Age Education Activity Exercise YearsSmoke
PerDay /quantile = 0.75;
estimate "diff in Quantile 0.75" sex 1 -1/ CL;
ods output ProcessEst=PE;
run;

 

This should help see the different quantile estimates.

Rick_SAS
SAS Super FREQ

Are you getting any warnings in the log? For example, you might see

WARNING: The bootstrap covariance is close to 0.
WARNING: The ESTIMATE statement is ignored because the
covariance could not be computed at QUANTILE= 0.5

 

These results make me think that a large proportion of your data is tied at the median value. Study the following example. In the example, the LOS_hours response variable is binned to the nearest hour and most of the values are tied values at the median. When the QUANTREG procedure estimates the median for each class, there is no variation. (Notice in your output that the standard error of each estimate is 0 and the confidence interval has zero length.) 

 

I suggest you study (graph) your data to determine if your data are similar. 

data Have;
input trtgroup LOS_hours @@;
datalines;
 1 10 1 12 1 18 1 22 1 24 1 24 1 24 1 24 1 24 1 24 1 25 1 27 1 30 
 1 24 1 24 1 24 1 24 1 24 1 24
 0 12 0 16 0 20 0 26 0 30 0 30 0 30 0 30 0 30 0 30 0 32 0 35 0 36
 0 30 0 30 0 30 0 30 0 30 0 30
;

proc quantreg data=Have ci=resampling;
class trtgroup;
model LOS_hours = trtgroup/ quantile=0.5 ;
estimate 'Diff in Medians' trtgroup 1 -1 / CL;
run;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 467 views
  • 1 like
  • 3 in conversation