Skip to content

Commit

Permalink
Support DCchoice
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Aug 1, 2023
1 parent 7814bb8 commit d104851
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions R/sanity_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ sanity_model_supported_class <- function(model) {
c("negbin", "glm", "lm"),
c("ols", "rms", "lm"),
c("orm", "rms"),
c("oohbchoice", "dbchoice"),
"phylolm",
"phyloglm",
c("plm", "panelmodel"),
Expand Down
2 changes: 2 additions & 0 deletions R/type_dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ mlogit,response
negbin,response
negbin,link
ols,lp
"oohbchoice", "probability",
"oohbchoice", "utility",
orm,fitted
orm,mean
orm,lp
Expand Down
1 change: 1 addition & 0 deletions data-raw/supported_models.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ brglm2,brmultinom,TRUE,TRUE,,,U,U,U,U
brms,brm,TRUE,TRUE,,,U,U,TRUE,TRUE
crch,crch,TRUE,TRUE,,,U,U,U,U
crch,hxlr,TRUE,TRUE,,,U,U,U,U
DCchoice,oohbchoice,TRUE,TRUE,,,,,,
estimatr,lm_lin,TRUE,TRUE,,,,,,
estimatr,lm_robust,TRUE,TRUE,TRUE,TRUE,TRUE,U,TRUE,TRUE
estimatr,iv_robust,TRUE,TRUE,TRUE,TRUE,U,U,U,U
Expand Down
24 changes: 24 additions & 0 deletions inst/tinytest/test-pkg-DCchoice.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# No validity test whatsoever

source("helpers.R")
using("marginaleffects")
requiet("DCchoice")

data(oohbsyn)
mod <- oohbchoice(R1 + R2 ~ age + gender | log(BL) + log(BH), data = oohbsyn)

# weird result seems to make sense manually
p1 <- transform(oohbsyn, BH = 5)
p2 <- transform(oohbsyn, BH = 7)
p1 <- predict(mod, newdata = p1)
p2 <- predict(mod, newdata = p2)
bh_comparison <- p2 - p1
expect_true(all(bh_comparison == 0))

slo <- avg_slopes(mod)
pre <- predictions(mod, by = "gender")
cmp <- comparisons(mod)

expect_inherits(cmp, "comparisons")
expect_inherits(pre, "predictions")
expect_inherits(slo, "slopes")
2 changes: 1 addition & 1 deletion man/comparisons.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/marginal_means.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/marginalmeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/predictions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/slopes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d104851

Please sign in to comment.