Skip to content

Commit b9d4917

Browse files
authored
Prepare CRAN submission (#767)
1 parent 11a881b commit b9d4917

16 files changed

+74
-41
lines changed

CRAN-SUBMISSION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 0.12.2
2-
Date: 2024-07-17 21:02:38 UTC
3-
SHA: d4c45126ca666644785dc64d2af6b87eee9ca39b
1+
Version: 0.12.3
2+
Date: 2024-09-02 16:10:51 UTC
3+
SHA: dfbe03fd4961ee9049d5169275248a4ef7a5a21e

DESCRIPTION

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: performance
33
Title: Assessment of Regression Models Performance
4-
Version: 0.12.2.13
4+
Version: 0.12.3
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -160,4 +160,3 @@ Config/Needs/website:
160160
r-lib/pkgdown,
161161
easystats/easystatstemplate
162162
Config/rcmdcheck/ignore-inconsequential-notes: true
163-
Remotes: easystats/see, easystats/insight

NAMESPACE

+4
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ S3method(model_performance,censReg)
170170
S3method(model_performance,clm)
171171
S3method(model_performance,clm2)
172172
S3method(model_performance,coxph)
173+
S3method(model_performance,coxph_weightit)
173174
S3method(model_performance,default)
174175
S3method(model_performance,felm)
175176
S3method(model_performance,fixest)
176177
S3method(model_performance,fixest_multi)
177178
S3method(model_performance,flexsurvreg)
178179
S3method(model_performance,glm)
180+
S3method(model_performance,glm_weightit)
179181
S3method(model_performance,glmmTMB)
180182
S3method(model_performance,glmmadmb)
181183
S3method(model_performance,glmx)
@@ -197,9 +199,11 @@ S3method(model_performance,mixor)
197199
S3method(model_performance,mlogit)
198200
S3method(model_performance,model_fit)
199201
S3method(model_performance,multinom)
202+
S3method(model_performance,multinom_weightit)
200203
S3method(model_performance,negbinirr)
201204
S3method(model_performance,negbinmfx)
202205
S3method(model_performance,nestedLogit)
206+
S3method(model_performance,ordinal_weightit)
203207
S3method(model_performance,plm)
204208
S3method(model_performance,poissonirr)
205209
S3method(model_performance,poissonmfx)

R/check_dag.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
#' Interpreting Confounder and Modifier Coefficients. American Journal of
104104
#' Epidemiology, 177(4), 292–298. \doi{10.1093/aje/kws412}
105105
#'
106-
#' @examplesIf require("ggdag", quietly = TRUE) && require("dagitty", quietly = TRUE) && require("see", quietly = TRUE)
106+
#' @examplesIf require("ggdag", quietly = TRUE) && require("dagitty", quietly = TRUE) && require("see", quietly = TRUE) && packageVersion("see") > "0.8.5"
107107
#' # no adjustment needed
108108
#' check_dag(
109109
#' y ~ x + b,

R/check_singularity.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
#' )
9898
#' check_singularity(model)
9999
#'
100+
#' \dontrun{
100101
#' # Fixing singularity issues using priors in glmmTMB
101102
#' # Example taken from `vignette("priors", package = "glmmTMB")`
102103
#' dat <- readRDS(system.file(
@@ -120,7 +121,7 @@
120121
#' model_with_priors <- update(model, priors = prior)
121122
#' # no singular fit
122123
#' check_singularity(model_with_priors)
123-
#'
124+
#' }
124125
#' @export
125126
check_singularity <- function(x, tolerance = 1e-5, ...) {
126127
UseMethod("check_singularity")

R/model_performance.lm.R

+16-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#' Compute indices of model performance for regression models.
44
#'
55
#' @param model A model.
6-
#' @param metrics Can be `"all"`, `"common"` or a character vector of
7-
#' metrics to be computed (one or more of `"AIC"`, `"AICc"`, `"BIC"`, `"R2"`,
8-
#' `"R2_adj"`, `"RMSE"`, `"SIGMA"`, `"LOGLOSS"`, `"PCP"`, `"SCORE"`).
9-
#' `"common"` will compute AIC, BIC, R2 and RMSE.
6+
#' @param metrics Can be `"all"`, `"common"` or a character vector of metrics to
7+
#' be computed (one or more of `"AIC"`, `"AICc"`, `"BIC"`, `"R2"`, `"R2_adj"`,
8+
#' `"RMSE"`, `"SIGMA"`, `"LOGLOSS"`, `"PCP"`, `"SCORE"`). `"common"` will
9+
#' compute AIC, BIC, R2 and RMSE.
1010
#' @param verbose Toggle off warnings.
1111
#' @param ... Arguments passed to or from other methods.
1212
#'
@@ -209,6 +209,18 @@ model_performance.lm_robust <- model_performance.lm
209209
#' @export
210210
model_performance.multinom <- model_performance.lm
211211

212+
#' @export
213+
model_performance.multinom_weightit <- model_performance.lm
214+
215+
#' @export
216+
model_performance.ordinal_weightit <- model_performance.lm
217+
218+
#' @export
219+
model_performance.coxph_weightit <- model_performance.lm
220+
221+
#' @export
222+
model_performance.glm_weightit <- model_performance.lm
223+
212224
#' @export
213225
model_performance.plm <- model_performance.lm
214226

R/r2.R

-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ r2.aov <- function(model, ci = NULL, ...) {
251251
#' @rdname r2
252252
#' @export
253253
r2.mlm <- function(model, multivariate = TRUE, ...) {
254-
255254
if (multivariate) {
256255
out <- r2_mlm(model)
257256
} else {

R/r2_coxsnell.R

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
#' @param ... Currently not used.
99
#'
1010
#' @details
11-
#' This index was proposed by *Cox and Snell (1989, pp. 208-9)* and,
12-
#' apparently independently, by *Magee (1990)*; but had been suggested
13-
#' earlier for binary response models by *Maddala (1983)*. However, this
14-
#' index achieves a maximum of less than 1 for discrete models (i.e. models
15-
#' whose likelihood is a product of probabilities) which have a maximum of 1,
16-
#' instead of densities, which can become infinite *(Nagelkerke, 1991)*.
11+
#' This index was proposed by *Cox and Snell (1989, pp. 208-9)* and, apparently
12+
#' independently, by *Magee (1990)*; but had been suggested earlier for binary
13+
#' response models by *Maddala (1983)*. However, this index achieves a maximum
14+
#' of less than 1 for discrete models (i.e. models whose likelihood is a product
15+
#' of probabilities) which have a maximum of 1, instead of densities, which can
16+
#' become infinite *(Nagelkerke, 1991)*.
1717
#'
1818
#' @return A named vector with the R2 value.
1919
#'
@@ -24,12 +24,12 @@
2424
#' @references
2525
#' - Cox, D. R., Snell, E. J. (1989). Analysis of binary data (Vol. 32).
2626
#' Monographs on Statistics and Applied Probability.
27-
#' - Magee, L. (1990). R 2 measures based on Wald and likelihood ratio
28-
#' joint significance tests. The American Statistician, 44(3), 250-253.
27+
#' - Magee, L. (1990). R 2 measures based on Wald and likelihood ratio joint
28+
#' significance tests. The American Statistician, 44(3), 250-253.
2929
#' - Maddala, G. S. (1986). Limited-dependent and qualitative variables in
3030
#' econometrics (No. 3). Cambridge university press.
31-
#' - Nagelkerke, N. J. (1991). A note on a general definition of the
32-
#' coefficient of determination. Biometrika, 78(3), 691-692.
31+
#' - Nagelkerke, N. J. (1991). A note on a general definition of the coefficient
32+
#' of determination. Biometrika, 78(3), 691-692.
3333
#'
3434
#' @export
3535
r2_coxsnell <- function(model, ...) {

R/r2_mlm.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#' - Azen, R., & Budescu, D. V. (2006). Comparing predictors in
5454
#' multivariate regression models: An extension of dominance analysis.
5555
#' Journal of Educational and Behavioral Statistics, 31(2), 157-180.
56-
#'- Cramer, E. M., & Nicewander, W. A. (1979). Some symmetric,
56+
#' - Cramer, E. M., & Nicewander, W. A. (1979). Some symmetric,
5757
#' invariant measures of multivariate association. Psychometrika, 44, 43-54.
5858
#' - Van den Burg, W., & Lewis, C. (1988). Some properties of two
5959
#' measures of multivariate association. Psychometrika, 53, 109-122.
@@ -73,7 +73,7 @@ r2_mlm.mlm <- function(model, verbose = TRUE, ...) {
7373
insight::get_predictors(model),
7474
insight::get_response(model)
7575
)$cor^2
76-
R_xy <- 1 - Reduce(`*`, rho2_vec, 1)
76+
R_xy <- 1 - Reduce(`*`, rho2_vec, 1)
7777

7878
resid_cov <- stats::cov(residuals(model))
7979
resp_cov <- stats::cov(insight::get_response(model))

cran-comments.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This is a patch release that fixes failing CRAN checks for Mac OS old-rel.
1+
Maintance release.

man/check_dag.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_singularity.Rd

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model_performance.lm.Rd

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/r2_coxsnell.Rd

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-check_heterogeneity_bias.R

+16
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@ test_that("check_heterogeneity_bias", {
3232
"Possible heterogeneity bias due to following predictors: Petal\\.Length, Petal\\.Width, Species"
3333
)
3434
})
35+
36+
test_that("check_heterogeneity_bias", {
37+
skip_if_not_installed("datawizard", minimum_version = "0.12.3")
38+
data(efc, package = "datawizard")
39+
dat <- na.omit(efc)
40+
dat$e42dep <- factor(dat$e42dep)
41+
dat$c172code <- factor(dat$c172code)
42+
43+
out <- check_heterogeneity_bias(
44+
dat,
45+
select = "c12hour",
46+
by = c("e42dep", "c172code"),
47+
nested = TRUE
48+
)
49+
expect_equal(out, "c12hour", ignore_attr = TRUE)
50+
})

tests/testthat/test-model_performance.bayesian.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test_that("model_performance.brmsfit", {
6060
expect_equal(perf$R2, 0.954538, tolerance = 1e-3)
6161
expect_equal(perf$R2_adjusted, 0.9529004, tolerance = 1e-3)
6262
expect_equal(perf$ELPD, -70.40493, tolerance = 1e-3)
63-
expect_identical(colnames(perf), c(
63+
expect_named(perf, c(
6464
"ELPD", "ELPD_SE", "LOOIC", "LOOIC_SE", "WAIC", "R2", "R2_marginal",
6565
"R2_adjusted", "R2_adjusted_marginal", "ICC", "RMSE", "Sigma"
6666
))

0 commit comments

Comments
 (0)