specs_plot: Draw a specification plot.

View source: R/specs_plots.R

specs_plotR Documentation

Draw a specification plot.

Description

specs_plot produces the specification plot with 2 panels: coefficient and control grid.

Usage

specs_plot(
  coefs,
  palette = "green",
  ratio = 2,
  coef_ylabel = "Coefficient estimate",
  coef_ylim = NULL,
  coef_xlabel = NULL,
  label_text_size = NULL,
  point_size = NULL,
  error_alpha = NULL,
  error_geom = NULL,
  error_width = 0,
  hline = NULL,
  control_geom = "rect",
  control_spacing = NULL,
  control_text_size = 9,
  trim_top = 0,
  ...
)

Arguments

coefs

A dataframe with the following components: names of indicators for specs, coef, error_low, error_high, pval

palette

Change the palette. Default to "green" for green-shaded plot. Change to "brown" for brown-shaded plot.

ratio

A numeric scalar indicating the height ratio of the coefficient plot relative to the control grid plot.

coef_ylabel

A string specifying the y-axis label on the coefficient panel. Default to "Coefficient estimate".

coef_ylim

A numeric vector of length two indicating the minimum and maximum values of the y-axis in the coefficient plot. Default to NULL to use ggplot2 default.

coef_xlabel

A string specifying the x-axis label on the coefficient panel. Default to NULL for none.

label_text_size

A numeric scalar indicating how large the text for the axis labels should be. Default to NULL for ttr::theme_tt() default.

point_size

A numeric scalar indicating the size of the coefficient estimate points. Default to NULL and set according to the number of specs.

error_alpha

A numeric scalar indicating the alpha of the error geom. Default to NULL and set to 0.5 for "errorbar" and 0.21 for "ribbon".

error_geom

A string indicating the type of geom that should be used to depict confidence intervals on coefficient estimates. Currently supported are "ribbon", "errorbar", and "none". Default to NULL and set to "errorbar"if fewer than 100 specs and to"ribbon"' otherwise.

error_width

A numeric scalar indicating the width of the error bar. Default to 0 and only applicable when error_geom is set to "errorbar".

hline

A numeric scalar indicating a horizontal line at value hline. Default to NULL for none.

control_geom

A string indicating the geom that should be used to indicate the presence of controls. Currently supported are "circle" and "rect". Default to "rect".

control_spacing

A numeric scalar indicating how large the control geoms should be. For control_geom=="circle", this is the diameter of the circle. For control_geom=="rect", this is the width of the rectangle. Default to NULL and set to 0.75 if fewer than 40 specs and 1 otherwise.

control_text_size

A numeric scalar indicating how large the control name text should be. Default to 9.

trim_top

A numeric scalar indicating how close the bottom panel (displaying presence of controls) should be to the top panel (displaying presence of coefficients). Useful when dealing with large CIs. Default to -1.

...

Other arguments passed to ttr::theme_tt()

Value

A list of 3 ggplot2 objects, coef_plot depicting the coefficient plot, control_plot depicting the control panel, and spec_plot depicting the specification plot with both coefficient and control panels


ttecon/ttr documentation built on March 6, 2023, 7:36 a.m.