Skip to contents

Compares GMM estimates with traditional 2SLS (Lewbel) estimates for the triangular system.

Usage

compare_gmm_2sls(
  data,
  y1_var = "Y1",
  y2_var = "Y2",
  x_vars = "Xk",
  add_intercept = TRUE,
  true_gamma1 = NA_real_,
  gmm_args = list(),
  tsls_sim_config = list(),
  verbose = TRUE
)

Arguments

data

Data frame containing all required variables. Must include the dependent variables and any exogenous regressors specified in the model.

y1_var

Character. Name of the first dependent variable (default: "Y1").

y2_var

Character. Name of the second dependent variable/endogenous regressor (default: "Y2").

x_vars

Character vector. Names of exogenous variables (default: "Xk"). For 2SLS via run_single_lewbel_simulation, it assumes a single "Xk" if default simulation parameters are used. For GMM, can be multiple. This function will try to match behavior. If multiple x_vars are given, the 2SLS part might be less comparable if its underlying data generating process assumes one X.

add_intercept

Logical. Whether to add an intercept for GMM (default: TRUE). 2SLS via run_single_lewbel_simulation typically includes an intercept.

true_gamma1

Numeric. Optional true value of gamma1 for bias calculation.

gmm_args

List. Additional arguments passed to lewbel_gmm.

tsls_sim_config

List. Parameters to override in the default config for run_single_lewbel_simulation. The sample_size will be set to nrow(data). lewbel_x_vars in this config should match x_vars here.

verbose

Logical. Whether to print progress messages (default: TRUE).

Value

A data frame comparing estimates, standard errors, and test statistics.

See also

lewbel_gmm for GMM estimation. run_single_lewbel_simulation for 2SLS estimation.

Examples

if (FALSE) { # \dontrun{
# Generate data
params_dgp <- list(
  beta1_0 = 0.5, beta1_1 = 1.5, gamma1 = -0.8,
  beta2_0 = 1.0, beta2_1 = -1.0,
  alpha1 = -0.5, alpha2 = 1.0, delta_het = 1.2
)
data_comp <- generate_lewbel_data(1000, params_dgp) # Generates Y1, Y2, Xk, Z

# Compare (assuming Xk is the exogenous variable for both)
comparison <- compare_gmm_2sls(data_comp, true_gamma1 = params_dgp$gamma1)
print(comparison)

# Example with multiple X for GMM, 2SLS might be less direct comparison
params_multi <- list(
  beta1_0 = 0.5, beta1_1 = c(1.5, 0.2), gamma1 = -0.8,
  beta2_0 = 1.0, beta2_1 = c(-1.0, 0.3),
  alpha1 = -0.5, alpha2 = 1.0, delta_het = 1.2
)
data_multi_x <- generate_lewbel_data(1000, params_multi, n_x = 2) # Y1,Y2,X1,X2,Z1,Z2
comparison_multi <- compare_gmm_2sls(data_multi_x,
  x_vars = c("X1", "X2"),
  true_gamma1 = params_multi$gamma1,
  tsls_sim_config = list(
    lewbel_x_vars = c("X1", "X2") # Hypothetical
    # Note: run_single_lewbel_simulation's internal
    # Data generating process might not easily map to this if it assumes 1 Xk.
    # This part is more illustrative for GMM side.
  )
)
print(comparison_multi)
} # }