Last updated on 2026-06-08 02:51:18 CEST.
| Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
|---|---|---|---|---|---|---|
| r-devel-linux-x86_64-debian-clang | 0.3.17 | 527.95 | 212.06 | 740.01 | OK | |
| r-devel-linux-x86_64-debian-gcc | 0.3.17 | 467.27 | 163.51 | 630.78 | ERROR | |
| r-devel-linux-x86_64-fedora-clang | 0.3.17 | 600.00 | 313.92 | 913.92 | OK | |
| r-devel-linux-x86_64-fedora-gcc | 0.3.17 | 1140.00 | 336.50 | 1476.50 | OK | |
| r-devel-windows-x86_64 | 0.3.17 | 544.00 | 337.00 | 881.00 | OK | |
| r-patched-linux-x86_64 | 0.3.17 | 576.98 | 248.80 | 825.78 | OK | |
| r-release-linux-x86_64 | 0.3.17 | 598.74 | 246.68 | 845.42 | OK | |
| r-release-macos-arm64 | 0.3.17 | 108.00 | -5.00 | 103.00 | OK | |
| r-release-macos-x86_64 | 0.3.17 | 336.00 | 182.00 | 518.00 | OK | |
| r-release-windows-x86_64 | 0.3.17 | 533.00 | 329.00 | 862.00 | ERROR | |
| r-oldrel-macos-arm64 | 0.3.17 | 108.00 | 0.00 | 108.00 | OK | |
| r-oldrel-macos-x86_64 | 0.3.17 | 342.00 | 131.00 | 473.00 | OK | |
| r-oldrel-windows-x86_64 | 0.3.17 | 653.00 | 432.00 | 1085.00 | OK |
Version: 0.3.17
Check: tests
Result: ERROR
Running ‘additional.R’ [2s/2s]
Running ‘testthat.R’ [35s/47s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> pkg_name <- "mmrm"
> library(pkg_name, character.only = TRUE)
> testthat::test_check(pkg_name)
In AVISIT there are dropped visits: VIS4.
Additional attributes including contrasts are lost.
To avoid this behavior, make sure use `drop_visit_levels = FALSE`.
Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
Saving _problems/test-fit-921.R
Saving _problems/test-tmb-378.R
[ FAIL 2 | WARN 4 | SKIP 64 | PASS 1995 ]
══ Skipped tests (64) ══════════════════════════════════════════════════════════
• On CRAN (48): 'test-between-within.R:23:1', 'test-emmeans.R:115:1',
'test-empirical.R:3:1', 'test-empirical.R:15:1', 'test-empirical.R:27:1',
'test-fit.R:282:3', 'test-fit.R:412:3', 'test-fit.R:559:1',
'test-interop-car.R:214:1', 'test-interop-car.R:237:1',
'test-kenwardroger.R:2:1', 'test-kenwardroger.R:12:1',
'test-kenwardroger.R:22:1', 'test-kenwardroger.R:32:1',
'test-kenwardroger.R:42:1', 'test-kenwardroger.R:52:1',
'test-kenwardroger.R:62:1', 'test-kenwardroger.R:72:1',
'test-kenwardroger.R:82:1', 'test-kenwardroger.R:92:1',
'test-kenwardroger.R:102:1', 'test-kenwardroger.R:112:1',
'test-kenwardroger.R:122:1', 'test-kenwardroger.R:132:1',
'test-kenwardroger.R:142:1', 'test-kenwardroger.R:152:1',
'test-kenwardroger.R:162:1', 'test-kenwardroger.R:172:1',
'test-kenwardroger.R:182:1', 'test-kenwardroger.R:192:1',
'test-kenwardroger.R:490:1', 'test-kenwardroger.R:498:1',
'test-kenwardroger.R:512:1', 'test-kenwardroger.R:530:1',
'test-kenwardroger.R:542:1', 'test-mmrm-methods.R:78:1',
'test-mmrm-methods.R:94:1', 'test-mmrm-methods.R:100:1',
'test-mmrm-methods.R:106:1', 'test-mmrm-methods.R:112:1',
'test-mmrm-methods.R:119:1', 'test-testing.R:78:1', 'test-testing.R:92:1',
'test-tmb-methods.R:142:1', 'test-tmb-methods.R:179:1',
'test-tmb-methods.R:351:1', 'test-tmb-methods.R:1081:1',
'test-tmb-methods.R:1088:1'
• empty test (1):
• {broom.helpers} is not installed (1): 'test-tmb-methods.R:914:3'
• {car} is not installed (7): 'test-interop-car.R:305:3',
'test-interop-car.R:340:3', 'test-interop-car.R:356:3',
'test-interop-car.R:373:3', 'test-interop-car.R:402:3',
'test-interop-car.R:434:3', 'test-interop-car.R:472:3'
• {car} is not installed. (1): 'test-interop-car.R:6:3'
• {parsnip} is not installed (6): 'test-interop-parsnip.R:4:3',
'test-interop-parsnip.R:19:3', 'test-interop-parsnip.R:34:3',
'test-interop-parsnip.R:53:3', 'test-interop-parsnip.R:67:3',
'test-interop-parsnip.R:93:3'
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-fit.R:914:3'): mmrm works for vcov: Empirical and method: Satterthwaite ──
Error in `file(file, if (append) "a" else "w")`: cannot open the connection
Backtrace:
▆
1. └─testthat::expect_silent(...) at test-fit.R:914:3
2. └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
3. └─testthat (local) .capture(...)
4. └─withr::with_output_sink(...)
5. └─withr:::set_output_sink(file = new, append = append, split = split)
6. └─withr:::output_sink(file = file, append = append, split = split)
7. └─base::sink(file = file, append = append, type = "output", split = split)
8. └─base::file(file, if (append) "a" else "w")
── Error ('test-tmb.R:371:3'): h_mmrm_tmb_data works as expected for mutli-dimensional spatial exponential covariance ──
Error in `file(file, if (append) "a" else "w")`: cannot open the connection
Backtrace:
▆
1. └─testthat::expect_silent(...) at test-tmb.R:371:3
2. └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
3. └─testthat (local) .capture(...)
4. └─withr::with_output_sink(...)
5. └─withr:::set_output_sink(file = new, append = append, split = split)
6. └─withr:::output_sink(file = file, append = append, split = split)
7. └─base::sink(file = file, append = append, type = "output", split = split)
8. └─base::file(file, if (append) "a" else "w")
[ FAIL 2 | WARN 4 | SKIP 64 | PASS 1995 ]
Error:
! Test failures.
Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 0.3.17
Check: re-building of vignette outputs
Result: ERROR
Error(s) in re-building vignettes:
...
--- re-building ‘algorithm.Rmd’ using rmarkdown
--- finished re-building ‘algorithm.Rmd’
--- re-building ‘between_within.Rmd’ using rmarkdown
--- finished re-building ‘between_within.Rmd’
--- re-building ‘coef_vcov.Rmd’ using rmarkdown
--- finished re-building ‘coef_vcov.Rmd’
--- re-building ‘covariance.Rmd’ using rmarkdown
--- finished re-building ‘covariance.Rmd’
--- re-building ‘empirical_wls.Rmd’ using rmarkdown
--- finished re-building ‘empirical_wls.Rmd’
--- re-building ‘hypothesis_testing.Rmd’ using rmarkdown
--- finished re-building ‘hypothesis_testing.Rmd’
--- re-building ‘introduction.Rmd’ using rmarkdown
This package supports estimation of one- and multi-dimensional contrasts
(t-test and F-test calculation) with the [`df_1d()`](https://openpharma.github.io/mmrm/main/reference/df_1d.html) and
[`df_md()`](https://openpharma.github.io/mmrm/main/reference/df_md.html) functions.
Both functions utilize the chosen adjustment method from the initial `mmrm` call
for the calculation of degrees of freedom and (for Kenward-Roger methods) the
variance estimates for the test-statistics.
## One-dimensional contrasts
Compute the test of a one-dimensional (vector) contrast for a `mmrm` object with
Satterthwaite degrees of freedom.
``` r
fit <- mmrm(
formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
data = fev_data
)
contrast <- numeric(length(component(fit, "beta_est")))
contrast[3] <- 1
df_1d(fit, contrast)
#> $est
#> [1] 5.643565
#>
#> $se
#> [1] 0.6656093
#>
#> $df
#> [1] 157.1382
#>
#> $t_stat
#> [1] 8.478795
#>
#> $p_val
#> [1] 1.564869e-14
```
This works similarly when choosing a Kenward-Roger adjustment:
``` r
fit_kr <- mmrm(
formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
data = fev_data,
method = "Kenward-Roger"
)
df_1d(fit_kr, contrast)
#> $est
#> [1] 5.643565
#>
#> $se
#> [1] 0.6740941
#>
#> $df
#> [1] 157.1382
#>
#> $t_stat
#> [1] 8.372073
#>
#> $p_val
#> [1] 2.931654e-14
```
We see that because this is a one-dimensional contrast, the degrees of freedoms
are identical for Satterthwaite and Kenward-Roger. However, the standard errors
are different and therefore the p-values are different.
Additional options for the degrees of freedom `method` are Residual and Between-Within.
## Multi-dimensional contrasts
Compute the test of a multi-dimensional (matrix) contrast for the above defined
`mmrm` object with Satterthwaite degrees of freedom:
``` r
contrast <- matrix(data = 0, nrow = 2, ncol = length(component(fit, "beta_est")))
contrast[1, 2] <- contrast[2, 3] <- 1
df_md(fit, contrast)
#> $num_df
#> [1] 2
#>
#> $denom_df
#> [1] 165.5553
#>
#> $f_stat
#> [1] 36.91143
#>
#> $p_val
#> [1] 5.544575e-14
```
And for the Kenward-Roger adjustment:
``` r
df_md(fit_kr, contrast)
#> $num_df
#> [1] 2
#>
#> $denom_df
#> [1] 165.5728
#>
#> $f_stat
#> [1] 35.99422
#>
#> $p_val
#> [1] 1.04762e-13
```
We see that for the multi-dimensional contrast we get slightly different
denominator degrees of freedom for the two adjustment methods.
Also the simpler Residual and Between-Within `method` choices can be used of
course together with multidimensional contrasts.
## Support for emmeans
This package includes methods that allow `mmrm` objects to be used with the
`emmeans` package. `emmeans` computes estimated marginal means (also called
least-square means) for the coefficients of the MMRM. For example, in order
to see the least-square means by visit and by treatment arm:
``` r
library(emmeans)
#> mmrm() registered as emmeans extension
#> Welcome to emmeans.
#> Caution: You lose important information if you filter this package's results.
#> See '? untidy'
lsmeans_by_visit <- emmeans(fit, ~ ARMCD | AVISIT)
lsmeans_by_visit
#> AVISIT = VIS1:
#> ARMCD emmean SE df lower.CL upper.CL
#> PBO 33.3 0.755 148 31.8 34.8
#> TRT 37.1 0.763 143 35.6 38.6
#>
#> AVISIT = VIS2:
#> ARMCD emmean SE df lower.CL upper.CL
#> PBO 38.2 0.612 147 37.0 39.4
#> TRT 41.9 0.602 143 40.7 43.1
#>
#> AVISIT = VIS3:
#> ARMCD emmean SE df lower.CL upper.CL
#> PBO 43.7 0.462 130 42.8 44.6
#> TRT 46.8 0.509 130 45.7 47.8
#>
#> AVISIT = VIS4:
#> ARMCD emmean SE df lower.CL upper.CL
#> PBO 48.4 1.190 134 46.0 50.7
#> TRT 52.8 1.190 133 50.4 55.1
#>
#> Results are averaged over the levels of: RACE, SEX
#> Confidence level used: 0.95
```
Note that the degrees of freedom choice is inherited here from the initial `mmrm`
fit.
Furthermore, we can also obtain the differences between the treatment arms for each visit
by applying `pairs()` on the object returned by `emmeans()` earlier:
``` r
pairs(lsmeans_by_visit, reverse = TRUE)
#> AVISIT = VIS1:
#> contrast estimate SE df t.ratio p.value
#> TRT - PBO 3.77 1.070 146 3.514 0.0006
#>
#> AVISIT = VIS2:
#> contrast estimate SE df t.ratio p.value
#> TRT - PBO 3.73 0.859 145 4.346 <0.0001
#>
#> AVISIT = VIS3:
#> contrast estimate SE df t.ratio p.value
#> TRT - PBO 3.08 0.690 131 4.467 <0.0001
#>
#> AVISIT = VIS4:
#> contrast estimate SE df t.ratio p.value
#> TRT - PBO 4.40 1.680 133 2.617 0.0099
#>
#> Results are averaged over the levels of: RACE, SEX
```
(This is similar like the `pdiff` option in SAS `PROC MIXED`.)
Note that we use here the `reverse` argument to obtain treatment minus
placebo results, instead of placebo minus treatment results.
To further obtain the confidence interval of the least square mean differences, we can apply
`confint()` on the result returned by `pairs()` .
This is similar to the `LSMEANS` in SAS, with `CL` and `DIFF` options.
``` r
confint(pairs(lsmeans_by_visit, reverse = TRUE))
#> AVISIT = VIS1:
#> contrast estimate SE df lower.CL upper.CL
#> TRT - PBO 3.77 1.070 146 1.65 5.90
#>
#> AVISIT = VIS2:
#> contrast estimate SE df lower.CL upper.CL
#> TRT - PBO 3.73 0.859 145 2.03 5.43
#>
#> AVISIT = VIS3:
#> contrast estimate SE df lower.CL upper.CL
#> TRT - PBO 3.08 0.690 131 1.72 4.44
#>
#> AVISIT = VIS4:
#> contrast estimate SE df lower.CL upper.CL
#> TRT - PBO 4.40 1.680 133 1.07 7.72
#>
#> Results are averaged over the levels of: RACE, SEX
#> Confidence level used: 0.95
```
## Support for car
This package includes methods that allow `mmrm` objects to be used with
`car::Anova()`. This function conducts type II/III hypothesis testing for
the effects in `mmrm` models, using either F-tests (default) or Chi-squared tests.
### Mathematical basis
For each effect, the Chi-squared test statistic is calculated using:
$$
\chi^2=[\mathbf{L}\cdot b]^T\cdot [\mathbf{L}\cdot\mathbf{V}\cdot\mathbf{L}^T]^{-1}\cdot\mathbf{L}\cdot b
$$
where $\mathbf{L}$ is the desired contrast matrix, $b$ is a one-column matrix containing the coefficients of the non-aliased terms in the model, and $\mathbf{V}$ is the variance-covariance matrix of the coefficients.
The F-test statistic is calculated by dividing the Chi-squared test statistic by the numerator degrees of freedom $\text{df}_\text{num}$, which is equal to the number of parameters associated with the effect and therefore the number of rows in the contrast matrix $\mathbf{L}$. It is also multiplied by a scaling factor $\lambda$ (e.g., when utilizing the adjusted Kenward-Roger degrees of freedom), which can be set to 1 if not needed:
$$
F = \lambda\frac{\chi^2}{\text{df}_\text{num}}
$$
### Examples
In order to see if the used covariates are related to the response using a type II test:
Quitting from ./subsections/_intro-hypothesis_testing.Rmd:130-133 [car_type2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<error/rlang_error>
Error in `library()`:
! there is no package called 'car'
---
Backtrace:
▆
1. └─base::library(car)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quitting from introduction.Rmd:49-50 [unnamed-chunk-6]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<error/rlang_error>
Error in `library()`:
! there is no package called 'car'
---
Backtrace:
▆
1. └─base::library(car)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: processing vignette 'introduction.Rmd' failed with diagnostics:
there is no package called 'car'
--- failed re-building ‘introduction.Rmd’
--- re-building ‘kenward.Rmd’ using rmarkdown
--- finished re-building ‘kenward.Rmd’
--- re-building ‘methodological_introduction.Rmd’ using rmarkdown
--- finished re-building ‘methodological_introduction.Rmd’
--- re-building ‘mmrm_review_methods.Rmd’ using rmarkdown
Quitting from mmrm_review_methods.Rmd:26-43 [review-setup]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<error/rlang_error>
Error in `library()`:
! there is no package called 'glmmTMB'
---
Backtrace:
▆
1. └─base::library(glmmTMB)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: processing vignette 'mmrm_review_methods.Rmd' failed with diagnostics:
there is no package called 'glmmTMB'
--- failed re-building ‘mmrm_review_methods.Rmd’
--- re-building ‘package_structure.Rmd’ using rmarkdown
--- finished re-building ‘package_structure.Rmd’
--- re-building ‘predict.Rmd’ using rmarkdown
--- finished re-building ‘predict.Rmd’
--- re-building ‘satterthwaite.Rmd’ using rmarkdown
--- finished re-building ‘satterthwaite.Rmd’
SUMMARY: processing the following files failed:
‘introduction.Rmd’ ‘mmrm_review_methods.Rmd’
Error: Vignette re-building failed.
Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 0.3.17
Check: tests
Result: ERROR
Running 'additional.R' [11s]
Running 'testthat.R' [56s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
> pkg_name <- "mmrm"
> library(pkg_name, character.only = TRUE)
> testthat::test_check(pkg_name)
In AVISIT there are dropped visits: VIS4.
Additional attributes including contrasts are lost.
To avoid this behavior, make sure use `drop_visit_levels = FALSE`.
Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
Loading required package: carData
-- Model Registration ------------------------------------------- mmrm 0.3.17 --
v mmrm::mmrm()
Der Befehl "sh" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Saving _problems/test-skipping-16.R
Der Befehl "sh" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Saving _problems/test-skipping-22.R
Der Befehl "sh" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Saving _problems/test-skipping-29.R
[ FAIL 3 | WARN 3 | SKIP 51 | PASS 2059 ]
══ Skipped tests (51) ══════════════════════════════════════════════════════════
• On CRAN (50): 'test-between-within.R:23:1', 'test-emmeans.R:115:1',
'test-empirical.R:3:1', 'test-empirical.R:15:1', 'test-empirical.R:27:1',
'test-fit.R:282:3', 'test-fit.R:412:3', 'test-fit.R:559:1',
'test-interop-car.R:214:1', 'test-interop-car.R:237:1',
'test-interop-car.R:304:1', 'test-kenwardroger.R:2:1',
'test-kenwardroger.R:12:1', 'test-kenwardroger.R:22:1',
'test-kenwardroger.R:32:1', 'test-kenwardroger.R:42:1',
'test-kenwardroger.R:52:1', 'test-kenwardroger.R:62:1',
'test-kenwardroger.R:72:1', 'test-kenwardroger.R:82:1',
'test-kenwardroger.R:92:1', 'test-kenwardroger.R:102:1',
'test-kenwardroger.R:112:1', 'test-kenwardroger.R:122:1',
'test-kenwardroger.R:132:1', 'test-kenwardroger.R:142:1',
'test-kenwardroger.R:152:1', 'test-kenwardroger.R:162:1',
'test-kenwardroger.R:172:1', 'test-kenwardroger.R:182:1',
'test-kenwardroger.R:192:1', 'test-kenwardroger.R:490:1',
'test-kenwardroger.R:498:1', 'test-kenwardroger.R:512:1',
'test-kenwardroger.R:530:1', 'test-kenwardroger.R:542:1',
'test-mmrm-methods.R:78:1', 'test-mmrm-methods.R:94:1',
'test-mmrm-methods.R:100:1', 'test-mmrm-methods.R:106:1',
'test-mmrm-methods.R:112:1', 'test-mmrm-methods.R:119:1',
'test-testing.R:78:1', 'test-testing.R:92:1', 'test-tmb-methods.R:142:1',
'test-tmb-methods.R:179:1', 'test-tmb-methods.R:351:1',
'test-tmb-methods.R:913:1', 'test-tmb-methods.R:1081:1',
'test-tmb-methods.R:1088:1'
• empty test (1):
══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test-skipping.R:16:3'): get_compiler works as expected ────────────
Check on 'get_compiler()' failed: Must have length 1
Backtrace:
▆
1. └─checkmate::expect_string(get_compiler()) at test-skipping.R:16:3
2. └─checkmate::makeExpectation(x, res, info, label)
── Failure ('test-skipping.R:22:3'): is_using_clang works as expected ──────────
Check on 'is_using_clang()' failed: Must have length 1
Backtrace:
▆
1. └─checkmate::expect_flag(is_using_clang()) at test-skipping.R:22:3
2. └─checkmate::makeExpectation(x, res, info, label)
── Failure ('test-skipping.R:29:3'): is_using_clang gives the same information as R_compiled_by in recent R versions ──
Expected `result` to be identical to `expected`.
Differences:
`actual`:
`expected`: FALSE
[ FAIL 3 | WARN 3 | SKIP 51 | PASS 2059 ]
Error:
! Test failures.
Execution halted
Flavor: r-release-windows-x86_64