tsci_secondstage {TSCI}R Documentation

Two Stage Curvature Identification with User Provided Hat Matrix

Description

tsci_secondstage implements Two Stage Curvature Identification (Guo and Buehlmann 2022) for a user-provided hat matrix. Through a data-dependent way it tests for the smallest sufficiently large violation space among a pre-specified sequence of nested violation space candidates. Point and uncertainty estimates of the treatment effect for all violation space candidates including the selected violation space will be returned amongst other relevant statistics.

Usage

tsci_secondstage(
  Y,
  D,
  Z,
  W = NULL,
  vio_space,
  create_nested_sequence = TRUE,
  weight,
  A1_ind = NULL,
  sel_method = c("comparison", "conservative"),
  sd_boot = TRUE,
  iv_threshold = 10,
  threshold_boot = TRUE,
  alpha = 0.05,
  intercept = TRUE,
  B = 300
)

Arguments

Y

observations of the outcome variable. Either a numeric vector of length n or a numeric matrix with dimension n by 1. If outcome variable is binary use dummy encoding.

D

observations of the treatment variable. Either a numeric vector of length n or a numeric matrix with dimension n by 1. If treatment variable is binary use dummy encoding.

Z

observations of the instrumental variable(s). Either a vector of length n or a matrix with dimension n by s. If observations are not numeric dummy encoding will be applied.

W

(transformed) observations of baseline covariate(s) used to fit the outcome model. Either a vector of length n or a matrix with dimension n by p_w or NULL (if no covariates should be included). If observations are not numeric dummy encoding will be applied.

vio_space

list with vectors of length n and/or matrices with n rows as elements to specify the violation space candidates. If observations are not numeric dummy encoding will be applied. See Details for more information.

create_nested_sequence

logical. If TRUE, the violation space candidates (in form of matrices) are defined sequentially starting with an empty violation matrix and subsequently adding the next element of vio_space to the current violation matrix. If FALSE, the violation space candidates (in form of matrices) are defined as the empty space and the elements of vio_space. See Details for more information.

weight

the hat matrix of the treatment model.

A1_ind

indices of the observations that wil be used to fit the outcome model. Must be of same length as the number of rows and columns of weight. If NULL, all observations will be used.

sel_method

The selection method used to estimate the treatment effect. Either "comparison" or "conservative". See Details.

sd_boot

logical. if TRUE, it determines the standard error using a bootstrap approach.

iv_threshold

a numeric value specifying the minimum of the threshold of IV strength test.

threshold_boot

logical. if TRUE, it determines the threshold of the IV strength using a bootstrap approach. If FALSE, it does not perform a bootstrap. See Details.

alpha

the significance level. Has to be a numeric value between 0 and 1.

intercept

logical. If TRUE, an intercept is included in the outcome model.

B

number of bootstrap samples. Has to be a positive integer value. Bootstrap methods are used to calculate the iv strength threshold if threshold_boot is TRUE and for the violation space selection.

Details

The treatment and outcome models are assumed to be of the following forms:

D_i = f(Z_i, X_i) + \delta_i

Y_i = \beta \cdot D_i + h(Z_i, X_i) + \phi(X_i) + \epsilon_i

where f(Z_i, X_i) is estimated using a random forest, h(Z_i X_i) is approximated using the hat matrix weight provided by the user and \phi(X_i) is approximated by a linear combination of the columns in W. The errors are allowed to be heteroscedastic. A1 is used to perform violation space selection and to estimate the treatment effect.

The violation space candidates should be in a nested sequence as the violation space selection is performed by comparing the treatment estimate obtained by each violation space candidate with the estimates of all violation space candidates further down the list vio_space that provide enough IV strength. Only if no significant difference was found in all of those comparisons, the violation space candidate will be selected. If sel_method is 'comparison', the treatment effect estimate of this violation space candidate will be returned. If sel_method is 'conservative', the treatment effect estimate of the successive violation space candidate will be returned provided that the IV strength is large enough. The specification of suitable violation space candidates is a crucial step because a poor approximation of g(Z_i, X_i) might not address the bias caused by the violation of the IV assumption sufficiently well. The function create_monomials can be used to create a predefined sequence of violation space candidates consisting of monomials. The function create_interactions can be used to create a predefined sequence of violation space candidates consisting of two-way interactions between the instrumens themselves and between the instruments and the instruments and baseline covariates.

