Skip to content

Commit f9e1c28

Browse files
committed
fix: adjust tests for compatibility with lavaan 0.7-1
1 parent 3f40bb4 commit f9e1c28

5 files changed

Lines changed: 67 additions & 28 deletions

File tree

‎DESCRIPTION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: mlstats
22
Title: Multilevel Descriptive Statistics and Data Preparation
3-
Version: 0.1.0.9000
3+
Version: 0.1.1
44
Authors@R:
55
person("Felix", "Dietrich", , "mail@felix-dietrich.de", role = c("aut", "cre", "cph"))
66
Description: Provides tools for multilevel descriptive statistics and data preparation.

‎NEWS.md‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mlstats 0.1.0.9000 (development version)
1+
# mlstats 0.1.1
22

33
* `decompose_within_between()` now defaults to `components = c("between",
44
"within")`, so grand-mean-centered scores are no longer returned by
@@ -17,7 +17,7 @@
1717
markdown italics (`*N*`) already used on the same label and with how the
1818
"a"/"b" correlation-note superscripts are marked elsewhere in the table.
1919

20-
* `mldesc()` now reports the observed minimum and maximum in the `range`
20+
* `mldesc()` now reports the observed minimum and maximum in the `range`
2121
column with two decimals instead of rounding them to whole numbers
2222
(decimals are dropped when both the minimum and the maximum are whole
2323
numbers, e.g., for integer scales). Previously, a variable observed
@@ -42,6 +42,27 @@
4242
the ICC models); `decompose_within_between()` keeps the rows but sets
4343
their between- and within-group components to `NA`, with a warning.
4444

45+
* Test-only fix for compatibility with lavaan 0.7-1 (no user-visible changes
46+
to `mlstats` itself).
47+
48+
Four `method = "sem"` tests depended on `lavaan` converging on an
49+
inadmissible (negative between-level variance) solution for particular
50+
degenerate/small-sample models, either expecting `.wb_cor_sem()`'s
51+
"out-of-range" warning to fire or a specific between-group correlation to
52+
come back as `NA`. lavaan 0.7-1 converges on an admissible solution
53+
instead for those same models, so the warning no longer fires and a valid
54+
correlation is returned. Three of the affected tests now simply suppress
55+
any warning instead of requiring the "out-of-range" one, since that
56+
warning was incidental to what they actually check (flip= symmetry, print
57+
methods, between-only variable handling). The fourth test, which checks
58+
that within-only variables are excluded from the between-group model, now
59+
constructs a variable with exactly zero between-group variance so it
60+
exercises that exclusion path deterministically rather than relying on
61+
lavaan returning an improper estimate.
62+
63+
The package's test suite now passes with both lavaan 0.6-21 and lavaan
64+
0.7-1.
65+
4566
# mlstats 0.1.0
4667

4768
Initial CRAN release.

‎cran-comments.md‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
## R CMD check results
2-
3-
0 errors | 0 warnings | 1 note
1+
## Reason for this submission
42

