Skip to content

Commit ce9e7ba

Browse files
authored
Prepare CRAN release (#1000)
* Prepare CRAN release * fix * version * fix * update rbuildignore
1 parent faa37b4 commit ce9e7ba

File tree

5 files changed

+30
-76
lines changed

5 files changed

+30
-76
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
\.lintr$
2121
^CRAN-SUBMISSION$
2222
^Rplots.pdf$
23+
^tests/testthat/_snaps/.

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: insight
33
Title: Easy Access to Model Information for Various Model Objects
4-
Version: 1.0.1.7
4+
Version: 1.0.2
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -127,7 +127,7 @@ Suggests:
127127
gee,
128128
geepack,
129129
geoR,
130-
ggeffects,
130+
ggeffects (>= 2.2.0),
131131
GLMMadaptive,
132132
glmmTMB (>= 1.1.10),
133133
glmtoolbox,
@@ -148,7 +148,7 @@ Suggests:
148148
lmtest,
149149
logistf,
150150
logitr,
151-
marginaleffects (>= 0.24.0),
151+
marginaleffects (>= 0.25.0),
152152
MASS,
153153
Matrix,
154154
mclogit,
@@ -163,7 +163,7 @@ Suggests:
163163
mice (>= 3.17.0),
164164
mlogit,
165165
mmrm,
166-
modelbased,
166+
modelbased (>= 0.9.0),
167167
multgee,
168168
MuMIn,
169169
nestedLogit,

R/get_parameters_others.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ get_parameters.deltaMethod <- function(x, ...) {
390390

391391
#' @export
392392
get_parameters.ggcomparisons <- function(x, merge_parameters = FALSE, ...) {
393-
estimate_pos <- which(colnames(x) == attr(x, "estimate_name"))
393+
estimate_name <- intersect(colnames(x), c(attr(x, "coef_name"), "Difference", "Mean", "Ratio"))[1]
394+
estimate_pos <- which(colnames(x) == estimate_name)
394395
params <- x[, seq_len(estimate_pos - 1), drop = FALSE]
395396

396397
if (isTRUE(merge_parameters) && ncol(params) > 1L) {

R/get_statistic.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,14 +1687,14 @@ get_statistic.emm_list <- function(x, ci = 0.95, adjust = "none", ...) {
16871687

16881688
#' @export
16891689
get_statistic.ggcomparisons <- function(x, merge_parameters = FALSE, ...) {
1690-
estimate_pos <- which(colnames(x) == attr(x, "estimate_name"))
16911690
if (isTRUE(merge_parameters)) {
16921691
params <- get_parameters(x, merge_parameters = TRUE)["Parameter"]
16931692
} else {
1694-
params <- x[, seq_len(estimate_pos - 1), drop = FALSE]
1693+
params <- get_parameters(x, merge_parameters = FALSE)[c("Level1", "Level2")]
16951694
}
16961695

1697-
stat <- .safe(x[[estimate_pos]] / attributes(x)$standard_error)
1696+
stat_column <- intersect(colnames(x), c("t", "z", "Statistic"))[1]
1697+
stat <- x[[stat_column]]
16981698
if (is.null(stat)) {
16991699
return(NULL)
17001700
}

tests/testthat/test-ggeffects.R

Lines changed: 20 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,67 @@ test_that("get_parameters, hypothesis_test", {
44
data(iris)
55
mgg <- lm(Sepal.Width ~ Sepal.Length * Species, data = iris)
66

7-
out <- ggeffects::hypothesis_test(
8-
ggeffects::ggpredict(mgg, c("Sepal.Length", "Species")),
9-
test = NULL
10-
)
7+
out <- ggeffects::test_predictions(mgg, "Sepal.Length", by = "Species")
118

129
param <- get_parameters(out)
13-
expect_named(param, c("Sepal.Length", "Species", "Estimate"))
14-
expect_identical(
15-
param$Sepal.Length,
16-
c("slope", "slope", "slope")
17-
)
10+
expect_named(param, c("Level1", "Level2", "Estimate"))
1811
expect_identical(
19-
param$Species,
20-
structure(1:3, levels = c("setosa", "versicolor", "virginica"), class = "factor")
12+
as.character(param$Level1),
13+
c("versicolor", "virginica", "virginica")
2114
)
2215
expect_equal(
2316
param$Estimate,
24-
c(0.79853, 0.31972, 0.23189),
17+
c(-0.47881, -0.56664, -0.08783),
2518
tolerance = 1e-3
2619
)
2720

2821
param <- get_parameters(out, merge_parameters = TRUE)
2922
expect_named(param, c("Parameter", "Estimate"))
3023
expect_identical(
31-
param$Parameter,
24+
as.character(param$Parameter),
3225
c(
33-
"Sepal.Length [slope], Species [setosa]", "Sepal.Length [slope], Species [versicolor]",
34-
"Sepal.Length [slope], Species [virginica]"
26+
"Level1 [versicolor], Level2 [setosa]", "Level1 [virginica], Level2 [setosa]",
27+
"Level1 [virginica], Level2 [versicolor]"
3528
)
3629
)
3730
expect_equal(
3831
param$Estimate,
39-
c(0.79853, 0.31972, 0.23189),
32+
c(-0.47881, -0.56664, -0.08783),
4033
tolerance = 1e-3
4134
)
42-
43-
out <- ggeffects::hypothesis_test(ggeffects::ggpredict(mgg, c("Sepal.Length", "Species")))
44-
45-
param <- get_parameters(out)
46-
expect_named(param, c("Sepal.Length", "Species", "Estimate"))
47-
expect_identical(
48-
param$Sepal.Length,
49-
c("slope", "slope", "slope")
50-
)
51-
expect_equal(
52-
param$Estimate,
53-
c(0.47881, 0.56664, 0.08783),
54-
tolerance = 1e-3
55-
)
56-
57-
param <- get_parameters(out, merge_parameters = TRUE)
58-
expect_named(param, c("Parameter", "Estimate"))
5935
})
6036

6137

6238
test_that("get_statistic, hypothesis_test", {
6339
data(iris)
6440
mgg <- lm(Sepal.Width ~ Sepal.Length * Species, data = iris)
6541

66-
out <- ggeffects::hypothesis_test(
67-
ggeffects::ggpredict(mgg, c("Sepal.Length", "Species")),
68-
test = NULL
69-
)
42+
out <- ggeffects::hypothesis_test(mgg, "Sepal.Length", by = "Species")
7043

7144
param <- get_statistic(out)
72-
expect_named(param, c("Sepal.Length", "Species", "Statistic"))
73-
expect_identical(
74-
param$Sepal.Length,
75-
c("slope", "slope", "slope")
76-
)
77-
expect_identical(
78-
param$Species,
79-
structure(1:3, levels = c("setosa", "versicolor", "virginica"), class = "factor")
80-
)
45+
expect_named(param, c("Level1", "Level2", "Statistic"))
8146
expect_equal(
8247
param$Statistic,
83-
c(7.23551, 4.24211, 3.79015),
48+
c(-3.58238, -4.48999, -0.90468),
8449
tolerance = 1e-3
8550
)
51+
expect_identical(
52+
as.character(param$Level1),
53+
c("versicolor", "virginica", "virginica")
54+
)
8655

8756
param <- get_statistic(out, merge_parameters = TRUE)
8857
expect_named(param, c("Parameter", "Statistic"))
8958
expect_identical(
90-
param$Parameter,
59+
as.character(param$Parameter),
9160
c(
92-
"Sepal.Length [slope], Species [setosa]", "Sepal.Length [slope], Species [versicolor]",
93-
"Sepal.Length [slope], Species [virginica]"
61+
"Level1 [versicolor], Level2 [setosa]", "Level1 [virginica], Level2 [setosa]",
62+
"Level1 [virginica], Level2 [versicolor]"
9463
)
9564
)
9665
expect_equal(
9766
param$Statistic,
98-
c(7.23551, 4.24211, 3.79015),
67+
c(-3.58238, -4.48999, -0.90468),
9968
tolerance = 1e-3
10069
)
101-
102-
out <- ggeffects::hypothesis_test(ggeffects::ggpredict(mgg, c("Sepal.Length", "Species")))
103-
104-
param <- get_statistic(out)
105-
expect_named(param, c("Sepal.Length", "Species", "Statistic"))
106-
expect_identical(
107-
param$Sepal.Length,
108-
c("slope", "slope", "slope")
109-
)
110-
expect_equal(
111-
param$Statistic,
112-
c(3.58262, 4.48915, 0.90475),
113-
tolerance = 1e-3
114-
)
115-
116-
param <- get_statistic(out, merge_parameters = TRUE)
117-
expect_named(param, c("Parameter", "Statistic"))
11870
})

0 commit comments

Comments
 (0)