Skip to content

Commit

Permalink
CRAN submission 0.21.2 (#903)
Browse files Browse the repository at this point in the history
* CRAN submission 0.21.2

* styler

* styler

* lintr

* lintr

* clean up description

* skip test on R < 4.2

* examplesIf

* fix test

* fix test

* examplesIf

* fix issues

* revert

* linte

* update cran comments

* update gitiognore

* remove revdep

* submitted
  • Loading branch information
strengejacke authored Sep 16, 2023
1 parent 1bb0cd6 commit 700067b
Show file tree
Hide file tree
Showing 35 changed files with 255 additions and 272 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# Output files from R CMD check
/*.Rcheck/
revdep/

# RStudio files
.Rproj.user/
Expand Down
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.21.1
Date: 2023-05-26 09:34:52 UTC
SHA: 7ad4819088d188babebe5de6880d1230782b32ec
Version: 0.21.2
Date: 2023-09-16 12:58:15 UTC
SHA: a1a80b72020f0287b81563a419eddb36f59fa18d
5 changes: 2 additions & 3 deletions 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.21.1.9
Version: 0.21.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -81,7 +81,7 @@ Depends:
Imports:
bayestestR (>= 0.13.0),
datawizard (>= 0.7.0),
insight (>= 0.19.3.2),
insight (>= 0.19.4),
graphics,
methods,
stats,
Expand Down Expand Up @@ -213,4 +213,3 @@ Config/Needs/website:
r-lib/pkgdown,
easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/insight
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
accepts the `exponentiate` argument.

* The `print()`, `print_html()`, `print_md()` and `format()` methods for
`model_parameters()` get an `add_reference` argument, to add the reference
`model_parameters()` get an `include_reference` argument, to add the reference
category of categorical predictors to the parameters table.

## Bug fixes
Expand Down
34 changes: 14 additions & 20 deletions R/1_model_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -418,29 +418,25 @@ parameters <- model_parameters
#'
#' @inheritSection model_parameters Confidence intervals and approximation of degrees of freedom
#'
#' @examples
#' @examplesIf require("boot", quietly = TRUE) && require("sandwich") && require("clubSandwich") && require("brglm2")
#' library(parameters)
#' model <- lm(mpg ~ wt + cyl, data = mtcars)
#'
#' model_parameters(model)
#'
#' # bootstrapped parameters
#' if (require("boot", quietly = TRUE)) {
#' model_parameters(model, bootstrap = TRUE)
#' }
#' model_parameters(model, bootstrap = TRUE)
#'
#' # standardized parameters
#' model_parameters(model, standardize = "refit")
#'
#' # robust, heteroskedasticity-consistent standard errors
#' if (require("sandwich") && require("clubSandwich")) {
#' model_parameters(model, vcov = "HC3")
#' model_parameters(model, vcov = "HC3")
#'
#' model_parameters(model,
#' vcov = "vcovCL",
#' vcov_args = list(cluster = mtcars$cyl)
#' )
#' }
#' model_parameters(model,
#' vcov = "vcovCL",
#' vcov_args = list(cluster = mtcars$cyl)
#' )
#'
#' # different p-value style in output
#' model_parameters(model, p_digits = 5)
Expand All @@ -454,15 +450,13 @@ parameters <- model_parameters
#' model_parameters(model, exponentiate = TRUE)
#'
#' # bias-corrected logistic regression with penalized maximum likelihood
#' if (require("brglm2")) {
#' model <- glm(
#' vs ~ wt + cyl,
#' data = mtcars,
#' family = "binomial",
#' method = "brglmFit"
#' )
#' model_parameters(model)
#' }
#' model <- glm(
#' vs ~ wt + cyl,
#' data = mtcars,
#' family = "binomial",
#' method = "brglmFit"
#' )
#' model_parameters(model)
#' }
#' @return A data frame of indices related to the model's parameters.
#' @export
Expand Down
21 changes: 10 additions & 11 deletions R/2_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@
#'
#' @inheritSection model_parameters Confidence intervals and approximation of degrees of freedom
#'
#' @examples
#' @examplesIf require("glmmTMB")
#' \donttest{
#' library(parameters)
#' if (require("glmmTMB")) {
#' model <- glmmTMB(
#' count ~ spp + mined + (1 | site),
#' ziformula = ~mined,
#' family = poisson(),
#' data = Salamanders
#' )
#' data(Salamanders, package = "glmmTMB")
#' model <- glmmTMB::glmmTMB(
#' count ~ spp + mined + (1 | site),
#' ziformula = ~mined,
#' family = poisson(),
#' data = Salamanders
#' )
#'
#' ci(model)
#' ci(model, component = "zi")
#' }
#' ci(model)
#' ci(model, component = "zi")
#' }
#' @export
ci.default <- function(x, ci = 0.95, dof = NULL, method = NULL, ...) {
Expand Down
16 changes: 6 additions & 10 deletions R/bootstrap_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@
#'
#' @seealso [`bootstrap_parameters()`], [`simulate_model()`], [`simulate_parameters()`]
#'
#' @examples
#' @examplesIf require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)
#' \dontrun{
#' if (require("boot", quietly = TRUE)) {
#' model <- lm(mpg ~ wt + factor(cyl), data = mtcars)
#' b <- bootstrap_model(model)
#' print(head(b))
#' model <- lm(mpg ~ wt + factor(cyl), data = mtcars)
#' b <- bootstrap_model(model)
#' print(head(b))
#'
#' if (require("emmeans", quietly = TRUE)) {
#' est <- emmeans(b, consec ~ cyl)
#' print(model_parameters(est))
#' }
#' }
#' est <- emmeans::emmeans(b, consec ~ cyl)
#' print(model_parameters(est))
#' }
#' @export
bootstrap_model <- function(model,
Expand Down
18 changes: 7 additions & 11 deletions R/bootstrap_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@
#' p-values can be biased, and it is suggested to use proper permutation tests
#' to obtain non-parametric p-values.
#'
#' @examples
#' @examplesIf require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)
#' \dontrun{
#' if (require("boot", quietly = TRUE)) {
#' set.seed(2)
#' model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris)
#' b <- bootstrap_parameters(model)
#' print(b)
#' set.seed(2)
#' model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris)
#' b <- bootstrap_parameters(model)
#' print(b)
#'
#' if (require("emmeans")) {
#' est <- emmeans(b, trt.vs.ctrl ~ Species)
#' print(model_parameters(est))
#' }
#' }
#' est <- emmeans::emmeans(b, trt.vs.ctrl ~ Species)
#' print(model_parameters(est))
#' }
#' @export
bootstrap_parameters <- function(model,
Expand Down
12 changes: 5 additions & 7 deletions R/cluster_discrimination.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
#' [`performance::check_clusterstructure()`] to check suitability of data for
#' clustering.
#'
#' @examples
#' if (requireNamespace("MASS", quietly = TRUE)) {
#' # Retrieve group classification from hierarchical cluster analysis
#' clustering <- cluster_analysis(iris[, 1:4], n = 3)
#' @examplesIf requireNamespace("MASS", quietly = TRUE)
#' # Retrieve group classification from hierarchical cluster analysis
#' clustering <- cluster_analysis(iris[, 1:4], n = 3)
#'
#' # Goodness of group classification
#' cluster_discrimination(clustering)
#' }
#' # Goodness of group classification
#' cluster_discrimination(clustering)
#' @export
cluster_discrimination <- function(x, cluster_groups = NULL, ...) {
UseMethod("cluster_discrimination")
Expand Down
10 changes: 4 additions & 6 deletions R/cluster_performance.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ cluster_performance.hclust <- function(model, data, clusters, ...) {


#' @rdname cluster_performance
#' @examples
#' @examplesIf require("dbscan", quietly = TRUE)
#' # DBSCAN
#' if (require("dbscan", quietly = TRUE)) {
#' model <- dbscan::dbscan(iris[1:4], eps = 1.45, minPts = 10)
#' model <- dbscan::dbscan(iris[1:4], eps = 1.45, minPts = 10)
#'
#' rez <- cluster_performance(model, iris[1:4])
#' rez
#' }
#' rez <- cluster_performance(model, iris[1:4])
#' rez
#' @export
cluster_performance.dbscan <- function(model, data, ...) {
if (is.null(data)) {
Expand Down
33 changes: 16 additions & 17 deletions R/convert_efa_to_cfa.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
#' @param max_per_dimension Maximum number of variables to keep per dimension.
#' @inheritParams principal_components
#'
#' @examples
#' @examplesIf require("psych") && require("lavaan")
#' \donttest{
#' library(parameters)
#' if (require("psych") && require("lavaan")) {
#' efa <- psych::fa(attitude, nfactors = 3)
#' data(attitude)
#' efa <- psych::fa(attitude, nfactors = 3)
#'
#' model1 <- efa_to_cfa(efa)
#' model2 <- efa_to_cfa(efa, threshold = 0.3)
#' model3 <- efa_to_cfa(efa, max_per_dimension = 2)
#' model1 <- efa_to_cfa(efa)
#' model2 <- efa_to_cfa(efa, threshold = 0.3)
#' model3 <- efa_to_cfa(efa, max_per_dimension = 2)
#'
#' suppressWarnings(anova(
#' lavaan::cfa(model1, data = attitude),
#' lavaan::cfa(model2, data = attitude),
#' lavaan::cfa(model3, data = attitude)
#' ))
#' }
#' suppressWarnings(anova(
#' lavaan::cfa(model1, data = attitude),
#' lavaan::cfa(model2, data = attitude),
#' lavaan::cfa(model3, data = attitude)
#' ))
#' }
#' @return Converted index.
#' @export
Expand All @@ -42,9 +41,10 @@ convert_efa_to_cfa.fa <- function(model,
max_per_dimension = NULL,
...) {
.efa_to_cfa(model_parameters(model, threshold = threshold, ...),
names = names,
max_per_dimension = max_per_dimension,
...)
names = names,
max_per_dimension = max_per_dimension,
...
)
}

#' @export
Expand Down Expand Up @@ -78,7 +78,7 @@ efa_to_cfa <- convert_efa_to_cfa


#' @keywords internal
.efa_to_cfa <- function(loadings, names = NULL, max_per_dimension=NULL, ...) {
.efa_to_cfa <- function(loadings, names = NULL, max_per_dimension = NULL, ...) {
loadings <- attributes(loadings)$loadings_long

# Get dimension names
Expand All @@ -100,7 +100,6 @@ efa_to_cfa <- convert_efa_to_cfa
cfa <- NULL
# Iterate over dimensions
for (i in seq_along(names)) {

# Find correct subset
items <- loadings[loadings$Component == unique(loadings$Component)[i], ]

Expand Down
2 changes: 1 addition & 1 deletion R/display.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ display.parameters_model <- function(object,
font_size = "100%",
line_padding = 4,
column_labels = NULL,
add_reference = FALSE,
include_reference = FALSE,
verbose = TRUE,
...) {
if (identical(format, "html")) {
Expand Down
32 changes: 15 additions & 17 deletions R/dominance_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#' @param contrasts A named list of [`contrasts`] used by the model object.
#' This list is required in order for the correct mapping of parameters to
#' predictors in the output when the model creates indicator codes for factor
#' variables using [`model_matrix`]. By default, the `contrast` element from
#' the model object submitted is used. If the model object does not have a
#' `contrast` element the user can supply this named list.
#' variables using [`insight::get_modelmatrix()`]. By default, the `contrast`
#' element from the model object submitted is used. If the model object does
#' not have a `contrast` element the user can supply this named list.
#'
#' @param ... Not used at current.
#'
Expand Down Expand Up @@ -115,24 +115,22 @@
#'
#' @author Joseph Luchman
#'
#' @examples
#' if (require("domir") && require("performance")) {
#' data(mtcars)
#' @examplesIf require("domir") && require("performance")
#' data(mtcars)
#'
#' # Dominance Analysis with Logit Regression
#' model <- glm(vs ~ cyl + carb + mpg, data = mtcars, family = binomial())
#' # Dominance Analysis with Logit Regression
#' model <- glm(vs ~ cyl + carb + mpg, data = mtcars, family = binomial())
#'
#' performance::r2(model)
#' dominance_analysis(model)
#' performance::r2(model)
#' dominance_analysis(model)
#'
#' # Dominance Analysis with Weighted Logit Regression
#' model_wt <- glm(vs ~ cyl + carb + mpg,
#' data = mtcars,
#' weights = wt, family = quasibinomial()
#' )
#' # Dominance Analysis with Weighted Logit Regression
#' model_wt <- glm(vs ~ cyl + carb + mpg,
#' data = mtcars,
#' weights = wt, family = quasibinomial()
#' )
#'
#' dominance_analysis(model_wt, quote_args = "weights")
#' }
#' dominance_analysis(model_wt, quote_args = "weights")
#' @export
dominance_analysis <- function(model, sets = NULL, all = NULL,
conditional = TRUE, complete = TRUE,
Expand Down
6 changes: 3 additions & 3 deletions R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ format.parameters_model <- function(x,
zap_small = FALSE,
format = NULL,
groups = NULL,
add_reference = FALSE,
include_reference = FALSE,
...) {
# save attributes
coef_name <- attributes(x)$coefficient_name
Expand Down Expand Up @@ -168,7 +168,7 @@ format.parameters_model <- function(x,
ci_width = ci_width,
ci_brackets = ci_brackets,
zap_small = zap_small,
add_reference = add_reference,
include_reference = include_reference,
...
)
} else {
Expand All @@ -185,7 +185,7 @@ format.parameters_model <- function(x,
format = format,
coef_name = coef_name,
zap_small = zap_small,
add_reference = add_reference,
include_reference = include_reference,
...
)
}
Expand Down
Loading

0 comments on commit 700067b

Please sign in to comment.