Package 'sisVIVE'

Title: Some Invalid Some Valid Instrumental Variables Estimator
Description: Selects invalid instruments amongst a candidate of potentially bad instruments. The algorithm selects potentially invalid instruments and provides an estimate of the causal effect between exposure and outcome.
Authors: Hyunseung Kang <[email protected]>
Maintainer: Hyunseung Kang <[email protected]>
License: GPL-2
Version: 1.4
Built: 2024-11-16 09:15:30 UTC
Source: https://github.com/cran/sisVIVE

Help Index


Computes K-fold cross validation for selecting lambda

Description

Computes a K-fold cross validation for

Usage

cv.sisVIVE(Y, D, Z, lambdaSeq, K = 10, intercept = TRUE, normalize = TRUE)

Arguments

Y

A numeric vector of outcomes

D

A numeric vector of exposures

Z

A numeric matrix of instruments, with each column referring to one instrument

lambdaSeq

A numeric vector of lambdas to cross-validate from. Cross-validation will be performed only on these sequence of lambdas. You can either supply lambdaSeq or nLambda. See Details

K

Number of cross-validation folds

intercept

A logical declaring whether the intercept be included. Default is TRUE

normalize

A logical declaring whether the columns of Z should be scaled with variance 1. Default is TRUE

Details

Performs K-fold cross validiation to select lambda and returns the "best" lambda based on this cross-validation. If lambdaSeq is unspecified, the algorithm defaults to using the sequence of lambdas selected by sisVIVE. If lambdaSeq is specified, the algorithm will only evaluate its cross-validation on the specified lambdaSeq.

Value

A list is returned, which contains the estimates of alpha, beta, and the set of invalid instruments for the "best" lambda chosen by cross validation

lambda

"best" lambda as chosen by cross validation

estCVError

Estimated cross-validated error at this lambda

alpha

Estimate of alpha at the said lambda

beta

Estimate of beta, the causal effect of exposure on outcome, at the said lambda

whichInvalid

Estimate of set of invalid instruments at the said lambda

Author(s)

Hyunseung Kang

Examples

library(MASS)
library(lars)

n = 1000; L = 10; s= 3;
Z <- matrix(rnorm(n*L),n,L)
error <- mvrnorm(n,rep(0,2),matrix(c(1,0.8,0.8,1),2,2))
intD = rnorm(1); ZtoD =   rnorm(L,0,1); ZtoY = c(rnorm(s),rep(0,L-s)); DtoY = 1; intY = rnorm(1)
D = intD + Z %*% ZtoD + error[,1]
Y = intY + Z %*% ZtoY + D * DtoY + error[,2]

result = cv.sisVIVE(Y,D,Z,K=10)

Estimates set of invalid instruments or the causal effect of exposure on outcome from a sisVIVE object

Description

predict.sisVIVE can estimate a set of invalid instruments or the causal effect of exposure on outcome for any particular lambda(s)

Usage

## S3 method for class 'sisVIVE'
predict(object, lambda, type = c("coefficients", "instruments"), ...)

Arguments

object

A fitted sisVIVE object

lambda

A numerical vector of lambda(s) to obtain estimates. The length of this vector can be one.

type

If type="coefficients", predict returns estimated alpha and betas (i.e. the causal effect of exposure on outcome) for supplied lambda(s). If type = "instruments", predict returns estimated set of invalid instruments for supplied lambda(s)

...

Any other argument for predict.lars

Details

predict() estimates the alphas and betas for given sequence of lambda(s) or set of invalid instrument.

Value

lambda

Sequence of lambda(s) supplied by the user

alpha

If type="coefficients", alpha is the estimated direct effect of the instruments on the outcome. Each row refers to an estimated alpha for one lambda value and each column refers to the corresponding column in Z

beta

If type="coefficients", beta is the estimated causal effect of exposure on outcome. Each entry refers to an estimated beta for one lambda value

instruments

If type="instruments",provides a character vector of invalid instruments. Each entry refers to column indices of Z that are estimated to be invalid.

Author(s)

Hyunseung Kang

See Also

summary, and cv.sisVIVE

Examples

library(MASS)
library(lars)

n = 1000; L = 10; s= 3;
Z <- matrix(rnorm(n*L),n,L)
error <- mvrnorm(n,rep(0,2),matrix(c(1,0.8,0.8,1),2,2))
intD = rnorm(1); ZtoD =   rnorm(L,0,1); ZtoY = c(rnorm(s),rep(0,L-s)); DtoY = 1; intY = rnorm(1)
D = intD + Z %*% ZtoD + error[,1]
Y = intY + Z %*% ZtoY + D * DtoY + error[,2]

