| estimateEffect | R Documentation |
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.
estimateEffect(data, x, y, amat, bootstrap = FALSE)
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 |
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]=0 and amat[j,i]=1 means i->j
amat[i,j]=1 and amat[j,i]=0 means i<-j
amat[i,j]=1 and amat[j,i]=1 means i--j
amat[i,j]=0 and amat[j,i]=0 means i 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.
A vector of the same length as x. If bootstrap=TRUE,
return a list of (effect, se.cov).
isIdentified is called for determining if an effect can be
identified. See also adjustment, ida,
and jointIda for other estimators.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.