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

p_function() gets vcov-args #1013

Merged
merged 4 commits into from
Sep 16, 2024
Merged
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: parameters
Title: Processing of Model Parameters
Version: 0.22.2.7
Version: 0.22.2.8
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
way to test the direction of the effect, which formerly was already (and still
is) possible with `pd = TRUE` in `model_parameters()`.

* `p_function()` gets a `vcov` and `vcov_args` argument to compute robust
standard errors for the confidence curves.

* Revision / enhancement of some documentation.

# parameters 0.22.2

## New supported models
Expand Down
7 changes: 6 additions & 1 deletion R/p_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#' @inheritParams model_parameters
#' @inheritParams model_parameters.default
#' @inheritParams model_parameters.glmmTMB
#' @inheritParams standard_error
#'
#' @note
#' Curently, `p_function()` computes intervals based on Wald t- or z-statistic.
Expand Down Expand Up @@ -61,7 +62,7 @@
#' (i.e. assumptions are taken as given). The unconditional interpretation (B),
#' however, questions all these assumptions.
#'
#' \if{html}{\cr \figure{unconditional_interpretation.png}{options: alt="Conditional versus unconditional interpretations of P-values"} \cr}

Check warning on line 65 in R/p_function.R

View workflow job for this annotation

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

file=R/p_function.R,line=65,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 140 characters.
#'
#' "Emphasizing unconditional interpretations helps avoid overconfident and
#' misleading inferences in light of uncertainties about the assumptions used
Expand Down Expand Up @@ -223,6 +224,8 @@
exponentiate = FALSE,
effects = "fixed",
component = "all",
vcov = NULL,
vcov_args = NULL,
keep = NULL,
drop = NULL,
verbose = TRUE,
Expand All @@ -234,7 +237,9 @@
se <- standard_error(
model,
effects = effects,
component = component
component = component,
vcov = vcov,
vcov_args = vcov_args
)$SE

if (is.null(dof) || length(dof) == 0 || .is_chi2_model(model, dof)) {
Expand Down
31 changes: 31 additions & 0 deletions man/p_function.Rd

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

20 changes: 20 additions & 0 deletions tests/testthat/test-p_function.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
skip_if_not_installed("sandwich")

data(iris)
model <- lm(Sepal.Length ~ Species, data = iris)

test_that("p_function ci-levels", {
out <- p_function(model)
expect_equal(
out$CI_low,
c(
4.982759, 0.897132, 1.549132, 4.956774, 0.860384, 1.512384,
4.92192, 0.811093, 1.463093, 4.862126, 0.726531, 1.378531
),
tolerance = 1e-4
)

expect_identical(dim(out), c(12L, 5L))

Expand Down Expand Up @@ -32,6 +42,16 @@ test_that("p_function ci-levels", {
c(0.3, 0.3, 0.3, 0.6, 0.6, 0.6, 0.9, 0.9, 0.9),
tolerance = 1e-4
)

out <- p_function(model, vcov = "HC3")
expect_equal(
out$CI_low,
c(
4.989925, 0.901495, 1.548843, 4.971951, 0.869624, 1.511772,
4.947844, 0.826875, 1.462047, 4.906485, 0.753538, 1.376742
),
tolerance = 1e-4
)
})


Expand Down
Loading