From 51b2f2711d795dba47865cb81bbcdf16edd8f1e0 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Mon, 16 Dec 2024 13:36:11 -0800 Subject: [PATCH] Lean false (#58) * lean = FALSE * gof catch * news --- NEWS.md | 8 +++++--- R/emfx.R | 17 ++++++++--------- man/emfx.Rd | 17 ++++++++--------- vignettes/etwfe.Rmd | 1 + 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/NEWS.md b/NEWS.md index b8d0645..ad7c2c8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,9 +7,11 @@ allows for obtaining the linear prediction for non-linear models. Internally passed as `marginaleffects::slopes(..., type = predict)`, thus avoiding a clash with the topline `emfx(..., type = )` argument. (#49) -- `emfx(..., lean = TRUE)` ensures a light return object by default, by -stripping away data-heavy attributes that are unlikely to be needed afterwards. -(#51) +- `emfx(..., lean = )`. Default value is `FALSE`, but switching to +`TRUE` will ensure a light return object that strips away data-heavy attributes +(e.g., copies of the original model). These attributes are unlikely to be needed +as part of the `emfx()` workflow, so we may change the default to `lean = TRUE` +in a future version of **etwfe**. (#51, #58) - Native `plot.emfx()` method (via a **tinyplot** backend) for visualizing `emfx` objects. (#54) diff --git a/R/emfx.R b/R/emfx.R index b54d0bf..b8d12da 100644 --- a/R/emfx.R +++ b/R/emfx.R @@ -51,14 +51,13 @@ #' that behaviour via `FALSE` is _strictly_ performative: the "zero" treatment #' effects for any pre-treatment periods is purely an artefact of the #' estimation setup. -#' @param lean Logical. Enforces a lean return object; namely a simple -#' data.frame of the main results, stripped of ancillary attributes. Defaults -#' to `TRUE`, in which case `options(marginaleffects_lean = TRUE)` is set -#' internally at the start of the `emfx` call, before being reverted upon -#' exit. Note that this will disable some advanced `marginaleffects` -#' post-processing features, but those are unlikely to be used in the `emfx` -#' context and means that we can dramatically reduce the size of the return -#' object. +#' @param lean Logical. Default is `FALSE`. Switching to `TRUE` enforces a lean +#' return object; namely a simple data.frame of the main results, stripped of +#' ancillary attributes. Note that this will disable some advanced +#' `marginaleffects` post-processing features, but those are unlikely to be +#' used in the `emfx` context. The upside is a potentially dramatic reduction +#' in the size of the return object. Consequently, we may change the default +#' to `TRUE` in a future version of **etwfe**. #' @param ... Additional arguments passed to #' [`marginaleffects::slopes`]. For example, you can pass `vcov = #' FALSE` to dramatically speed up estimation times of the main marginal @@ -105,7 +104,7 @@ emfx = function( collapse = compress, predict = c("response", "link"), post_only = TRUE, - lean = TRUE, + lean = FALSE, ... ) { diff --git a/man/emfx.Rd b/man/emfx.Rd index 54620ee..390af7d 100644 --- a/man/emfx.Rd +++ b/man/emfx.Rd @@ -12,7 +12,7 @@ emfx( collapse = compress, predict = c("response", "link"), post_only = TRUE, - lean = TRUE, + lean = FALSE, ... ) } @@ -67,14 +67,13 @@ that behaviour via \code{FALSE} is \emph{strictly} performative: the "zero" trea effects for any pre-treatment periods is purely an artefact of the estimation setup.} -\item{lean}{Logical. Enforces a lean return object; namely a simple -data.frame of the main results, stripped of ancillary attributes. Defaults -to \code{TRUE}, in which case \code{options(marginaleffects_lean = TRUE)} is set -internally at the start of the \code{emfx} call, before being reverted upon -exit. Note that this will disable some advanced \code{marginaleffects} -post-processing features, but those are unlikely to be used in the \code{emfx} -context and means that we can dramatically reduce the size of the return -object.} +\item{lean}{Logical. Default is \code{FALSE}. Switching to \code{TRUE} enforces a lean +return object; namely a simple data.frame of the main results, stripped of +ancillary attributes. Note that this will disable some advanced +\code{marginaleffects} post-processing features, but those are unlikely to be +used in the \code{emfx} context. The upside is a potentially dramatic reduction +in the size of the return object. Consequently, we may change the default +to \code{TRUE} in a future version of \strong{etwfe}.} \item{...}{Additional arguments passed to \code{\link[marginaleffects:slopes]{marginaleffects::slopes}}. For example, you can pass \code{vcov = FALSE} to dramatically speed up estimation times of the main marginal diff --git a/vignettes/etwfe.Rmd b/vignettes/etwfe.Rmd index 913cf0a..73f12e6 100644 --- a/vignettes/etwfe.Rmd +++ b/vignettes/etwfe.Rmd @@ -317,6 +317,7 @@ modelsummary( list(mod_es2, mod_es), shape = term:event:statistic ~ model, coef_rename = rename_fn, + gof_omit = "Adj|Within|IC|RMSE", stars = TRUE, title = "Event study", notes = "Std. errors are clustered at the county level"