| plot.fixest | R Documentation |
fixest and fixest_multi objectsPlot method reporting the coefficient estimates and their confidence intervals.
This is a wrapper to the more complete functions coefplot and iplot.
## S3 method for class 'fixest'
plot(
x,
vcov = NULL,
add = FALSE,
horiz = FALSE,
do_iplot = NULL,
zero = TRUE,
zero.par = TRUE,
dict = NULL,
keep = NULL,
drop = NULL,
order = NULL,
ci.width = "1%",
ci_level = 0.95,
plot_prms = list(),
ylim = NULL,
xlim = NULL,
pch = c(20, 17, 15, 21, 24, 22),
col = 1:8,
cex = 1,
lty = 1,
lwd = 1,
pt.pch = pch,
pt.bg = NULL,
pt.cex = cex,
pt.col = col,
ci.col = col,
pt.lwd = lwd,
ci.lwd = lwd,
ci.lty = lty,
main = "Effect on __depvar__",
value.lab = "Estimate and __ci__ Conf. Int.",
ylab = NULL,
xlab = NULL,
sub = NULL,
...
)
x |
A |
vcov |
Versatile argument to specify the VCOV. In general, it is either a character scalar equal to a VCOV type, either a formula of the form: vcov_type ~ variables. The VCOV types implemented are: "iid", "hetero" (or "HC1"), "cluster", "twoway", "NW" (or "newey_west"), "DK" (or "driscoll_kraay"), and "conley". It also accepts object from vcov_cluster, vcov_NW, NW, vcov_DK, DK, vcov_conley and conley. It also accepts covariance matrices computed externally. Finally it accepts functions to compute the covariances. See the vcov documentation in the vignette. You can pass several VCOVs (as above) if you nest them into a list.
If the number of VCOVs equals the number of models, eahc VCOV is mapped to the appropriate model.
If there is one model and several VCOVs, or if the first element of the list is equal to
|
add |
Default is |
horiz |
A logical scalar, default is |
do_iplot |
Logical, default is |
zero |
Logical scalar, default is |
zero.par |
A named list of graphical parameters or a logical scalar.
This argument is a list containing the graphical parameters used to draw the zero-line.
The default value is |
dict |
A named character vector or a logical scalar. It changes the original variable names
to the ones contained in the |
keep |
Character vector. This element is used to display only a subset of variables. This
should be a vector of regular expressions (see Example: you have the variable |
drop |
Character vector. This element is used if some variables are not to be displayed.
This should be a vector of regular expressions (see Example: you have the variable |
order |
Character vector. This element is used if the user wants the variables to be
ordered in a certain way. This should be a vector of regular expressions (see Example: you have the following variables: |
ci.width |
The width of the extremities of the confidence intervals. Default is |
ci_level |
Scalar between 0 and 1: the level of the CI. By default it is equal to 0.95. |
plot_prms |
A named list. It may contain additionnal parameters to be passed to the plot. |
ylim |
Numeric vector of length 2 which gives the limits of the plotting region for
the y-axis. The default is |
xlim |
Numeric vector of length 2 which gives the limits of the plotting region for
the x-axis. The default is |
pch |
The patch of the coefficient estimates. Default is 1 (circle).
This is an alias to tha argument |
col |
The color of the points and the confidence intervals. Default is 1
("black"). Note that you can set the colors separately for each of them
with |
cex |
Numeric, default is 1. Expansion factor for the points |
lty |
The line type of the confidence intervals. Default is 1.
This is an alias to the argument |
lwd |
General line with. Default is 1. |
pt.pch |
The patch of the coefficient estimates. Default is 1 (circle). |
pt.bg |
The background color of the point estimate (when the |
pt.cex |
The size of the coefficient estimates. Default is the other argument |
pt.col |
The color of the coefficient estimates. Default is equal to the argument |
ci.col |
The color of the confidence intervals. Default is equal to the argument |
pt.lwd |
The line width of the coefficient estimates. Default is equal to
the other argument |
ci.lwd |
The line width of the confidence intervals. Default is equal to
the other argument |
ci.lty |
The line type of the confidence intervals. Default is 1. |
main |
The title of the plot. Default is |
value.lab |
The label to appear on the side of the coefficient values. If
|
ylab |
The label of the y-axis, default is |
xlab |
The label of the x-axis, default is |
sub |
A subtitle, default is |
... |
Other arguments to be passed to |
By default plot.fixest runs coefplot unless the estimation includes
the function sunab, in which case it uses iplot.
The switch to iplot can be made with the argument do_iplot = TRUE.
It returns invisibly the data used to create the graph.
The arguments keep, drop and order use regular expressions. If you are not aware
of regular expressions, I urge you to learn it, since it is an extremely powerful way
to manipulate character strings (and it exists across most programming languages).
For example drop = "Wind" would drop any variable whose name contains "Wind". Note that
variables such as "Temp:Wind" or "StrongWind" do contain "Wind", so would be dropped.
To drop only the variable named "Wind", you need to use
drop = "^Wind$" (with "^" meaning beginning, resp. "$" meaning end,
of the string => this is the language of regular expressions).
Although you can combine several regular expressions in a single character
string using pipes, drop also accepts a vector of regular expressions.
You can use the special character "!" (exclamation mark) to reverse the effect
of the regular expression (this feature is specific to this function).
For example drop = "!Wind" would drop any variable that does not contain "Wind".
By default, the regular expressions are checked against the variables after
they have been renamed with the dictionary (argument dict).
You can use the *_raw versions of drop/keep/order to apply the regular
expressions on the original variable names.
Note that alternatively you can use the special character "%" (percentage) at the
beginning of drop/keep/order's regular expressions to refer to the original variable name.
For example, you have a variable named "Month6",
and use a dictionary dict = c(Month6="June").
Thus the variable will be displayed as "June".
If you want to delete that variable, you can use either drop="June", drop_raw="Month6",
or drop="%Month6".
The argument order takes in a vector of regular expressions, the order will follow the
elements of this vector. The vector gives a list of priorities,
on the left the elements with highest priority.
For example, order = c("Wind", "!Inter", "!Temp") would give highest priorities to
the variables containing "Wind" (which would then appear first),
second highest priority is the variables not containing "Inter", last,
with lowest priority, the variables not containing "Temp".
If you had the following variables: (Intercept), Temp:Wind, Wind, Temp you
would end up with the following order: Wind, Temp:Wind, Temp, (Intercept).
#
# Single estimation
#
est = feols(Ozone ~ Temp + Solar.R, airquality)
plot(est)
# focus only on the variables
plot(est, drop = "Cons")
#
# Multiple estimations
#
est_mult = feols(Ozone ~ csw(Temp, Solar.R, Wind), airquality)
plot(est_mult, drop = "Const")
#
# DiD estimation: Sun & Abraham
#
data(base_stagg)
# The DiD estimation
res_sunab = feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg)
plot(res_sunab)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.