Skip to content

Commit

Permalink
Merge branch 'main' into strengejacke/issue954
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Nov 7, 2024
2 parents e63e386 + 8739518 commit c6f67c7
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 89 deletions.
9 changes: 6 additions & 3 deletions R/find_parameters_other.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#' @inheritParams find_parameters.betamfx
#' @inheritParams find_predictors
#'
#' @inheritSection find_predictors Model components
#'
#' @return A list of parameter names. The returned list may have following
#' elements, usually requested via the `component` argument:
#'
Expand All @@ -18,10 +20,11 @@
#' - `survival` for model of class `mjoint`.
#' - `extra` for models of class `glmx`.
#'
#' @examples
#' data(mtcars)
#' m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
#' @examplesIf requireNamespace("betareg", quietly = TRUE)
#' data("GasolineYield", package = "betareg")
#' m <- betareg::betareg(yield ~ batch + temp, data = GasolineYield)
#' find_parameters(m)
#' find_parameters(m, component = "precision")
#' @export
find_parameters.averaging <- function(x, component = "conditional", flatten = FALSE, ...) {
component <- validate_argument(component, c("conditional", "full"))
Expand Down
3 changes: 3 additions & 0 deletions R/find_predictors.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
#' - **averaging**:`"conditional"` and `"full"`
#' - **mjoint**: `"survival"`
#' - **mfx**: `"precision"`, `"marginal"`
#' - **betareg**, **DirichletRegModel**: `"precision"`
#' - **mvord**: `"thresholds"` and `"correlation"`
#' - **clm2**: `"scale"`
#'
#' For models of class `brmsfit` (package **brms**), `component`, even more
#' options are possible for the `component` argument, which are not all
Expand Down
75 changes: 33 additions & 42 deletions R/get_parameters_others.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
#' @return A data frame with three columns: the parameter names, the related
#' point estimates and the component.
#'
#' @examples
#' data(mtcars)
#' m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
#' @examplesIf requireNamespace("betareg", quietly = TRUE)
#' data("GasolineYield", package = "betareg")
#' m <- betareg::betareg(yield ~ batch + temp, data = GasolineYield)
#' get_parameters(m)
#' get_parameters(m, component = "precision")
#' @export
get_parameters.betareg <- function(x,
component = c("all", "conditional", "precision", "location", "distributional", "auxiliary"),
...) {
component <- match.arg(component)
get_parameters.betareg <- function(x, component = "all", ...) {
component <- validate_argument(
component,
c("all", "conditional", "precision", "location", "distributional", "auxiliary")
)
cf <- stats::coef(x)

params <- data.frame(
Expand All @@ -40,10 +42,9 @@ get_parameters.betareg <- function(x,
}


#' @rdname get_parameters.betareg
#' @export
get_parameters.glmgee <- function(x, component = c("all", "conditional", "dispersion"), ...) {
component <- match.arg(component)
get_parameters.glmgee <- function(x, component = "all", ...) {
component <- validate_argument(component, c("all", "conditional", "dispersion"))

junk <- utils::capture.output({
cs <- suppressWarnings(stats::coef(summary(x, corr = FALSE)))
Expand Down Expand Up @@ -99,12 +100,12 @@ get_parameters.nestedLogit <- function(x, component = "all", verbose = TRUE, ...
}


#' @rdname get_parameters.betareg
#' @export
get_parameters.DirichletRegModel <- function(x,
component = c("all", "conditional", "precision", "location", "distributional", "auxiliary"),
...) {
component <- match.arg(component)
get_parameters.DirichletRegModel <- function(x, component = "all", ...) {
component <- validate_argument(
component,
c("all", "conditional", "precision", "location", "distributional", "auxiliary")
)
cf <- stats::coef(x)

if (x$parametrization == "common") {
Expand Down Expand Up @@ -139,12 +140,9 @@ get_parameters.DirichletRegModel <- function(x,
}


#' @rdname get_parameters.betareg
#' @export
get_parameters.averaging <- function(x,
component = c("conditional", "full"),
...) {
component <- match.arg(component)
get_parameters.averaging <- function(x, component = "conditional", ...) {
component <- validate_argument(component, c("conditional", "full"))
cf <- stats::coef(x, full = component == "full")

params <- data.frame(
Expand All @@ -158,12 +156,12 @@ get_parameters.averaging <- function(x,
}


#' @rdname get_parameters.betareg
#' @export
get_parameters.glmx <- function(x,
component = c("all", "conditional", "extra", "location", "distributional", "auxiliary"),
...) {
component <- match.arg(component)
get_parameters.glmx <- function(x, component = "all", ...) {
component <- validate_argument(
component,
c("all", "conditional", "extra", "location", "distributional", "auxiliary")
)
cf <- stats::coef(summary(x))

params <- rbind(
Expand Down Expand Up @@ -191,12 +189,9 @@ get_parameters.glmx <- function(x,
}


#' @rdname get_parameters.betareg
#' @export
get_parameters.clm2 <- function(x,
component = c("all", "conditional", "scale"),
...) {
component <- match.arg(component)
get_parameters.clm2 <- function(x, component = "all", ...) {
component <- validate_argument(component,c("all", "conditional", "scale"))

cf <- stats::coef(summary(x))
n_intercepts <- length(x$xi)
Expand All @@ -223,12 +218,12 @@ get_parameters.clm2 <- function(x,
get_parameters.clmm2 <- get_parameters.clm2


#' @rdname get_parameters.betareg
#' @export
get_parameters.mvord <- function(x,
component = c("all", "conditional", "thresholds", "correlation"),
...) {
component <- match.arg(component)
get_parameters.mvord <- function(x, component = "all", ...) {
component <- validate_argument(
component,
c("all", "conditional", "thresholds", "correlation")
)
junk <- utils::capture.output(s <- summary(x)) # nolint
# intercepts thresholds
thresholds <- as.data.frame(s$thresholds)
Expand Down Expand Up @@ -278,13 +273,9 @@ get_parameters.mvord <- function(x,
}



#' @rdname get_parameters.betareg
#' @export
get_parameters.mjoint <- function(x,
component = c("all", "conditional", "survival"),
...) {
component <- match.arg(component)
get_parameters.mjoint <- function(x, component = "all", ...) {
component <- validate_argument(component, c("all", "conditional", "survival"))
s <- summary(x)

params <- rbind(
Expand Down Expand Up @@ -312,7 +303,6 @@ get_parameters.mjoint <- function(x,
}



#' @export
get_parameters.systemfit <- function(x, ...) {
cf <- stats::coef(summary(x))
Expand All @@ -335,6 +325,7 @@ get_parameters.systemfit <- function(x, ...) {
do.call(rbind, out)
}


#' @export
get_parameters.marginaleffects <- function(x, summary = FALSE, merge_parameters = FALSE, ...) {
# check if we have a Bayesian model here
Expand Down
3 changes: 3 additions & 0 deletions man/find_parameters.Rd

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

56 changes: 54 additions & 2 deletions man/find_parameters.averaging.Rd

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

3 changes: 3 additions & 0 deletions man/find_parameters.betamfx.Rd

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

3 changes: 3 additions & 0 deletions man/find_parameters.glmmTMB.Rd

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

3 changes: 3 additions & 0 deletions man/find_parameters.zeroinfl.Rd

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

3 changes: 3 additions & 0 deletions man/find_predictors.Rd

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

3 changes: 3 additions & 0 deletions man/find_variables.Rd

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

3 changes: 3 additions & 0 deletions man/get_data.Rd

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

3 changes: 3 additions & 0 deletions man/get_parameters.BGGM.Rd

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

3 changes: 3 additions & 0 deletions man/get_parameters.Rd

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

3 changes: 3 additions & 0 deletions man/get_parameters.betamfx.Rd

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

Loading

0 comments on commit c6f67c7

Please sign in to comment.