o_delta_boot_viz: Visualization of bootstrapped deltas*

Description Usage Arguments Details Value References Examples

View source: R/robomit_functions.R

Description

Estimates and visualizes bootstrapped deltas*, i.e. the degree of selection on unobservables relative to observables that would be necessary to explain away the result, following Oster (2019).

Usage

1
2
3
o_delta_boot_viz(y, x, con, id = "none", time = "none", beta = 0, R2max, sim, obs, rep,
CI, type, norm = TRUE, bin, col = c("#08306b","#4292c6","#c6dbef"),
nL = FALSE, mL = TRUE, useed = NA, data)

Arguments

y

Name of the dependent variable (as string).

x

Name of the independent variable of interest (treatment variable; as string).

con

Name of the other control variables. Provided as string in the format: "w + z +...".

id

Name of the individual id variable (e.g. firm or farm; as string). Only applicable for fixed effect models.

time

Name of the time variable (e.g. year or month; as string). Only applicable for fixed effect models.

beta

Beta for which delta* should be estimated (default is beta = 0).

R2max

Max R-square for which beta* should be estimated.

sim

Number of simulations.

obs

Number of draws per simulation.

rep

Bootstrapping either with (= TRUE) or without (= FALSE) replacement

CI

Confidence intervals, indicated as vector. Can be and/or 90,95,99.

type

Model type (either lm or plm; as string).

norm

Option to include a normal distribution in the plot (default is norm = TURE).

bin

Number of bins used for the histogram.

col

Colors used to indicate different confidence interval levels (indicated as vector). Needs to be the same length as the variable CI. The default is a blue color range.

nL

Option to include a red vertical line at 0 (default is nL = TRUE).

mL

Option to include a vertical line at beta* mean (default is mL = TRUE).

useed

Seed number defined by user.

data

Data.

Details

Estimates and visualizes bootstrapped deltas*, i.e. the degree of selection on unobservables relative to observables that would be necessary to explain away the result, following Oster (2019). Bootstrapping can either be done with or without replacement. The function supports linear cross sectional (see lm objects in R) and panel fixed effect (see plm objects in R) models.

Value

Returns ggplot object. Including bootstrapped deltas*.

References

Oster, E. (2019). Unobservable selection and coefficient stability: Theory and evidence. Journal of Business & Economic Statistics, 37, 187-204.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# load data, e.g. the in-build mtcars dataset
data("mtcars")
data_oster <- mtcars

# preview of data
head(data_oster)

# load robomit
require(robomit)

# estimate and visualize bootstrapped deltas*
o_delta_boot_viz(y = "mpg",               # define the dependent variable name
                     x = "wt",            # define the main independent variable name
                     con = "hp + qsec",   # other control variables
                     beta = 0,            # define beta. This is usually set to 0
                     R2max = 0.9,         # define the max R-square.
                     sim = 100,           # define number of simulations
                     obs = 30,            # define number of drawn observations per simulation
                     rep = FALSE,         # define if bootstrapping is with or without replacement
                     CI = c(90,95,99),    # define confidence intervals.
                     type = "lm",         # define model type
                     norm = TRUE,         # include normal distribution
                     bin = 200,           # set number of bins
                     useed = 123,         # define seed
                     data = data_oster)   # define dataset

robomit documentation built on Sept. 15, 2020, 5:07 p.m.