Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 19, 2024
1 parent ad962ed commit e99200d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 55 deletions.
12 changes: 9 additions & 3 deletions R/5_simulate_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#' @inheritParams bootstrap_model
#' @inheritParams p_value
#'
#' @inheritSection model_parameters.zcpglm Model components
#'
#' @return A data frame.
#'
#' @seealso [`simulate_parameters()`], [`bootstrap_model()`], [`bootstrap_parameters()`]
Expand Down Expand Up @@ -57,9 +59,9 @@ simulate_model <- function(model, iterations = 1000, ...) {

# Models with single component only -----------------------------------------


#' @rdname simulate_model
#' @export
simulate_model.default <- function(model, iterations = 1000, ...) {
simulate_model.default <- function(model, iterations = 1000, component = "all", ...) {
# check for valid input
.is_model_valid(model)

Expand Down Expand Up @@ -229,7 +231,11 @@ simulate_model.bracl <- simulate_model.default
# helper -----------------------------------------


.simulate_model <- function(model, iterations, component = "conditional", effects = "fixed", ...) {
.simulate_model <- function(model,
iterations,
component = "conditional",
effects = "fixed",
...) {
if (is.null(iterations)) iterations <- 1000

params <- insight::get_parameters(model, effects = effects, component = component, verbose = FALSE)
Expand Down
26 changes: 8 additions & 18 deletions R/methods_betareg.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ model_parameters.betareg <- function(model,


#' @export
ci.betareg <- function(x,
ci = 0.95,
component = "all",
verbose = TRUE,
...) {
ci.betareg <- function(x, ci = 0.95, component = "all", verbose = TRUE, ...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
Expand All @@ -83,10 +79,7 @@ ci.betareg <- function(x,


#' @export
standard_error.betareg <- function(model,
component = "all",
verbose = TRUE,
...) {
standard_error.betareg <- function(model, component = "all", verbose = TRUE, ...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
Expand Down Expand Up @@ -117,10 +110,7 @@ standard_error.betareg <- function(model,


#' @export
p_value.betareg <- function(model,
component = "all",
verbose = TRUE,
...) {
p_value.betareg <- function(model, component = "all", verbose = TRUE, ...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
Expand Down Expand Up @@ -154,11 +144,11 @@ p_value.betareg <- function(model,


#' @export
simulate_model.betareg <- function(model,
iterations = 1000,
component = c("all", "conditional", "precision"),
...) {
component <- match.arg(component)
simulate_model.betareg <- function(model, iterations = 1000, component = "all", ...) {
component <- insight::validate_argument(
component,
c("all", "conditional", "precision")
)
out <- .simulate_model(model, iterations, component = component, ...)

class(out) <- c("parameters_simulate_model", class(out))
Expand Down
3 changes: 0 additions & 3 deletions R/methods_glmmTMB.R
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ standard_error.glmmTMB <- function(model,
# simulate model -----


#' @rdname simulate_model
#' @export
simulate_model.glmmTMB <- function(model,
iterations = 1000,
Expand Down Expand Up @@ -632,8 +631,6 @@ simulate_model.glmmTMB <- function(model,

# simulate_parameters -----


#' @rdname simulate_parameters
#' @export
simulate_parameters.glmmTMB <- function(model,
iterations = 1000,
Expand Down
7 changes: 5 additions & 2 deletions R/methods_glmx.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ p_value.glmx <- function(model, ...) {


#' @export
simulate_model.glmx <- function(model, iterations = 1000, component = c("all", "conditional", "extra"), ...) {
component <- match.arg(component)
simulate_model.glmx <- function(model, iterations = 1000, component = "all", ...) {
component <- insight::validate_argument(
component,
c("all", "conditional", "extra")
)
out <- .simulate_model(model, iterations, component = component, ...)

class(out) <- c("parameters_simulate_model", class(out))
Expand Down
2 changes: 0 additions & 2 deletions R/simulate_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ simulate_parameters <- function(model, ...) {
}




#' @rdname simulate_parameters
#' @export
simulate_parameters.default <- function(model,
Expand Down
58 changes: 47 additions & 11 deletions man/simulate_model.Rd

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

21 changes: 5 additions & 16 deletions man/simulate_parameters.Rd

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

0 comments on commit e99200d

Please sign in to comment.