Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dcchoice #817

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.6.2
Version: 0.19.6.3
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 @@ -1051,6 +1051,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 @@ -1170,6 +1171,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 @@ -1301,6 +1303,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 @@ -1442,6 +1445,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 @@
#' @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 Expand Up @@ -134,7 +142,7 @@

#' @export
n_obs.gam <- function(x, ...) {
if (!is.null(dim(x$y))) {

Check warning on line 145 in R/n_obs.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/n_obs.R,line=145,col=7,[if_not_else_linter] In a simple if/else statement, prefer `if (A) x else y` to the less-readable `if (!A) y else x`.
dim(x$y)[1]
} else {
length(x$y)
Expand Down
Loading