analyses: Analysis Function for Replications.

Description Usage Arguments Value Examples

View source: R/analyses.R

Description

Analysis Function for Replications.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
analyses(
  DV,
  treat,
  data,
  model = "lm",
  covs = NULL,
  heterogenous = NULL,
  subset = NULL,
  FE = NULL,
  cluster = NULL,
  IV_list = NULL,
  robust = is.null(cluster),
  ri = NULL,
  IPW = NULL,
  treat_only = FALSE,
  margin_at = NULL,
  status = NULL,
  stars = FALSE,
  round_digits = 3,
  return_df = FALSE,
  seed = 12345,
  cores = 4
)

Arguments

DV

Dependent variable specified as character.

treat

Treatment vector of variables specified as character vector.

data

Data frame which contains all the relevant variables.

model

Character string specifying the model to estimate. Currently only "lm" (OLS), "logit" (Binary Logit), "probit" (Binary Probit), "ologit" (Ordered Logit) and "oprobit" (Ordered Probit) models are supported. Default is "lm".

covs

Character vector of covariates specified as character vector.

heterogenous

Character vector of covariates to interact with treatments specified as character vector.

subset

character string specifing logical expression for subsetting.

FE

Character vector of fixed effects covariates specified as character vector.

cluster

Covariate for clustered robust standard errors as defined by multiwayvcov::cluster.vcov function. Currently only one clustering variable option supported specified as character vector.

IV_list

Character string. Should be a character string which presents valid IV formula as specified in lfe::felm.

robust

Logical. Whether to report heteroskedastic robust standard errors. Implemented only for linear models for now.

ri

Numeric. If not NULL, gives number of iterations to use for calculation of non-parametric Studentized randomization inference p-values from two-sided test. Only implemented for model = "lm" at the moment.

IPW

Inverse probability weights specified as character vector.

treat_only

Logical vector of length 1, specifying whether only treat estimates should be reported. Defaults to FALSE.

margin_at

Character string which should be in the format of 'var_name = value', defaults to NULL (no marginal effects). This calculates the marginal effects of the treat variable in Logit and Probit models at these particular levels. Takes only binary variables.

status

Logical vector of length 3, specifying whether the model was pre-(R)egistered, run in (S)cript and reported in (P)aper respectively.

stars

Logical. If FALSE no stars are passed to printout.

round_digits

Integer. How many decimal points to round to in the output.

return_df

If TRUE dataframe used for estimation will be returned.

seed

Numeric. RNG seed.

cores

Numeric from 1 to 4. Number of cores used for parallel processing.

Value

List of three objects. estimates is estimates from the model and corresponding standard errors. stat is vector of adjusted R squared and number of observations. model_spec is logical vector of characteristics of the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
usefulr::analyses(DV = "mpg",
                  treat = "vs",
                  model = "lm",
                  covs = c("carb", "disp"),
                  heterogenous = "cyl",
                  IPW = "drat",
                  cluster = "gear",
                  subset = "qsec >= 16",
                  FE = "vs",
                  treat_only = FALSE,
                  status = c(T,T,F),
                  data = mtcars,
                  margin_at = NULL)
         
## End(Not run)

gerasy1987/usefulr documentation built on Aug. 31, 2021, 4:25 p.m.