m1 <- mlogit::mlogit(mode ~ price + catch, data = Fish)
m2 <- mlogit::mlogit(mode ~ price + catch | income, data = Fish)
expect_identical(find_predictors(m1), list(conditional = c("price", "catch")))
expect_identical(find_predictors(m1, flatten = TRUE), c("price", "catch"))
expect_identical(find_predictors(m2), list(conditional = c("price", "catch", "income")))
expect_identical(nrow(get_data(m1, verbose = FALSE)), 4728L)
expect_identical(nrow(get_data(m2, verbose = FALSE)), 4728L)
if (packageVersion("mlogit") <= "1.0-3.1") {
c("mode", "price", "catch", "probabilities", "linpred")
c("mode", "price", "catch", "idx", "probabilities", "linpred")
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
expect_equal(link_inverse(m2)(0.2), plogis(0.2), tolerance = 1e-5)
expect_identical(find_terms(m1, flatten = TRUE), c("mode", "price", "catch"))
conditional = c("price", "catch", "income")