o_beta_boot_viz: Visualization of bootstrapped betas*

Description Usage Arguments Details Value References Examples

View source: R/robomit_functions.R

Description

Estimates and visualizes bootstrapped betas*, i.e. the estimated bias-adjusted treatment effects, following Oster (2019).

Usage

1
2
3
o_beta_boot_viz(y, x, con, id = "none", time = "none", delta = 1, R2max, sim, obs, rep,
CI, type, norm = TRUE, bin, col = c("#08306b","#4292c6","#c6dbef"),
nL = TRUE, 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.

delta

Delta for which beta* should be estimated (default is delta = 1).

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 betas*, i.e. the estimated bias-adjusted treatment effects, 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 betas*.

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 betas*
o_beta_boot_viz(y = "mpg",                # define the dependent variable name
                    x = "wt",             # define the main independent variable name
                    con = "hp + qsec",    # other control variables
                    delta = 1,            # define delta This is usually set to 1
                    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.