plot.fect: Plot Method for 'fect' Objects

View source: R/plot.R

plot.fectR Documentation

Plot Method for 'fect' Objects

Description

Visualizes results from a fect estimation.

Usage

## S3 method for class 'fect'
plot(
    x,
    type = NULL,
    loo = FALSE,
    highlight = NULL,
    plot.ci = NULL,
    show.points = NULL,
    show.group = NULL,
    bound = NULL,
    vis = NULL,
    count = TRUE,
    proportion = 0.3,
    pre.periods = NULL,
    f.threshold = NULL,
    tost.threshold = NULL,
    effect.bound.ratio = FALSE,
    stats = NULL,
    stats.labs = NULL,
    raw = "none",
    main = NULL,
    xlim = NULL,
    ylim = NULL,
    xlab = NULL,
    ylab = NULL,
    xangle = NULL,
    yangle = NULL,
    xbreaks = NULL,
    ybreaks = NULL,
    xticklabels = NULL,
    yticklabels = NULL,
    gridOff = FALSE,
    legendOff = FALSE,
    legend.pos = NULL,
    legend.nrow = NULL,
    legend.labs = NULL,
    stats.pos = NULL,
    show.stats = TRUE,
    theme.bw = TRUE,
    nfactors = NULL,
    include.FE = TRUE,
    id = NULL,
    cex.main = NULL,
    cex.main.sub = NULL,
    cex.axis = NULL,
    cex.lab = NULL,
    cex.legend = NULL,
    cex.text = NULL,
    axis.adjust = FALSE,
    axis.lab = "both",
    axis.lab.gap = c(0, 0),
    shade.post = FALSE,
    start0 = FALSE,
    return.test = FALSE,
    balance = NULL,
    weight = NULL,
    line.color = NULL,
    line.width = c(1.2, 0.5),
    lcolor = NULL,
    lwidth = NULL,
    ...
)

Arguments

x

A fitted fect object.

type

Plot type: "gap", "equiv", "status", "exit", "factors", "loadings", "calendar", "box", or "counterfactual".

loo

Logical; if TRUE, use leave-one-out for equivalence tests.

highlight

Logical; if TRUE, highlight certain periods (e.g., placebo).

plot.ci

Specifies the confidence interval to be plotted. Options include: "0.9", "0.95", or "none". Default depends on the context.

show.points

Logical; if TRUE, shows point estimates on the plot.

show.group

Optional; specify a subgroup to plot.

bound

Which bounds to display in bounding/equivalence tests: "none", "min", "equiv", or "both".

vis

Controls line display for placebo/carryover tests: "connected" or "none".

count

Logical; if TRUE, shows a histogram of observation counts.

proportion

Restrict plotted time points to those with at least this fraction of the max units.

pre.periods

Specifies pre-treatment periods used for bounding.

f.threshold

F-test threshold in equivalence checks.

tost.threshold

Threshold for TOST-based checks.

effect.bound.ratio

If TRUE, shows the ratio of ATT to the minimal bound.

stats

Specifies which statistics to display: e.g., "F.p", "equiv.p".

stats.labs

Custom labels for the displayed statistics.

raw

For "counterfactual" plot: "none", "band", or "all".

main

Main plot title.

xlim

Specifies x-axis limits.

ylim

Specifies y-axis limits.

xlab

x-axis label.

ylab

y-axis label.

xangle

Angle (in degrees) for x-axis labels.

yangle

Angle (in degrees) for y-axis labels.

xbreaks

Positions of major ticks on the x-axis.

ybreaks

Positions of major ticks on the y-axis.

xticklabels

Labels for the x-axis ticks.

yticklabels

Labels for the y-axis ticks.

gridOff

Logical; if TRUE, removes grid lines.

legendOff

Logical; if TRUE, hides the legend.

legend.pos

Position of the legend.

legend.nrow

Number of rows in the legend.

legend.labs

Custom legend labels.

stats.pos

(x,y) coordinates for displaying text of test statistics.

show.stats

Logical; if TRUE, displays test statistics on the plot.

theme.bw

Logical; if TRUE, uses a black-and-white ggplot2 theme.

nfactors

Number of factors to plot when type is "factors" or "loadings".

include.FE

Logical; if TRUE, includes fixed effects as additional "factors".

id

When specified, plots only the chosen unit(s).

cex.main

Font size of the main title.

cex.main.sub

Font size of a possible subtitle.

cex.axis

Font size of axis tick labels.

cex.lab

Font size of axis labels.

cex.legend

Font size of legend text.

cex.text

Font size for text annotations.

axis.adjust

If TRUE, attempts to adjust axis labels for large data.

axis.lab

Controls axis labeling in "status" plots. Could be "both", "time", "unit", or "off".

axis.lab.gap

Gap spacing for axis labels in "status" plots.

shade.post

If TRUE, shades post-treatment periods in certain plots.

start0

If TRUE, re-indexes the first post-treatment period as 0.

return.test

If return.test=TRUE, returns test statistics along with the plot.

balance

Logical; if TRUE, uses a "balance sample" from the fect object.

weight

Logical; if TRUE, applies weighting from the fect object.

line.color

Color for main plot lines.

line.width

A numeric vector specifying line widths for different line types.

lcolor

Color for reference lines (e.g., 0 line, vertical lines).

lwidth

Line width for reference lines.

...

Additional graphical parameters passed to internal plotting routines.

Details

plot.fect generates various visualizations for objects estimated via fect. Depending on the selected type, it can show treatment-effect dynamics, equivalence test outcomes, factor/loadings for factor models, or raw vs. counterfactual trajectories.

Value

p

A ggplot2 object containing the requested plot.

test.out

If return.test=TRUE, includes relevant test statistics (F-tests, equivalence p-values, etc.).

Author(s)

Licheng Liu, Ye Wang, Yiqing Xu, Ziyi Liu

References

Xu, Y. (2017). Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models. Political Analysis, 25(1), 57–76.

Examples

library(fect)
data(fect)
out.fect <- fect(Y ~ D + X1 + X2, data = simdata, index = c("id","time"), 
  method = "fe", force = "two-way", se = TRUE, parallel = TRUE, nboots = 200)
plot(out.fect, main = "Estimated ATT (FEct)", ylab = "Effect of D on Y")

xuyiqing/fect documentation built on April 12, 2025, 9:50 p.m.