line_confint: Construct a univariate confidence interval via a line search

View source: R/line_confint.R

line_confintR Documentation

Construct a univariate confidence interval via a line search

Description

Search for the smallest/largest value of a particular coefficient where the null hypothesis of the coefficient being equal to that value is not rejected.

Usage

line_confint(
  index,
  endogeneous = TRUE,
  beta_null = NULL,
  stopping_tolerance = NULL,
  width_ratio = 1,
  step_size = NULL,
  step_rate = 0.5,
  cores = 2,
  log_dir = NULL,
  log_name = "line_search.csv",
  remove_intermediate_csvs = FALSE,
  return_setup = FALSE,
  p_val_tol = 1e-06,
  small_change_count_tol = 10,
  alpha = 0.1,
  Y,
  X,
  D,
  Z,
  Phi = linear_projection(D, X, Z),
  tau,
  B = NULL,
  orthogonalize_statistic = FALSE,
  homoskedasticity = FALSE,
  kernel = "Powell",
  residuals = NULL,
  show_progress = TRUE,
  print_test_stat_results = TRUE,
  initial_TimeLimit = NULL,
  initial_globalTimeLimit = Inf,
  save_log = FALSE,
  ...
)

Arguments

index

Index of the coefficient of interest (numeric between 1 and p_D if endogeneous is TRUE; numeric between 1 and p_X if endogeneous is FALSE)

endogeneous

If TRUE (default), index refers to the coefficients on the endogeneous variables; if FALSE, index refers to the coefficients on the exogeneous variables (boolean)

beta_null

Initial value of line search; suggested value is given by iqr_milp; if NULL (default), naive quantile regression point estimate will be used (numeric)

stopping_tolerance

Smallest step size before stopping the line search; if NULL (default), takes on the value of width_ratio times the width of the naive confidence interval (numeric)

width_ratio

Determines the relationship between the size of naive confidence interval and default value of stopping_tolerance;

step_size

Initial step size of line search; if NULL(default), use half the width of the naive confidence interval (numeric)

step_rate

Rate at which we decrease the step size when we cross the border of the confidence interval; defaults to 0.5 (numeric, less than 1) defaults to 1 (numeric)

cores

Number of cores to be used in parallelization process; defaults to 2 (no more than 2 needed)

log_dir

Path of log directory to store parallelized results; if NULL (default), log is not saved (string)

log_name

Name of CSV file (including extension) to store results; defaults to "gridsearch_results.csv" (string)

remove_intermediate_csvs

If TRUE, intermediate csvs created during while loop will be removed after line search is finished; defaults to FALSE

return_setup

If TRUE, return the step size and naive quantile regression summary without carrying out the line search; defaults to FALSE

p_val_tol, small_change_count_tol

If the change in p-value is less than p_val_tol for small_change_count_tol consecutive iterations, we stop the while loop; defaults to 1e-6 and 10

alpha

Alpha level of the test; defaults to 0.1; only used when homoskedasticity is FALSE (numeric between 0 and 1)

Y

Dependent variable (vector of length n)

X

Exogenous variable (including constant vector) (n by p_X matrix)

D

Endogenous variable (n by p_D matrix)

Z

Instrumental variable (n by p_Z matrix)

Phi

Transformation of X and Z to be used in the program; defaults to the linear projection of D on X and Z (matrix with n rows)

tau

Quantile (number between 0 and 1)

B

Matrix that enters numerator of test statistic (n by |J| + |K| matrix); If NULL (default), this matrix is (Phi_J, X_K), where Phi_J and X_K are the columns of Phi and X with indices J and K;

orthogonalize_statistic

If TRUE, \tilde{B} will be used in numerator of test statistic; defaults to FALSE; for advanced users only

homoskedasticity

If TRUE, assume density of error at 0 is constant; defaults to FALSE (boolean)

kernel

Only active if homoskedasticity is FALSE; either "Powell" (default) to use the Powell estimator or "Gaussian" to use a Gaussian kernel; only used when homoskedasticity is FALSE

residuals

Residuals from IQR MILP program; if NULL (default), use residuals from short-iqr regression

show_progress

If TRUE (default), sends progress messages during execution (boolean); also passed to preprocess_iqr_milp

initial_TimeLimit

Time limit (in sec) for each iteration of preprocessing in the computation of initial test-statistic; defaults to heuristic (scalar)

initial_globalTimeLimit

Time limit (in sec) for computation of initial test-statistic; defaults to Inf (scalar)

save_log

If TRUE, save log files from Gurobi programs in log_dir; defaults to FALSE (boolean)

...

Arguments passed to preprocess_iqr_milp

Details

The suggested value of beta_null is given by the output of iqr_milp or preprocess_iqr_milp. For example, if index is 2, endogeneous is TRUE, and the iqr_milp estimates are stored in iqr, then iqr$beta_D[2] should be the value of beta_null.

The time limit for computing the test-statistic at each step of the line search code is twice as long as the time it takes to compute the initial test statistic. If the time limit is too restrictive thereby ending the computation of the test-statistic too early, we skip the step and move a bit forward in the line search code and temporarily increase the time limit for this new step.


omkarakatta/ivqr documentation built on Aug. 20, 2022, 11:04 p.m.