Skip to content

Commit

Permalink
Improve emmeans doc with pairs / new release (another CRAN submission…
Browse files Browse the repository at this point in the history
… round) (#373)
  • Loading branch information
danielinteractive authored Nov 17, 2023
1 parent 9ba41f1 commit 4da1cd1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: mmrm
Title: Mixed Models for Repeated Measures
Version: 0.3.5.9003
Version: 0.3.6
Authors@R: c(
person("Daniel", "Sabanes Bove", , "[email protected]", role = c("aut", "cre")),
person("Julia", "Dedic", , "[email protected]", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mmrm 0.3.5.9003
# mmrm 0.3.6

### New Features

Expand Down
4 changes: 4 additions & 0 deletions R/interop-emmeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#' 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.
#' We can also e.g. obtain differences between groups by applying
#' [`pairs()`][emmeans::pairs.emmGrid()] on the object returned
#' by [emmeans::emmeans()].
#'
#' @examples
#' fit <- mmrm(
Expand All @@ -13,6 +16,7 @@
#' )
#' if (require(emmeans)) {
#' emmeans(fit, ~ ARMCD | AVISIT)
#' pairs(emmeans(fit, ~ ARMCD | AVISIT), reverse = TRUE)
#' }
#' @name emmeans_support
NULL
Expand Down
4 changes: 4 additions & 0 deletions man/emmeans_support.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions vignettes/subsections/_intro-hypothesis_testing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,24 @@ course together with multidimensional contrasts.

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.
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 emmeans}
fit <- mmrm(
formula = FEV1 ~ RACE + ARMCD * AVISIT + us(AVISIT | USUBJID),
data = fev_data
)
if (require(emmeans)) {
emmeans(fit, ~ ARMCD | AVISIT)
}
library(emmeans)
lsmeans_by_visit <- emmeans(fit, ~ ARMCD | AVISIT)
lsmeans_by_visit
```

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 pdiff}
pairs(lsmeans_by_visit, reverse = TRUE)
```

(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.

0 comments on commit 4da1cd1

Please sign in to comment.