o_beta_rsq: beta*s over a range of maximum R-squares

Description Usage Arguments Details Value References Examples

View source: R/robomit_functions.R

Description

Estimates beta*s, i.e., the bias-adjusted treatment effects (or correlations) (following Oster 2019) over a range of maximum R-squares.

Usage

1
2
o_beta_rsq(y, x, con, m = "none", w = NULL, id = "none", time = "none", delta = 1,
type, data)

Arguments

y

Name of the dependent variable (as string).

x

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

con

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

m

Name of unrelated control variables (m; see Oster 2019; as string; default is m = "none").

w

weights (only for weighted estimations). Warning: For weighted panel models R can report different R-square than Stata, leading deviation between R and Stata results.

id

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

time

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

delta

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

type

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

data

Dataset.

Details

Estimates beta*s, i.e., the bias-adjusted treatment effects (or correlations) (following Oster 2019) over a range of maximum R-squares. The range of maximum R-squares starts from the R-square of the controlled model rounded up to the next 1/100 to 1. The function supports linear cross-sectional (see lm objects in R) and fixed effect panel (see plm objects in R) models.

Value

Returns tibble object, which includes beta*s over a range of maximum R-squares.

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
# 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 delta*s over a range of maximum R-squares
o_beta_rsq(y = "mpg",            # dependent variable
           x = "wt",             # independent treatment variable
           con = "hp + qsec",    # related control variables
           delta = 1,            # delta
           type = "lm",          # model type
           data = data_oster)    # dataset

Example output

                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1
# A tibble: 17 x 3
       x  Rmax `Beta*`
   <int> <dbl>   <dbl>
 1     1 0.84  -4.23  
 2     2 0.85  -3.96  
 3     3 0.86  -3.64  
 4     4 0.87  -3.28  
 5     5 0.88  -2.89  
 6     6 0.89  -2.46  
 7     7 0.900 -2.00  
 8     8 0.910 -1.52  
 9     9 0.92  -1.02  
10    10 0.93  -0.512 
11    11 0.94   0.0123
12    12 0.95   0.546 
13    13 0.96   1.09  
14    14 0.97   1.63  
15    15 0.98   2.19  
16    16 0.99   2.74  
17    17 1      3.31  

robomit documentation built on June 22, 2021, 9:09 a.m.

Related to o_beta_rsq in robomit...