diff --git a/DESCRIPTION b/DESCRIPTION index dcd130e..bdce90f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: emmeans Type: Package Title: Estimated Marginal Means, aka Least-Squares Means -Version: 1.10.7 -Date: 2025-01-30 +Version: 1.10.7-100001 +Date: 2025-02-14 Authors@R: c(person("Russell V.", "Lenth", role = c("aut", "cre", "cph"), email = "russell-lenth@uiowa.edu"), person("Balazs", "Banfai", role = "ctb"), diff --git a/NAMESPACE b/NAMESPACE index e778454..96a1b9f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -68,6 +68,7 @@ S3method(emm_basis,svyolr) S3method(emm_basis,zeroinfl) S3method(emmip,default) S3method(head,emmGrid) +S3method(linfct,default) S3method(pairs,emmGrid) S3method(pairs,emm_list) S3method(plot,emmGrid) @@ -199,6 +200,7 @@ export(get_emm_option) export(hpd.summary) export(inverse) export(joint_tests) +export(linfct) export(lsm) export(lsm.options) export(lsmeans) diff --git a/NEWS.md b/NEWS.md index 5429aa1..ea81548 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ --- title: "NEWS for the emmeans package" --- +## emmeans 1.10.7-100xxx + * Added a `linfct()` generic and default method that returns `object@linfct` + ## emmeans 1.10-7 * Spelling changes in several vignettes diff --git a/R/emmGrid-methods.R b/R/emmGrid-methods.R index 1a42c13..d56fcb8 100644 --- a/R/emmGrid-methods.R +++ b/R/emmGrid-methods.R @@ -172,6 +172,18 @@ vcov.emmGrid = function(object, ..., sep = get_emm_option("sep")) { } +#' @rdname emmGrid-methods +#' +#' @returns The \code{linfct} function and method returns the \code{linfct} slot of \code{object}. +#' @export +linfct = function(object, ...) + UseMethod("linfct") + +#' @rdname emmGrid-methods +#' @export +linfct.default = function(object, ...) { + attr(object, "linfct") +} # Method to alter contents of misc slot diff --git a/R/interfacing.R b/R/interfacing.R index e0f7a84..8c8eb8b 100644 --- a/R/interfacing.R +++ b/R/interfacing.R @@ -385,7 +385,7 @@ recover_data.call = function(object, trms, na.action, data = NULL, #' \code{tol} is the tolerance for assessing estimability. It should return a #' matrix with 3 columns: the estimates, standard errors (\code{NA} when #' \code{do.se==FALSE}), and degrees of freedom (\code{NA} for asymptotic). The -#' number of rows should be the same as \samp{object@linfct}. The +#' number of rows should equal \samp{nrow(linfct(object)}. The #' \code{vcovHook} function should have arguments \samp{(object, tol, ...)} as #' described. It should return the covariance matrix for the estimates. Finally, #' \code{postGridHook}, if present, is called at the very end of diff --git a/R/summary.R b/R/summary.R index c9b70d2..0345811 100644 --- a/R/summary.R +++ b/R/summary.R @@ -194,7 +194,7 @@ as.data.frame.summary_emm = function(x, ...) { #' \eqn{\sqrt{rF(\alpha; r, d)}}{sqrt[r*qf(alpha, r, d)]}, where \eqn{d} is #' the error degrees of freedom and \eqn{r} is the rank of the set of linear #' functions under consideration. By default, the value of \code{r} is -#' computed from \code{object@linfct} for each by group; however, if the +#' computed from \code{linfct(object)} for each by group; however, if the #' user specifies an argument matching \code{scheffe.rank}, its value will #' be used instead. Ordinarily, if there are \eqn{k} means involved, then #' \eqn{r = k - 1} for a full set of contrasts involving all \eqn{k} means, and diff --git a/R/test.R b/R/test.R index d16a8e6..b267901 100644 --- a/R/test.R +++ b/R/test.R @@ -47,7 +47,7 @@ test = function(object, null, ...) { #' @param joint Logical value. If \code{FALSE}, the arguments are passed to #' \code{\link{summary.emmGrid}} with \code{infer=c(FALSE, TRUE)}. If \code{joint = #' TRUE}, a joint test of the hypothesis L beta = null is performed, where L -#' is \code{object@linfct} and beta is the vector of fixed effects estimated +#' is \code{linfct(object)} and beta is the vector of fixed effects estimated #' by \code{object@betahat}. This will be either an \emph{F} test or a #' chi-square (Wald) test depending on whether degrees of freedom are #' available. See also \code{\link{joint_tests}}. diff --git a/man/emmGrid-methods.Rd b/man/emmGrid-methods.Rd index a9b8e32..76f105c 100644 --- a/man/emmGrid-methods.Rd +++ b/man/emmGrid-methods.Rd @@ -4,6 +4,8 @@ \alias{str.emmGrid} \alias{print.emmGrid} \alias{vcov.emmGrid} +\alias{linfct} +\alias{linfct.default} \title{Miscellaneous methods for \code{emmGrid} objects} \usage{ \method{str}{emmGrid}(object, ...) @@ -11,6 +13,10 @@ \method{print}{emmGrid}(x, ..., export = FALSE) \method{vcov}{emmGrid}(object, ..., sep = get_emm_option("sep")) + +linfct(object, ...) + +\method{linfct}{default}(object, ...) } \arguments{ \item{object}{An \code{emmGrid} object} @@ -33,6 +39,8 @@ names for \code{vcov()} results} \value{ The \code{vcov} method returns a symmetric matrix of variances and covariances for \code{predict.emmGrid(object, type = "lp")} + +The \code{linfct} function and method returns the \code{linfct} slot of \code{object}. } \description{ Miscellaneous methods for \code{emmGrid} objects diff --git a/man/extending-emmeans.Rd b/man/extending-emmeans.Rd index 1f1fc2b..3b79afd 100644 --- a/man/extending-emmeans.Rd +++ b/man/extending-emmeans.Rd @@ -306,7 +306,7 @@ The \code{estHook} function should have arguments \samp{(object, do.se, tol, \code{tol} is the tolerance for assessing estimability. It should return a matrix with 3 columns: the estimates, standard errors (\code{NA} when \code{do.se==FALSE}), and degrees of freedom (\code{NA} for asymptotic). The -number of rows should be the same as \samp{object@linfct}. The +number of rows should equal \samp{nrow(linfct(object)}. The \code{vcovHook} function should have arguments \samp{(object, tol, ...)} as described. It should return the covariance matrix for the estimates. Finally, \code{postGridHook}, if present, is called at the very end of diff --git a/man/summary.emmGrid.Rd b/man/summary.emmGrid.Rd index b7f3297..209d360 100644 --- a/man/summary.emmGrid.Rd +++ b/man/summary.emmGrid.Rd @@ -123,7 +123,7 @@ In \code{confint.emmGrid}, \item{joint}{Logical value. If \code{FALSE}, the arguments are passed to \code{\link{summary.emmGrid}} with \code{infer=c(FALSE, TRUE)}. If \code{joint = TRUE}, a joint test of the hypothesis L beta = null is performed, where L -is \code{object@linfct} and beta is the vector of fixed effects estimated +is \code{linfct(object)} and beta is the vector of fixed effects estimated by \code{object@betahat}. This will be either an \emph{F} test or a chi-square (Wald) test depending on whether degrees of freedom are available. See also \code{\link{joint_tests}}.} @@ -303,7 +303,7 @@ If a data frame is needed, \code{summary}, \code{confint}, \eqn{\sqrt{rF(\alpha; r, d)}}{sqrt[r*qf(alpha, r, d)]}, where \eqn{d} is the error degrees of freedom and \eqn{r} is the rank of the set of linear functions under consideration. By default, the value of \code{r} is - computed from \code{object@linfct} for each by group; however, if the + computed from \code{linfct(object)} for each by group; however, if the user specifies an argument matching \code{scheffe.rank}, its value will be used instead. Ordinarily, if there are \eqn{k} means involved, then \eqn{r = k - 1} for a full set of contrasts involving all \eqn{k} means, and diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 05db20b..7cf666d 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -68,6 +68,7 @@ reference: - emm - emm_example - emm_options + - linfct - make.tran - str.emmGrid diff --git a/vignettes/messy-data.Rmd b/vignettes/messy-data.Rmd index 1b2f91f..3a9f6f7 100644 --- a/vignettes/messy-data.Rmd +++ b/vignettes/messy-data.Rmd @@ -274,10 +274,10 @@ And let's construct two different reference grids: ```{r} rg.usual <- ref_grid(mtcars.lm) rg.usual -nrow(rg.usual@linfct) +nrow(linfct(rg.usual)) rg.nuis = ref_grid(mtcars.lm, non.nuisance = "cyl") rg.nuis -nrow(rg.nuis@linfct) +nrow(linfct(rg.nuis)) ``` Notice that we left `am` out of `non.nuisance` and hence included it in `nuisance`. However, it interacts with `cyl`, so it was not allowed as a nuisance factor.