Skip to content

Commit

Permalink
Merge branch 'main' into use_check_arg
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Oct 19, 2024
2 parents 29419f3 + a7b97a5 commit f968cd0
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: parameters
Title: Processing of Model Parameters
Version: 0.23.0.1
Version: 0.23.0.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
4 changes: 2 additions & 2 deletions R/3_p_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ p_value.default <- function(model,
method <- "wald"
}

# robust standard errors with backward compatibility for `robust = TRUE`
if (!is.null(vcov) || isTRUE(dots[["robust"]])) {
# robust standard errors
if (!is.null(vcov)) {
method <- "robust"
}

Expand Down
7 changes: 4 additions & 3 deletions R/4_standard_error.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#' - Bootstrap: `"BS"`, `"xy"`, `"residual"`, `"wild"`, `"mammen"`,
#' `"fractional"`, `"jackknife"`, `"norm"`, `"webb"`.
#' See `?sandwich::vcovBS`
#' - Other `sandwich` package functions: `"HAC"`, `"PC"`, `"vCL"`, `"PL"`.
#' - Other `sandwich` package functions: `"HAC"`, `"PC"`, `"CL"`, `"OPG"`,
#' `"PL"`.
#' @param vcov_args List of arguments to be passed to the function identified by
#' the `vcov` argument. This function is typically supplied by the
#' **sandwich** or **clubSandwich** packages. Please refer to their
Expand Down Expand Up @@ -100,8 +101,8 @@ standard_error.default <- function(model,
se <- .safe(sqrt(diag(do.call("vcov", fun_args))))
}

# vcov: character (with backward compatibility for `robust = TRUE`)
if (is.character(vcov) || isTRUE(dots[["robust"]])) {
# vcov: character
if (is.character(vcov)) {
.vcov <- insight::get_varcov(
model,
component = component,
Expand Down
3 changes: 1 addition & 2 deletions R/extract_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@

# ==== test statistic - fix values for robust vcov

# deprecated argument `robust = TRUE`
if (!is.null(vcov) || isTRUE(dots[["robust"]])) {
if (!is.null(vcov)) {
parameters$Statistic <- parameters$Estimate / parameters$SE
} else if (!is.null(statistic)) {
parameters <- merge(parameters, statistic, by = merge_by, sort = FALSE)
Expand Down
4 changes: 2 additions & 2 deletions R/methods_nestedLogit.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ standard_error.nestedLogit <- function(model,
se <- .safe(sqrt(diag(do.call("vcov", fun_args))))
}

# vcov: character (with backward compatibility for `robust = TRUE`)
if (is.character(vcov) || isTRUE(dots[["robust"]])) {
# vcov: character
if (is.character(vcov)) {
.vcov <- insight::get_varcov(
model,
component = component,
Expand Down
2 changes: 1 addition & 1 deletion R/p_value_kenward.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ p_value_kenward.lmerMod <- function(model, dof = NULL) {
if (is.null(se)) {
se <- se_kenward(model)$SE
}
} else if (!is.null(vcov) || isTRUE(list(...)[["robust"]])) {
} else if (!is.null(vcov)) {
se <- standard_error(model,
vcov = vcov,
vcov_args = vcov_args,
Expand Down
6 changes: 3 additions & 3 deletions R/standardize_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#' @param ... Arguments passed to or from other methods.
#'
#' @return A data frame with information on each parameter (see
#' [parameters_type()]), and various standardization coefficients
#' for the post-hoc methods (see [standardize_parameters()]) for the predictor
#' and the response.
#' [`parameters_type()`]), and various standardization coefficients
#' for the post-hoc methods (see [`standardize_parameters()`]) for the predictor
#' and the response.
#'
#' @family standardize
#'
Expand Down
3 changes: 2 additions & 1 deletion man/equivalence_test.lm.Rd

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

3 changes: 2 additions & 1 deletion man/model_parameters.default.Rd

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

3 changes: 2 additions & 1 deletion man/model_parameters.merMod.Rd

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

3 changes: 2 additions & 1 deletion man/model_parameters.mlm.Rd

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

3 changes: 2 additions & 1 deletion man/p_direction.lm.Rd

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

3 changes: 2 additions & 1 deletion man/p_function.Rd

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

3 changes: 2 additions & 1 deletion man/p_significance.lm.Rd

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

3 changes: 2 additions & 1 deletion man/p_value.Rd

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

3 changes: 2 additions & 1 deletion man/standard_error.Rd

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

1 change: 0 additions & 1 deletion tests/testthat/test-model_parameters_robust.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ mtcars$am <- as.factor(mtcars$am)
model <- lm(mpg ~ wt * am + cyl + gear, data = mtcars)

test_that("model_parameters, robust", {
expect_warning(expect_warning(expect_warning(model_parameters(model, robust = TRUE))))
params <- model_parameters(model, vcov = "HC3")
robust_se <- unname(sqrt(diag(sandwich::vcovHC(model))))
expect_equal(params$SE, robust_se, tolerance = 1e-3)
Expand Down
8 changes: 0 additions & 8 deletions vignettes/model_parameters_robust.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ The computation of robust standard errors is controlled by two arguments:

### Robust Covariance Matrix Estimation from Model Parameters

There are two arguments (see
[`?standard_error`](https://easystats.github.io/parameters/reference/standard_error.html)
for further details) that allow for choosing different methods and options of
robust estimation:

- `vcov`
- `vcov_args`

Let us start with a simple example, which uses a heteroskedasticity-consistent
covariance matrix estimation with estimation-type "HC3" (i.e.
`sandwich::vcovHC(type = "HC3")`).
Expand Down

0 comments on commit f968cd0

Please sign in to comment.