Skip to content

Commit

Permalink
Support dcchoice
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 6, 2023
1 parent e87e9e0 commit bfb28b1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: insight
Title: Easy Access to Model Information for Various Model Objects
Version: 0.19.5.12
Version: 0.19.5.13
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ S3method(link_function,cph)
S3method(link_function,crch)
S3method(link_function,crq)
S3method(link_function,crqs)
S3method(link_function,dbchoice)
S3method(link_function,default)
S3method(link_function,feglm)
S3method(link_function,feis)
Expand Down Expand Up @@ -1168,6 +1169,7 @@ S3method(link_inverse,cph)
S3method(link_inverse,crch)
S3method(link_inverse,crq)
S3method(link_inverse,crqs)
S3method(link_inverse,dbchoice)
S3method(link_inverse,default)
S3method(link_inverse,feglm)
S3method(link_inverse,feis)
Expand Down Expand Up @@ -1299,6 +1301,7 @@ S3method(model_info,crch)
S3method(model_info,crq)
S3method(model_info,crqs)
S3method(model_info,data.frame)
S3method(model_info,dbchoice)
S3method(model_info,default)
S3method(model_info,deltaMethod)
S3method(model_info,earth)
Expand Down Expand Up @@ -1439,6 +1442,7 @@ S3method(n_obs,cpglmm)
S3method(n_obs,crq)
S3method(n_obs,crqs)
S3method(n_obs,crr)
S3method(n_obs,dbchoice)
S3method(n_obs,default)
S3method(n_obs,eglm)
S3method(n_obs,emm_list)
Expand Down
6 changes: 6 additions & 0 deletions R/link_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ link_function.model_fit <- link_function.logitmfx
# Other models -----------------------------


#' @export
link_function.dbchoice <- function(x, ...) {
x$f.stage$family$linkfun
}


#' @export
link_function.Rchoice <- function(x, ...) {
stats::make.link(link = x$link)$linkfun
Expand Down
6 changes: 6 additions & 0 deletions R/link_inverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ link_inverse.negbinirr <- link_inverse.logitmfx

# Other models ----------------------------

#' @export
link_inverse.dbchoice <- function(x, ...) {
x$f.stage$family$linkinv
}


#' @export
link_inverse.Rchoice <- function(x, ...) {
stats::make.link(link = x$link)$linkinv
Expand Down
14 changes: 14 additions & 0 deletions R/model_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,20 @@ model_info.Rchoice <- function(x, ...) {
}


#' @export
model_info.dbchoice <- function(x, ...) {
faminfo <- x$f.stage$family
.make_family(
x = x,
fitfam = faminfo$family,
logit.link = faminfo$link == "logit",
multi.var = FALSE,
link.fun = faminfo$link,
...
)
}


#' @export
model_info.ivprobit <- function(x, ...) {
.make_family(
Expand Down
8 changes: 8 additions & 0 deletions R/n_obs.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,19 @@ n_obs.glm <- function(x, disaggregate = FALSE, ...) {
#' @export
n_obs.censReg <- n_obs.default


#' @export
n_obs.nestedLogit <- function(x, disaggregate = FALSE, ...) {
lapply(x$models, n_obs)
}


#' @export
n_obs.dbchoice <- function(x, ...) {
stats::nobs(x)
}


#' @rdname n_obs
#' @export
n_obs.svyolr <- function(x, weighted = FALSE, ...) {
Expand Down

0 comments on commit bfb28b1

Please sign in to comment.