2

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's plot Page 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.

2
  • 1
    It's not clear whether this is a statistical or programming question. To help us decide, could you tell us what you mean by "not quite the same"? What is different and what kind of solution do you think might apply (statistical clarification or programming help)? Commented Jan 16, 2020 at 18:54
  • 1
    I suppose is slightly more programming than statistical. Commented Jan 17, 2020 at 14:38

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.