cv_CIV: cross-validated CIV.

Description Usage Arguments Value Examples

View source: R/CIVMR_function.R

Description

This function produce a Constrained Instrumental Variable with cross-validation. Specifically, for a predefined fold the CIV is calculated using all samples except this fold, then the CIV solution is applied to the samples in this fold to obtain corresponding CIV. In this way the correlation between samples are expected to be reduced.

Usage

1
cv_CIV(MR.data, n_folds = 10)

Arguments

MR.data:

a data frame containing G,X,Z,Y.

n_folds:

number of folds for cross-validation.

Value

weights: A matrix with dimension n_folds * p. Each row is a CIV solution c from a specific fold.

civ.IV: cross-validated CIV instrument G^{*}=Gc.

beta_est: causal effect estimation of X on Y using CIV instrument civ.IV

Examples

1
2
3
4
data(simulation)
cv.civ <- cv_CIV(simulation)
#strong correlation between CIV solutions from different folds.
cor(t(cv.civ$weights))

LaiJiang/CIVMR documentation built on July 16, 2020, 12:45 a.m.