Skip to content
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
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to parameters

This outlines how to propose a change to **parameters**.
This outlines how to propose a change to **parameters**.

## Fixing typos

Expand All @@ -9,7 +9,7 @@ Small typos or grammatical errors in documentation may be edited directly using
## Filing an issue

The easiest way to propose a change or new feature is to file an issue. If you've found a
bug, you may also create an associated issue. If possible, try to illustrate your proposal or the bug with a minimal [reproducible example](https://www.tidyverse.org/help/#reprex).
bug, you may also create an associated issue. If possible, try to illustrate your proposal or the bug with a minimal reproducible example.

## Pull requests

Expand Down
6 changes: 2 additions & 4 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ Start by making a minimal **repr**oducible **ex**ample using the
[reprex](http://reprex.tidyverse.org/) package. If you haven't heard of or used
reprex before, you're in for a treat! Seriously, reprex will make all of your
R-question-asking endeavors easier (which is a pretty insane ROI for the five to
ten minutes it'll take you to learn what it's all about). For additional reprex
pointers, check out the [Get help!](https://www.tidyverse.org/help/) resource
used by the tidyverse team.
ten minutes it'll take you to learn what it's all about).

Armed with your reprex, the next step is to figure out where to ask:

Expand All @@ -26,4 +24,4 @@ default, the search will be pre-populated with `is:issue is:open`. You can
(e.g. `is:pr`, `is:closed`) as needed. For example, you'd simply
remove `is:open` to search _all_ issues in the repo, open or closed.

Thanks for your help!
Thanks for your help!
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.28.2.7
Version: 0.28.2.8
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ S3method(ci,systemfit)
S3method(ci,varest)
S3method(ci,zerocount)
S3method(ci,zeroinfl)
S3method(ci_kenward,default)
S3method(ci_kenward,glmmTMB)
S3method(cluster_discrimination,cluster_analysis)
S3method(cluster_discrimination,default)
S3method(cluster_performance,dbscan)
Expand All @@ -138,7 +140,6 @@ S3method(display,parameters_pca_summary)
S3method(display,parameters_sem)
S3method(display,parameters_simulate)
S3method(display,parameters_standardized)
S3method(dof_satterthwaite,lmerMod)
S3method(equivalence_test,MixMod)
S3method(equivalence_test,estimate_contrasts)
S3method(equivalence_test,estimate_means)
Expand Down Expand Up @@ -568,7 +569,6 @@ S3method(p_value,wbm)
S3method(p_value,zcpglm)
S3method(p_value,zerocount)
S3method(p_value,zeroinfl)
S3method(p_value_kenward,lmerMod)
S3method(plot,cluster_analysis)
S3method(plot,cluster_analysis_summary)
S3method(plot,compare_parameters)
Expand Down Expand Up @@ -660,6 +660,8 @@ S3method(reduce_parameters,lm)
S3method(reduce_parameters,merMod)
S3method(reshape_loadings,data.frame)
S3method(reshape_loadings,parameters_efa)
S3method(se_kenward,default)
S3method(se_kenward,glmmTMB)
S3method(se_satterthwaite,default)
S3method(select_parameters,lm)
S3method(select_parameters,merMod)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

* Added support for package *lcmm*.

* Added `ci_method` options `"kenward-roger"` and `"satterthwaite"` for models
from package *glmmTMB*. Consequently, `se_kenward()`, `se_satterthwaite()`,
`ci_kenward()`, `ci_satterthwaite()`, `p_value_kenward()` and
`p_value_satterthwaite()` can now be used with `glmmTMB` models.

# parameters 0.28.2

## Bug fixes
Expand Down
27 changes: 16 additions & 11 deletions R/ci_generic.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# generic function for CI calculation
.ci_generic <- function(model,
ci = 0.95,
method = "wald",
dof = NULL,
effects = "fixed",
component = "all",
vcov = NULL,
vcov_args = NULL,
verbose = TRUE,
...) {
.ci_generic <- function(
model,
ci = 0.95,
method = "wald",
dof = NULL,
effects = "fixed",
component = "all",
vcov = NULL,
vcov_args = NULL,
verbose = TRUE,
...
) {
# check method
if (is.null(method)) {
method <- "wald"
}
method <- tolower(method)
# fmt: skip
method <- insight::validate_argument(
method,
c(
Expand All @@ -23,6 +26,7 @@
)

effects <- insight::validate_argument(effects, c("fixed", "random", "all"))
# fmt: skip
component <- insight::validate_argument(
component,
c(
Expand All @@ -31,7 +35,8 @@
)
)

if (method == "ml1") { # nolint
if (method == "ml1") {

Check warning on line 38 in R/ci_generic.R

View workflow job for this annotation

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

file=R/ci_generic.R,line=38,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.

Check warning on line 38 in R/ci_generic.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/ci_generic.R,line=38,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.
# nolint
return(ci_ml1(model, ci = ci))
} else if (method == "betwithin") {
return(ci_betwithin(model, ci = ci))
Expand Down
42 changes: 39 additions & 3 deletions R/ci_kenward.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#' @rdname p_value_kenward
#' @export
ci_kenward <- function(model, ci = 0.95) {
.check_REML_fit(model)
ci_kenward <- function(model, ci = 0.95, ...) {
UseMethod("ci_kenward")
}

#' @export
ci_kenward.default <- function(model, ci = 0.95, ...) {
if (!.check_REML_fit(model)) {
model <- stats::update(model, . ~ ., REML = TRUE)
}

df_kr <- dof_kenward(model)
out <- lapply(ci, function(i) {
.ci_dof(
Expand All @@ -19,15 +27,43 @@
out
}

#' @export
ci_kenward.glmmTMB <- function(model, ci = 0.95, ...) {
if (!.check_REML_fit(model)) {
model <- stats::update(model, . ~ ., REML = TRUE)
}

df_kr <- dof_kenward(model)
out <- lapply(ci, function(i) {
.ci_dof(
model = model,
ci = i,
dof = df_kr,
effects = "fixed",
component = "conditional", # for glmmTMB, only conditional
method = "kenward",
se = attr(df_kr, "se", exact = TRUE)
)
})
out <- do.call(rbind, out)
row.names(out) <- NULL
out
}


.ci_kenward_dof <- function(model, ci = 0.95, df_kr) {

Check warning on line 54 in R/ci_kenward.R

View workflow job for this annotation

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

file=R/ci_kenward.R,line=54,col=47,[function_argument_linter] Arguments without defaults should come before arguments with defaults.

Check warning on line 54 in R/ci_kenward.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/ci_kenward.R,line=54,col=47,[function_argument_linter] Arguments without defaults should come before arguments with defaults.
if (inherits(model, "glmmTMB")) {
component <- "conditional"
} else {
component <- "all"
}
out <- lapply(ci, function(i) {
.ci_dof(
model = model,
ci = i,
dof = df_kr$df_error,
effects = "fixed",
component = "all",
component = component,
method = "kenward",
se = df_kr$SE
)
Expand Down
7 changes: 6 additions & 1 deletion R/ci_satterthwaite.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
#' @export
ci_satterthwaite <- function(model, ci = 0.95, ...) {
df_satter <- dof_satterthwaite(model)
if (inherits(model, "glmmTMB")) {
component <- "conditional"
} else {
component <- "all"
}
out <- lapply(ci, function(i) {
.ci_dof(
model = model,
ci = i,
dof = df_satter,
effects = "fixed",
component = "all",
component = component,
method = "satterthwaite",
...
)
Expand Down
2 changes: 1 addition & 1 deletion R/dof.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
if (!is.null(info) && isFALSE(info$is_mixed) && method == "boot") {
if (verbose) {
insight::format_alert(sprintf(
"`%s=boot` only works for mixed models of class `merMod`. To bootstrap this model, use `bootstrap=TRUE, ci_method=\"bcai\"`.",

Check warning on line 120 in R/dof.R

View workflow job for this annotation

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

file=R/dof.R,line=120,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 134 characters.
type
))
}
Expand All @@ -132,7 +132,7 @@
))) {
if (verbose) {
insight::format_alert(sprintf(
"`%s` must be one of \"residual\", \"wald\", \"normal\", \"profile\", \"boot\", \"uniroot\", \"betwithin\" or \"ml1\". Using \"wald\" now.",

Check warning on line 135 in R/dof.R

View workflow job for this annotation

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

file=R/dof.R,line=135,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 150 characters.
type
))
}
Expand All @@ -149,12 +149,12 @@
))) {
if (verbose) {
insight::format_alert(sprintf(
"`%s` must be one of \"residual\", \"wald\", \"normal\", \"profile\", \"boot\", \"uniroot\", \"kenward\", \"satterthwaite\", \"betwithin\" or \"ml1\". Using \"wald\" now.",

Check warning on line 152 in R/dof.R

View workflow job for this annotation

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

file=R/dof.R,line=152,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 180 characters.
type
))
}
return(FALSE)
}
}

if (!info$is_linear && method %in% c("satterthwaite", "kenward", "kr")) {
if (verbose) {
Expand All @@ -166,5 +166,5 @@
return(FALSE)
}

return(TRUE)

Check warning on line 169 in R/dof.R

View workflow job for this annotation

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

file=R/dof.R,line=169,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}
Loading
Loading