leeper / prediction

Tidy, Type-Safe 'prediction()' Methods

Home Page:https://cran.r-project.org/package=prediction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

matguidi opened this issue · comments

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.