Skip to content

prediction() does not compute standard errors for ordered logit models #48

@matguidi

Description

@matguidi

I can't compute the standard errors of predicted probabilities for an ordered logit model. I have tried both MASS::polr and ordinal::clm. The regression models run fine. When prediction::prediction() is run, the predicted probabilities are calculated, but not the SEs (and, consequently, no p-value, no lower and upper bound of prediction).

Here a silly but reproducible example:

library(prediction)
library(tidyverse)
library(MASS)
library(ordinal)

polr(as.factor(cyl) ~ displ + cty, data = mpg) -> ol1
summary(ol1)

prediction(ol1,
           at = list(
             displ = seq(min(mpg$displ), max(mpg$displ), by = 0.2)
           ),
           calculate_se = T, 
           category = "6") %>% 
  summary()

clm(as.factor(cyl) ~ displ + cty, data = mpg) -> ol2
summary(ol2)

prediction(ol2,
           at = list(
             displ = seq(min(mpg$displ), max(mpg$displ), by = 0.2)
           ),
           calculate_se = T,
           category = "6") %>% 
  summary()

I notice that prediction with the clm object is considerably slower. Also, prediction in that case doesn't pick up any value I assign to category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions