iplot_data {ggfixest}R Documentation

Internal function for grabbing and preparing iplot data.

Description

Grabs the underlying data used to construct fixest::iplot, with some added functionality and tweaks for the ggiplot equivalents.

Usage

iplot_data(
  object,
  .ci_level = 0.95,
  .keep = NULL,
  .drop = NULL,
  .dict = fixest::getFixest_dict(),
  .internal.only.i = TRUE,
  .i.select = 1,
  .aggr_es = NULL,
  .group = "auto",
  .vcov = NULL,
  .cluster = NULL,
  .se = NULL
)

coefplot_data(
  object,
  .ci_level = 0.95,
  .keep = NULL,
  .drop = NULL,
  .group = "auto",
  .dict = fixest::getFixest_dict(),
  .internal.only.i = FALSE,
  .i.select = 1,
  .aggr_es = "none",
  .vcov = NULL,
  .cluster = NULL,
  .se = NULL
)

Arguments

object

A model object of class fixest or fixest_multi, where the i() operator has been used to construct an interaction, or set of interactions.

.ci_level

A number between 0 and 1 indicating the desired confidence level, Defaults to 0.95.

.keep

Character vector used to subset the coefficients of interest. Passed down to fixest::iplot(..., keep = .keep) and should take the form of an acceptable regular expression.

.drop

Character vector used to subset the coefficients of interest (complement of .keep). Passed down to fixest::iplot(..., drop = .drop) and should take the form of an acceptable regular expression.

.dict

A dictionary (i.e. named character vector or a logical scalar). Used for changing coefficient names. Defaults to the values in getFixest_dict(). See the ?fixest::coefplot documentation for more information. Note: This argument applies dictionary changes directly to the return object for coefplot_data. However, it is ignored for iplot_data, since we want to preserve the numeric ordering for potential event study plots. (And imposing an ordered factor would create its own downstream problems in the case of continuous plot features like ribbons.) Instead, any dictionary replacement for ggiplot is deferred to the actual plot call and applied directly to the labels.

.internal.only.i

Logical variable used for some internal function handling when passing on to coefplot/iplot.

.i.select

Integer scalar, default is 1. In (gg)iplot, used to select which variable created with i() to select. Only used when there are several variables created with i. This is an index, just try increasing numbers to hopefully obtain what you want. Passed down to fixest::iplot(..., i.select = .i.select)

.aggr_es

A keyword string or numeric sequence indicating whether the aggregated mean treatment effects for some subset of the model should be added as a column to the returned data frame. Passed to aggr_es(..., aggregation = "mean").

.group

A list, default is missing. Each element of the list reports the coefficients to be grouped while the name of the element is the group name. Passed down to fixest::coefplot(..., group = .group). Example of valid uses:

  • group=list(group_name="pattern")

  • group=list(group_name=c("var_start", "var_end"))

  • group=list(group_name=1:2)

  • See the Details section of ?fixest::coefplot for more.

.vcov, .cluster, .se

Alternative options for adjusting the standard errors of the model object on the fly. See summary.fixest for details (although note that the "." period prefix should be ignored in the latter's argument documentation). Written here in superseding order; .cluster will only be considered if .vcov is not null, etc.

Details

This function is a wrapper around fixest::iplot(..., only.params = TRUE), but with various checks and tweaks to better facilitate plotting with ggplot2 and handling of complex object types (e.g. lists of fixest_multi models)

Value

A data frame consisting of estimate values, confidence intervals, relative x-axis positions, and other aesthetic information needed to draw a ggplot2 object.

Functions

See Also

fixest::iplot(), aggr_es().

Examples

library(fixest)

est_did = feols(y ~ x1 + i(period, treat, 5) | id+period,
                data = base_did)
iplot(est_did, only.params = TRUE) # The "base" version
iplot_data(est_did)                # The wrapper provided by this package

# Illustrative fixest_multi case, where the sample has been split by odd and
# even ID numbers.
est_split = feols(y ~ x1 + i(period, treat, 5) | id+period,
                  data = base_did, split = ~id%%2)
iplot(est_split, only.params = TRUE) # The "base" version
iplot_data(est_split)                # The wrapper provided by this package


[Package ggfixest version 0.1.0 Index]