easystats / easystats/performance

Cannot check model from mgcv and categorical outcome

Open
#794 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.2k
Forks
109
Avg merge
6h 34m
Merged PRs (30d)
8

Description

Reproducible example:

library(mgcv)
library(performance)

df <- mtcars |>
  tibble::as_tibble() |>
  dplyr::mutate(carb = as.integer(carb))

model <- mgcv::gam(
  carb~s(wt, k=5),
  data = df,
  family = mgcv::ocat(R=8)
)

plot(check_model(model))

Error:

Error in d[, !(names(data) %in% all.varying), drop = FALSE] : 
  incorrect number of dimensions

It seems that there is something wrong when using mgcv and ocat. Nevertheless, I can use MASS and ordinal regression:

df <- mtcars |>
  tibble::as_tibble() |>
  dplyr::mutate(carb = as.factor(carb))
model <- MASS::polr(
  carb~wt,
  data = df,
  Hess = TRUE
)
plot(check_model(model))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproducible mgcv::gam example with performance::check_model() and inspect the handling of categorical outcomes from mgcv::ocat models. Done means check_model(model) completes without the dimensionality error and produces the diagnostic plot shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.