| estimateEffect {eff2} | R Documentation |
Estimate the total causal effect
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
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 |
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[i,j]=0andamat[j,i]=1meansi->j -
amat[i,j]=1andamat[j,i]=0meansi<-j -
amat[i,j]=1andamat[j,i]=1meansi--j -
amat[i,j]=0andamat[j,i]=0meansi j
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
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)