QuickCoefPlot: QuickCoefPlot

Description Usage Arguments Examples

Description

QuickCoefPlot (aka qcp) is an easy interface for linear regression coefficient plots in R. This includes the option to request robust and clustered standard errors, automatic labeling, and easy selection of coefficients to plot. Written by Sondre U. Solstad (ssolstad@princeton.edu) - Please cite my github: github.com/sondreus/QuickCoefPlot.

Usage

1
2
3
4
5
QuickCoefPlot(model, iv.vars.names, plot.title, include.only, robust.se,
  cluster, cluster.vars.names, boot.se, boot.b, boot.plot.est, plot.lines,
  plot.margin = c(0.5, 0.5, 0.5, 0.5), legend.on, colors.off, text.size,
  add.summary.lines, hide.summary.lines, xlim, save.summary.df, horserace,
  ...)

Arguments

model

Fitted "lm" or "glm" object.

iv.vars.names

(Optional) Vector of desired independent variable names in table output (e.g. c("GDP per capita", "Population")). Defaults to values in "iv.vars" if none provided.

plot.title

(Optional) Specifies the title of the coefficient plot. Defaults to no title.

include.only

(Optional) Vector of coefficients by number to keep in the plot (e.g. c(1, 2, 6)). If none specified, defaults to all.

robust.se

(Optional) If TRUE, returns robust standard errors calculated using a sandwich estimator from the "sandwich" package. Defaults to TRUE (i.e. robust rather than normal standard errors).

cluster

(Optional) Name of variable by which cluster-robust standard errors should be computed using the cluster.vcov command of the multiwayvcov package. If this variable is not in the model, a data frame common to both the model variables and the clustering variable must be supplied.

cluster.vars.names

(Optional) Desired name or label of clustering variable to be reported in table output (e.g. "Country" yields a note on the bottom of the table reading "Country-Clustered Standard Errors in Parenthesis"). If cluster specified but no "cluster.vars.names" provided, "Cluster-Robust Standard Errors in Parenthesis" is reported.

boot.se

(Optional) If TRUE, calculates confidence interval based on bootstrap simulations. By default based on 100 such simulations, see boot.b below.

boot.b

(Optional) Integer specifying the number of bootstrap simulation to run if boot.se is set to TRUE. Defaults to 100.

boot.plot.est

(Optional) If TRUE, plots the bootstrap estimates semi-transparently on the coefficient plot. Defaults to FALSE.

plot.lines

(Optional) If FALSE, does not plot confidence intervals on the coefficient plot. Defaults to TRUE.

plot.margin

(Optional) Vector of plot margins in centimeters. Defaults to (1, 1, 1, 1).

legend.on

(Optional) If TRUE turns on the plot legend. Defaults to FALSE.

colors.off

(Optional) If TRUE turns off color scheme (sky-blue if p > 0.1, dark blue if p < 0.1, black if p < 0.05). Defaults to FALSE.

text.size

(Optional) Text size for plot elements.

add.summary.lines

(Optional) Vector of summary lines to add to plot. If none supplied, defaults to none.

hide.summary.lines

(Optional) Vector of summary lines to hide in plot output. If none supplied, defaults to none.

xlim

(Optional) Vector of limits on x-axis of plot. If none supplied, this is automatically selected by ggplot.

save.summary.df

(Optional) Saves the coefficients and standard errors to a new data frame called "qcp.summary.df".

horserace

(Optional) If TRUE Produces a table comparing t-statistics instead of a coefficient plot.

...

(Optional) arguments passed to ggplot's theme() function.

Examples

1
2
3
4
QuickCoefPlot(lm(x ~y, data = mydata))
qcp(lm(x ~ y), data = mydata, boot.se = TRUE, boot.plot.est = TRUE, legend.on = TRUE))

Please see: github.com/sondreus/QuickCoefPlot

sondreus/QuickCoefPlot documentation built on May 28, 2020, 12:30 p.m.