The instrumental variable(s) are considered strong enough for violation space candidate V_q if the estimated IV strength using this violation space candidate is larger than the obtained value of the threshold of the IV strength. The formula of the threshold of the IV strength has the form \min \{\max \{ 2 \cdot \mathrm{Trace} [ \mathrm{M} (V_q) ], \mathrm{iv{\_}threshold} \} + S (V_q), 40 \} if threshold_boot is TRUE, and \min \{\max \{ 2 \cdot \mathrm{Trace} [ \mathrm{M} (V_q) ], \mathrm{iv{\_}threshold} \}, 40 \} if threshold_boot is FALSE. The matrix \mathrm{M} (V_q) depends on the hat matrix obtained from estimating f(Z_i, X_i), the violation space candidate V_q and the variables to include in the outcome model W. S (V_q) is obtained using a bootstrap and aims to adjust for the estimation error of the IV strength. Usually, the value of the threshold of the IV strength obtained using the bootstrap approach is larger. Thus, using threshold_boot equals TRUE leads to a more conservative IV strength test. For more information see subsection 3.3 in Guo and Buehlmann (2022).

See also Carl et al. (2023) for more details.

Value

A list containing the following elements:

Coef_all

a series of point estimates of the treatment effect obtained by the different violation space candidates.

sd_all

standard errors of the estimates of the treatmnet effect obtained by the different violation space candidates.

pval_all

p-values of the treatment effect estimates obtained by the different violation space candidates.

CI_all

confidence intervals for the treatment effect obtained by the different violation space candidates.

Coef_sel

the point estimator of the treatment effect obtained by the selected violation space candidate(s).

sd_sel

the standard error of Coef_sel.

pval_sel

p-value of the treatment effect estimate obtained by the selected violation space candidate(s).

CI_sel

confidence interval for the treatment effect obtained by the selected violation space candidate(s).

iv_str

IV strength using the different violation space candidates.

iv_thol

the threshold for the IV strength using the different violation space candidates.

Qmax

the violation space candidate that was the largest violation space candidate for which the IV strength was considered large enough determined by the IV strength test. If 0, the IV Strength test failed for the first violation space candidate. Otherwise, violation space selection was performed.

q_comp

the violation space candidate that was selected by the comparison method over the multiple data splits.

q_cons

the violation space candidate that was selected by the conservative method over the multiple data splits.

invalidity

shows whether the instrumental variable(s) were considered valid, invalid or too weak to test for violations. The instrumental variables are considered too weak to test for violations if the IV strength is already too weak using the first violation space candidate (besides the empty violation space). Testing for violations is always performed by using the comparison method.

References

See Also

tsci_boosting for TSCI with boosting.

tsci_forest for TSCI with random forest.

tsci_poly for TSCI with polynomial basis expansion.

Examples

### a small example without baseline covariates
if (require("MASS")) {
  # sample size
  n <- 100
  # the IV strength
  a <- 1
  # the violation strength
  tau <- 1
  # true effect
  beta <- 1
  # treatment model
  f <- function(x) {1 + a * (x + x^2)}
  # outcome model
  g <- function(x) {1 + tau * x}

  # generate data
  mu_error <- rep(0, 2)
  Cov_error <- matrix(c(1, 0.5, 0.5, 1), 2, 2)
  Error <- MASS::mvrnorm(n, mu_error, Cov_error)
  # instrumental variable
  Z <- rnorm(n)
  # treatment variable
  D <- f(Z) + Error[, 1]
  # outcome variable
  Y <- beta * D + g(Z) + Error[, 2]

  # Two Stage User Defined
  # get hat matrix of treatment model
  A <- cbind(1, Z, Z^2, Z^3)
  weight <- A %*% chol2inv(chol(t(A) %*% A)) %*% t(A)
  # create violation space candidates
  vio_space <- create_monomials(Z, 2, "monomials_main")
  # perform two stage curvature identification
  output_UD <- tsci_secondstage(Y, D, Z, vio_space = vio_space, weight = weight,
                                B = 100)
  summary(output_UD)
}

[Package TSCI version 3.0.4 Index]