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 - fixestor- 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::coefplotdocumentation 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- ggiplotis 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::coefplotfor more.
 
- .vcov, .cluster, .se
- Alternative options for adjusting the standard errors of the model object on the fly. See - vcov.fixestfor details (although note that the "." period prefix should be ignored in the latter's argument documentation). Written here in superseding order;- .clusterwill only be considered if- .vcovis not null, etc.
Value
A data frame consisting of estimate values, confidence intervals, relative x-axis positions, and other aesthetic information needed to draw a ggplot2 object.
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)
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
#> $prms
#>     estimate    ci_low   ci_high estimate_names estimate_names_raw is_ref  x id
#> 1  -1.403045 -3.585530 0.7794393              1    period::1:treat  FALSE  1  1
#> 2  -1.247511 -3.429620 0.9345983              2    period::2:treat  FALSE  2  1
#> 3  -0.273206 -2.456119 1.9097070              3    period::3:treat  FALSE  3  1
#> 4  -1.795721 -3.979055 0.3876142              4    period::4:treat  FALSE  4  1
#> 5   0.000000  0.000000 0.0000000              5    period::5:treat   TRUE  5  1
#> 6   0.784452 -1.397595 2.9664986              6    period::6:treat  FALSE  6  1
#> 7   3.598897  1.416102 5.7816931              7    period::7:treat  FALSE  7  1
#> 8   3.811766  1.629982 5.9935508              8    period::8:treat  FALSE  8  1
#> 9   4.731426  2.549626 6.9132260              9    period::9:treat  FALSE  9  1
#> 10  6.606229  4.424228 8.7882298             10   period::10:treat  FALSE 10  1
#>            y
#> 1  -1.403045
#> 2  -1.247511
#> 3  -0.273206
#> 4  -1.795721
#> 5   0.000000
#> 6   0.784452
#> 7   3.598897
#> 8   3.811766
#> 9   4.731426
#> 10  6.606229
#> 
#> $is_iplot
#> [1] TRUE
#> 
#> $at
#>  [1]  1  2  3  4  5  6  7  8  9 10
#> 
#> $labels
#>  [1]  1  2  3  4  5  6  7  8  9 10
#> 
iplot_data(est_did)                # The wrapper provided by this package
#>     estimate    ci_low   ci_high estimate_names estimate_names_raw is_ref  x id
#> 1  -1.403045 -3.585530 0.7794393              1    period::1:treat  FALSE  1  1
#> 2  -1.247511 -3.429620 0.9345983              2    period::2:treat  FALSE  2  1
#> 3  -0.273206 -2.456119 1.9097070              3    period::3:treat  FALSE  3  1
#> 4  -1.795721 -3.979055 0.3876142              4    period::4:treat  FALSE  4  1
#> 5   0.000000  0.000000 0.0000000              5    period::5:treat   TRUE  5  1
#> 6   0.784452 -1.397595 2.9664986              6    period::6:treat  FALSE  6  1
#> 7   3.598897  1.416102 5.7816931              7    period::7:treat  FALSE  7  1
#> 8   3.811766  1.629982 5.9935508              8    period::8:treat  FALSE  8  1
#> 9   4.731426  2.549626 6.9132260              9    period::9:treat  FALSE  9  1
#> 10  6.606229  4.424228 8.7882298             10   period::10:treat  FALSE 10  1
#>            y lhs ci_level
#> 1  -1.403045   y     0.95
#> 2  -1.247511   y     0.95
#> 3  -0.273206   y     0.95
#> 4  -1.795721   y     0.95
#> 5   0.000000   y     0.95
#> 6   0.784452   y     0.95
#> 7   3.598897   y     0.95
#> 8   3.811766   y     0.95
#> 9   4.731426   y     0.95
#> 10  6.606229   y     0.95
# 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
#> $prms
#>      estimate      ci_low    ci_high    x id estimate_names estimate_names_raw
#> 1   1.4239576 -1.60254257  4.4504578  0.9  1              1    period::1:treat
#> 2  -4.1291547 -7.24594391 -1.0123655  1.1  2              1    period::1:treat
#> 3   1.6931989 -1.33129200  4.7176898  1.9  1              2    period::2:treat
#> 4  -4.1353019 -7.25210013 -1.0185037  2.1  2              2    period::2:treat
#> 5   3.0439521  0.01936116  6.0685430  2.9  1              3    period::3:treat
#> 6  -3.4897091 -6.60819719 -0.3712210  3.1  2              3    period::3:treat
#> 7  -0.8667871 -3.89119509  2.1576210  3.9  1              4    period::4:treat
#> 8  -2.6458897 -5.76600810  0.4742287  4.1  2              4    period::4:treat
#> 9   0.0000000  0.00000000  0.0000000  4.9  1              5    period::5:treat
#> 10  0.0000000  0.00000000  0.0000000  5.1  2              5    period::5:treat
#> 11  3.8181620  0.79432122  6.8420028  5.9  1              6    period::6:treat
#> 12 -2.2626440 -5.37955551  0.8542676  6.1  2              6    period::6:treat
#> 13  5.1642678  2.13947329  8.1890624  6.9  1              7    period::7:treat
#> 14  2.0828305 -1.03527497  5.2009360  7.1  2              7    period::7:treat
#> 15  5.2338735  2.21040625  8.2573408  7.9  1              8    period::8:treat
#> 16  2.4826394 -0.63454538  5.5998242  8.1  2              8    period::8:treat
#> 17  7.0979736  4.07473245 10.1212148  8.9  1              9    period::9:treat
#> 18  2.4385390 -0.67859350  5.5556715  9.1  2              9    period::9:treat
#> 19  9.5453455  6.51516679 12.5755243  9.9  1             10   period::10:treat
#> 20  3.6267443  0.50754205  6.7459466 10.1  2             10   period::10:treat
#>    is_ref          y
#> 1   FALSE  1.4239576
#> 2   FALSE -4.1291547
#> 3   FALSE  1.6931989
#> 4   FALSE -4.1353019
#> 5   FALSE  3.0439521
#> 6   FALSE -3.4897091
#> 7   FALSE -0.8667871
#> 8   FALSE -2.6458897
#> 9    TRUE  0.0000000
#> 10   TRUE  0.0000000
#> 11  FALSE  3.8181620
#> 12  FALSE -2.2626440
#> 13  FALSE  5.1642678
#> 14  FALSE  2.0828305
#> 15  FALSE  5.2338735
#> 16  FALSE  2.4826394
#> 17  FALSE  7.0979736
#> 18  FALSE  2.4385390
#> 19  FALSE  9.5453455
#> 20  FALSE  3.6267443
#> 
#> $is_iplot
#> [1] TRUE
#> 
#> $at
#>  [1]  1  2  3  4  5  6  7  8  9 10
#> 
#> $labels
#>  [1]  1  2  3  4  5  6  7  8  9 10
#> 
iplot_data(est_split)                # The wrapper provided by this package
#>                              id   estimate      ci_low    ci_high  x
#> 1  sample.var: id%%2; sample: 0  1.4239576 -1.60254257  4.4504578  1
#> 2  sample.var: id%%2; sample: 0  1.6931989 -1.33129200  4.7176898  2
#> 3  sample.var: id%%2; sample: 0  3.0439521  0.01936116  6.0685430  3
#> 4  sample.var: id%%2; sample: 0 -0.8667871 -3.89119509  2.1576210  4
#> 5  sample.var: id%%2; sample: 0  0.0000000  0.00000000  0.0000000  5
#> 6  sample.var: id%%2; sample: 0  3.8181620  0.79432122  6.8420028  6
#> 7  sample.var: id%%2; sample: 0  5.1642678  2.13947329  8.1890624  7
#> 8  sample.var: id%%2; sample: 0  5.2338735  2.21040625  8.2573408  8
#> 9  sample.var: id%%2; sample: 0  7.0979736  4.07473245 10.1212148  9
#> 10 sample.var: id%%2; sample: 0  9.5453455  6.51516679 12.5755243 10
#> 11 sample.var: id%%2; sample: 1 -4.1291547 -7.24594391 -1.0123655  1
#> 12 sample.var: id%%2; sample: 1 -4.1353019 -7.25210013 -1.0185037  2
#> 13 sample.var: id%%2; sample: 1 -3.4897091 -6.60819719 -0.3712210  3
#> 14 sample.var: id%%2; sample: 1 -2.6458897 -5.76600810  0.4742287  4
#> 15 sample.var: id%%2; sample: 1  0.0000000  0.00000000  0.0000000  5
#> 16 sample.var: id%%2; sample: 1 -2.2626440 -5.37955551  0.8542676  6
#> 17 sample.var: id%%2; sample: 1  2.0828305 -1.03527497  5.2009360  7
#> 18 sample.var: id%%2; sample: 1  2.4826394 -0.63454538  5.5998242  8
#> 19 sample.var: id%%2; sample: 1  2.4385390 -0.67859350  5.5556715  9
#> 20 sample.var: id%%2; sample: 1  3.6267443  0.50754205  6.7459466 10
#>    estimate_names estimate_names_raw is_ref          y lhs sample ci_level
#> 1               1    period::1:treat  FALSE  1.4239576   y      0     0.95
#> 2               2    period::2:treat  FALSE  1.6931989   y      0     0.95
#> 3               3    period::3:treat  FALSE  3.0439521   y      0     0.95
#> 4               4    period::4:treat  FALSE -0.8667871   y      0     0.95
#> 5               5    period::5:treat   TRUE  0.0000000   y      0     0.95
#> 6               6    period::6:treat  FALSE  3.8181620   y      0     0.95
#> 7               7    period::7:treat  FALSE  5.1642678   y      0     0.95
#> 8               8    period::8:treat  FALSE  5.2338735   y      0     0.95
#> 9               9    period::9:treat  FALSE  7.0979736   y      0     0.95
#> 10             10   period::10:treat  FALSE  9.5453455   y      0     0.95
#> 11              1    period::1:treat  FALSE -4.1291547   y      1     0.95
#> 12              2    period::2:treat  FALSE -4.1353019   y      1     0.95
#> 13              3    period::3:treat  FALSE -3.4897091   y      1     0.95
#> 14              4    period::4:treat  FALSE -2.6458897   y      1     0.95
#> 15              5    period::5:treat   TRUE  0.0000000   y      1     0.95
#> 16              6    period::6:treat  FALSE -2.2626440   y      1     0.95
#> 17              7    period::7:treat  FALSE  2.0828305   y      1     0.95
#> 18              8    period::8:treat  FALSE  2.4826394   y      1     0.95
#> 19              9    period::9:treat  FALSE  2.4385390   y      1     0.95
#> 20             10   period::10:treat  FALSE  3.6267443   y      1     0.95