result = sisVIVE(Y,D,Z)
estCoef1 = predict(result,lambda = 10,type="coefficients")
estCoef2 = predict(result,lambda = seq(1,100,10),type="coefficients")
estInst1 = predict(result,lambda = 10,type="instruments")
estInst2 = predict(result,lambda = seq(1,100,10),type="instruments")

Some Invalid Some Valid Instrumental Variables Estimator

Description

Selects invalid instruments from a candidate of instruments and estimates the causal effect of exposure on outcome

Usage

sisVIVE(Y, D, Z, intercept = TRUE, normalize = TRUE)

Arguments

Y

A numeric vector of outcomes

D

A numeric vector of exposures

Z

A numeric matrix of instruments, with each column referring to one instrument

intercept

A logical declaring whether the intercept be included. Default is TRUE

normalize

A logical declaring whether the columns of Z should be scaled with variance 1. Default is TRUE

Details

Given a candidate of instruments, the algorithm selects invalid instruments and estimates the causal effect of exposure on outcome by leveraging LARS. The entire solution path, which includes the estimate of the causal effect as well as the estimated set of invalid instruments, is computed for lambda.

Value

A "sisVIVE" object is returned, for which print, plot, summary, and predict methods exist.

alpha

Estimates of alpha, the causal effect of the instrument on the outcome. Each row represents a lambda value and each column corresponds to the estimate of alpha corresponding to that same column in Z

beta

Estimate of beta, the causal effect of the exposure on the outcome. Each entry represents an estimate of beta for a lambda value

whichInvalid

Estimate of which instruments are invalid. Each entry refers to the column indexes of the Z matrix which were deemed to be invalid for a lambda value

lambda

Lambda used in the algorithm

larsObject

A LARS object

Y

A numeric vector of outcomes

D

A numeric vector of exposures

Z

A numeric matrix of instruments, with each column referring to one instrument

Dhat

A numeric vector of predicted exposure given instruments

Author(s)

Hyunseung Kang. We thank Frank Windmeijer for his suggestion to improve the code.

References

For LARS: Efron, Hastie, Johnstone and Tibshirani (2003) "Least Angle Regression" (with discussion) Annals of Statistics

See Also

summary and predict methods for sisVIVE, and cv.sisVIVE which performs cross-validation to choose the tuning parameter

Examples

library(MASS)
library(lars)

n = 1000; L = 10; s= 3;
Z <- matrix(rnorm(n*L),n,L)
error <- mvrnorm(n,rep(0,2),matrix(c(1,0.8,0.8,1),2,2))
intD = rnorm(1); ZtoD =   rnorm(L,0,1); ZtoY = c(rnorm(s),rep(0,L-s)); DtoY = 1; intY = rnorm(1)
D = intD + Z %*% ZtoD + error[,1]
Y = intY + Z %*% ZtoY + D * DtoY + error[,2]

result = sisVIVE(Y,D,Z)
summary(result)

A summary of the sisVIVE object

Description

Produces a summary of the sisVIVE object, including the estimates of the causal effect of exposure on outcome and the estimated set of invalid instruments for sequence of lambdas

Usage

## S3 method for class 'sisVIVE'
summary(object,...)

Arguments

object

a sisVIVE object

...

additional arguments for summary generic

Details

Each row summarizes an estimated causal effect of exposure on outcome and the estimated set of invalid instruments for one lambda

Value

Each row summarizes an estimated causal effect of exposure on outcome and the estimated set of invalid instruments for one lambda. For the estimated set of invalid instruments, each number is a column index number for Z that is estimated to be invalid.

Author(s)

Hyunseung Kang

See Also

predict and cv.sisVIVE

Examples

library(MASS)
library(lars)

n = 1000; L = 10; s= 3;
Z <- matrix(rnorm(n*L),n,L)
error <- mvrnorm(n,rep(0,2),matrix(c(1,0.8,0.8,1),2,2))
intD = rnorm(1); ZtoD =   rnorm(L,0,1); ZtoY = c(rnorm(s),rep(0,L-s)); DtoY = 1; intY = rnorm(1)
D = intD + Z %*% ZtoD + error[,1]
Y = intY + Z %*% ZtoY + D * DtoY + error[,2]

result = sisVIVE(Y,D,Z)
summary(result)