insight icon indicating copy to clipboard operation
insight copied to clipboard

`model_info(model)$is_linear` should be `FALSE` with `mblogit()`

Open vincentarelbundock opened this issue 1 year ago • 6 comments

I don't really understand the family code in model_info, but here's a test:

test_that("mblogit is not linear", {
  requiet("mclogit")
  mod <- mblogit(factor(gear) ~ mpg + hp, data = mtcars, trace = FALSE)
  expect_false(model_info(mod)$is_linear)
})

vincentarelbundock avatar Sep 02 '22 14:09 vincentarelbundock

library("mclogit")
#> Loading required package: Matrix
mod <- mblogit(factor(gear) ~ mpg + hp, data = mtcars, trace = FALSE)
inherits(mod, "lm")
#> [1] TRUE
family(mod)
#> 
#> Family: gaussian 
#> Link function: identity

Created on 2022-09-02 with reprex v2.0.2

strengejacke avatar Sep 02 '22 17:09 strengejacke

Yes, the model object inherits from lm (perhaps to leverage existing methods?), but it is not in fact linear.

vincentarelbundock avatar Sep 02 '22 17:09 vincentarelbundock

but family is gaussian and link is identity?

strengejacke avatar Sep 02 '22 17:09 strengejacke

No, all those are erroneous, I think. This is a multinomial logit model:

https://www.rdocumentation.org/packages/mclogit/versions/0.9.4.2/topics/mblogit

vincentarelbundock avatar Sep 02 '22 18:09 vincentarelbundock

Categorical or multinomial? :-) I fixed this for mclogit and mblogit, and also link_inverse(). Must add tests, though, to check whether the results are ok.

strengejacke avatar Sep 02 '22 18:09 strengejacke

I wonder whether a similar issue is at play for models with family = gaussian(link = 'log'). For models with this family, I dont seem to be able to obtain modelbased::estimate_link or insight::get_predict(predict = "link") values on the link scale.

pcinereus avatar Jul 18 '23 10:07 pcinereus