Learn R Programming

speccurvieR (version 1.0.0)

plot_multi_se: Plots a specification curve under multiple standard error types.

Description

plot_multi_se() estimates every specification (as `sca()` does) and, for each, computes the independent variable's standard error under several types via `se_compare()`. It then plots the specification curve faceted by standard error type: the coefficient estimates are identical across facets, but the confidence intervals -- and hence which specifications are "significant" -- change with the choice of standard error, showing how sensitive your conclusions are to that choice.

Usage

plot_multi_se(
  y,
  x,
  controls,
  data,
  types = c("iid", "HC3"),
  cluster = NULL,
  fixed_effects = NULL,
  level = 0.95,
  title = ""
)

Value

A ggplot object: the specification curve faceted by standard error type, points coloured by significance under each type.

Arguments

y

A string containing the column name of the dependent variable in data. Alternatively, a two-sided formula specifying the whole model, e.g. `y ~ x + control1 + control2 | fixedEffect`. When a formula is supplied the first right-hand-side term is taken as the independent variable `x`, the remaining terms as `controls`, and anything after `|` as `fixed_effects`; the `x`, `controls`, and `fixed_effects` arguments are then taken from the formula. `data` may be passed positionally in this case, e.g. `sca(y ~ x + z, data)`.

x

A string containing the column name of the independent variable in data.

controls

A vector of strings containing the column names of the control variables in data.

data

A dataframe containing y, x, controls, and (optionally) the variables to be used for fixed effects or clustering.

types

A vector of standard error types to compare, passed to `se_compare()`: `"iid"`, the `"HC*"` types, or (with `cluster`) clustered types. Defaults to `c("iid", "HC3")`. Bootstrapped standard errors are not supported here; use `se_compare()` directly for those.

cluster

Optional clustering variable(s) passed to `se_compare()`.

fixed_effects

A string containing the column name of the variable in data desired for fixed effects. Defaults to NULL in which case no fixed effects are included.

level

The confidence level used for the intervals. Defaults to `0.95`.

title

A string to use as the plot title. Defaults to `""`.

Examples

Run this code
plot_multi_se(y = "Salnty", x = "T_degC", controls = c("ChlorA", "O2Sat"),
            data = bottles, types = c("iid", "HC1", "HC3"));

Run the code above in your browser using DataLab