estimateEffect: Estimate the total causal effect

Description Usage Arguments Details Value See Also Examples

View source: R/bucket.R

Description

Estimate the total causal effect of x on y with iterated least squares. The resulting estimate has the minimal asymptotic covariance among all least squares estimators.

Usage

1
estimateEffect(data, x, y, amat, bootstrap = FALSE)

Arguments

data

a data frame consisting of iid observational data

x

(integer) positions of treatment variables in the adjacency matrix; can be a singleton (single treatment) or a vector (multiple treatments)

y

(integer) position of the outcome variable in the adjacency matrix

amat

adjacency matrix representing a DAG, CPDAG or MPDAG

bootstrap

If TRUE, will estimate the standard error covariance with bootstrap (default: FALSE)

Details

Adjacency matrix amat represents the graphical information of the underlying causal DAG (directed acyclic graph). The causal DAG should be contained by the graph represented by amat, which can be a DAG, CPDAG (essential graph), or more generally, an MPDAG (maximally oriented partially directed acyclic graph).

Matrix amat is coded with the convention of amatType:

amat can be learned from observational data with a structure learning algorithm; see pc, ges and LINGAM. Additional background knowledge can also be incorporated with addBgKnowledge.

Value

A vector of the same length as x. If bootstrap=TRUE, return a list of (effect, se.cov).

See Also

isIdentified is called for determining if an effect can be identified. See also adjustment, ida, and jointIda for other estimators.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data("ex1")
result <- estimateEffect(ex1$data, c(5,3), 7, ex1$amat.cpdag, bootstrap=TRUE)
print(result$effect)
print(result$effect - 1.96 * sqrt(diag(result$se.cov)))
print(result$effect + 1.96 * sqrt(diag(result$se.cov)))
# compare with truth
print(ex1$true.effects)

## Not run: 
# throws an error because the effect is not identified
estimateEffect(ex1$data, 3, 7, ex1$amat.cpdag)

## End(Not run)

eff2 documentation built on Oct. 1, 2021, 1:07 a.m.