5-
* This is a new release.
3+
This is an urgent maintenance release requested by Yves Rosseel (lavaan
4+
maintainer). A new lavaan feature (`optim.fix.saturated`, default `TRUE` in
5+
the upcoming lavaan 0.7-1) causes 4 of mlstats' `method = "sem"` tests to
6+
fail, because those tests depended on lavaan converging on an inadmissible
7+
(out-of-range) standardized solution for certain degenerate/small-sample
8+
models. lavaan 0.7-1 now converges on an admissible solution instead for
9+
those same models. This is currently blocking lavaan 0.7-1's own submission
10+
to CRAN. The relevant tests have been adjusted accordingly (see NEWS.md);
11+
no user-facing behavior of mlstats itself has changed. The package's test
12+
suite passes with both lavaan 0.6-21 (current CRAN release) and lavaan
13+
0.7-1 (verified locally against the pre-release version from the
14+
maintainer's r-universe).
615

7-
## Notes
16+
This release also bundles a handful of unrelated bug fixes and
17+
documentation/output improvements accumulated since 0.1.0 (see NEWS.md).
818

9-
`devtools::check(cran = TRUE)` reports "unable to verify current time" in
10-
some local runs; this is a network-reachability artifact of the local check
11-
environment (it cannot reach the time-verification service) and is unrelated
12-
to package content.
13-
14-
## win-builder / R-hub
19+
## R CMD check results
1520

16-
Checked on win-builder (R-devel) and R-hub (Linux, macOS x86_64/arm64,
17-
R-devel). All clean except:
21+
0 errors | 0 warnings | 2 notes
1822

19-
* win-builder flags "APA", "ICCs", "REWB", and "intraclass" as possibly
20-
misspelled in DESCRIPTION. These are established abbreviations/terms in
21-
the multilevel-modeling literature, not typos.
23+
* `checking CRAN incoming feasibility ... NOTE`: "Days since last update: 4".
24+
Expected, and the reason for the rush is explained above.
25+
* `checking for future file timestamps ... NOTE`: "unable to verify current
26+
time". This is a network-reachability artifact of the local check
27+
environment (it cannot reach the time-verification service) and is
28+
unrelated to package content; it also appeared on the 0.1.0 submission.

‎tests/testthat/test-mldesc.R‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,26 +1067,29 @@ test_that("mldesc method='sem' works with flip=TRUE", {
10671067
z = rnorm(200)
10681068
)
10691069

1070-
result_normal <- expect_warning_value(
1070+
# Whether this particular model yields an out-of-range standardized
1071+
# solution (and hence the "out-of-range" warning) depends on the lavaan
1072+
# version: older versions converge on an inadmissible between-level
1073+
# solution here, newer ones do not. That is incidental to what this test
1074+
# checks -- the flip= symmetry -- so any warning is simply suppressed.
1075+
result_normal <- suppressWarnings(
10711076
mldesc(
10721077
data = data,
10731078
group = "group",
10741079
vars = c("x", "y", "z"),
10751080
method = "sem",
10761081
flip = FALSE
1077-
),
1078-
"out-of-range"
1082+
)
10791083
)
10801084

1081-
result_flipped <- expect_warning_value(
1085+
result_flipped <- suppressWarnings(
10821086
mldesc(
10831087
data = data,
10841088
group = "group",
10851089
vars = c("x", "y", "z"),
10861090
method = "sem",
10871091
flip = TRUE
1088-
),
1089-
"out-of-range"
1092+
)
10901093
)
10911094

10921095
# Upper triangle of normal should equal lower triangle of flipped
@@ -1134,14 +1137,15 @@ test_that("mldesc method='sem' handles between-only variables correctly", {
11341137
data$x <- rnorm(500, 5, 2)
11351138
data$y <- rnorm(500, 5, 2)
11361139

1137-
result <- expect_warning_value(
1140+
# As above, an "out-of-range" warning here is lavaan-version dependent and
1141+
# incidental: this test checks the handling of the between-only variable.
1142+
result <- suppressWarnings(
11381143
mldesc(
11391144
data = data,
11401145
group = "group",
11411146
vars = c("trait", "x", "y"),
11421147
method = "sem"
1143-
),
1144-
"out-of-range"
1148+
)
11451149
)
11461150

11471151
# Check structure

‎tests/testthat/test-within_between_correlations.R‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,13 @@ test_that("method='sem' excludes within-only variables from the between-group mo
11021102
data$wi <- rnorm(200)
11031103
data$x <- rnorm(200)
11041104

1105+
# Group-mean-center `wi` so that it has *exactly* zero between-group
1106+
# variance, i.e. it is genuinely within-only and must be dropped from the
1107+
# between (level 2) model. Plain `rnorm()` would leave a small but nonzero
1108+
# between-group variance, which does not meet the ICC ~ 0 criterion used by
1109+
# .wb_cor_sem(), so the exclusion path being tested here would not be taken.
1110+
data$wi <- data$wi - stats::ave(data$wi, data$group)
1111+
11051112
result <- suppressWarnings(
11061113
within_between_correlations(data, "group", c("wi", "x"), method = "sem")
11071114
)

0 commit comments

Comments
 (0)