简体   繁体   中英

Quantile Plot in RMS::orm

I'm not sure if this question is more pertinent to CrossValidated or StackOverflow. I'm happy to migrate it if necessary.

I'm trying to reproduce the plots from Roger Koenker 's quantile regression vignette but utilizing Frank Harrell 's ordinal regression model .

Here are Koenker's plots on page 8 (I'm mostly interested in the plot of quantiles vs. predictor): Koenker 的阴谋 第 8 页

R Code

I can produce similar plots but not quite the same. For instance:

## Load libraries
library(dplyr)
library(rms)
library(ggplot2)

## Simulate data
set.seed(123)
n <- 100
df <- data.frame(x1 = rnorm(n),
                 x2 = sample(c(-1,0,1), n, TRUE)) %>% 
  mutate(y = x1 + rnorm(n))

d <- datadist(df)
options(datadist="d")


## Fit ORM model
f1 <- orm(y ~ x1 + x2, data = df)


## Estimate quantiles
qu  <- Quantile(f1)
q25 <- function(x) qu(0.25, x)
q50 <- function(x) qu(0.50, x)
q75 <- function(x) qu(0.75, x)

## Point predictions
qplot <- Predict(f1, fun =q25) %>% mutate(q = 25) %>% 
  bind_rows(Predict(f1, fun = q50) %>% mutate(q = 50)) %>% 
  bind_rows(Predict(f1, fun = p75) %>% mutate(q = 75))

qplot %>% 
  mutate(q = as.factor(q)) %>% 
  ggplot(aes(x = x1, y = yhat, group = q, color = q)) +
  geom_line()

I believe SAS produces a similar plot in proc quantreg .

The 2 plots are likely to be similar but not the same because orm (cumulative probability model) uses a different modelling process from rq (quantile regression model) . In orm , predicted median values derive from the estimated conditional cumulative distribution function. Of interest, Figure 14 in Liu et al (2017) provides a comparison of conditional median values generated from the 2 models.

Reference
Liu Q, Shepherd BE, Li C, Harrell FE. Modeling continuous response variables using ordinal regression. Statistics in Medicine 2017 Nov 30;36(27):4316-4335. doi: 10.1002/sim.7433.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM