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?
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
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;
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.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.