Title: | Efficient Least Squares for Total Causal Effects |
---|---|
Description: | Estimate a total causal effect from observational data under linearity and causal sufficiency. The observational data is supposed to be generated from a linear structural equation model (SEM) with independent and additive noise. The underlying causal DAG associated the SEM is required to be known up to a maximally oriented partially directed graph (MPDAG), which is a general class of graphs consisting of both directed and undirected edges, including CPDAGs (i.e., essential graphs) and DAGs. Such graphs are usually obtained with structure learning algorithms with added background knowledge. The program is able to estimate every identified effect, including single and multiple treatment variables. Moreover, the resulting estimate has the minimal asymptotic covariance (and hence shortest confidence intervals) among all estimators that are based on the sample covariance. |
Authors: | Richard Guo [aut, cre] |
Maintainer: | Richard Guo <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.2 |
Built: | 2024-10-30 04:17:21 UTC |
Source: | https://github.com/richardkwo/eff2 |
Estimate a total causal effect from observational data under linearity and causal sufficiency. The observational data is supposed to be generated from a linear structural equation model (SEM) with independent and additive noise. The underlying causal DAG associated the SEM is required to be known up to a maximally oriented partially directed graph (MPDAG), which is a general class of graphs consisting of both directed and undirected edges, including CPDAGs (i.e., essential graphs) and DAGs. Such graphs are usually obtained with structure learning algorithms with added background knowledge. The program is able to estimate every identified effect, including single and multiple treatment variables. Moreover, the resulting estimate has the minimal asymptotic covariance (and hence shortest confidence intervals) among all estimators that are based on the sample covariance.
Use estimateEffect
to estimate a total effect.
Use isIdentified
to determine if a total effect can be
identified.
Maintainer: Richard Guo [email protected] (ORCID)
Useful links:
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)
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)
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)
An example of 10 variables simulated from a linear SEM
ex1
ex1
A list containing:
treatment variables
outcome variable
the true total effect of x on y
the coefficient matrix of the SEM
the adjacency matrix of the causal DAG
the adjacency matrix of the CPDAG of the causal DAG, representing the Markov equivalence class of the DAG.
500 iid samples generated under student-t errors
The total causal effect from x to y is identified if and only if there is no possibly causal path from x to y that starts with an undirected edge.
isIdentified(amat, x, y, type = "pdag")
isIdentified(amat, x, y, type = "pdag")
amat |
adjacency matrix. See |
x |
(integer) positions of treatment variables in the adjacency matrix |
y |
(integer) positions of outcome variables in the adjacency matrix |
type |
string specifying the type of graph of |
TRUE
if identified, FALSE
if not.
Emilija Perkovic. Identifying causal effects in maximally oriented partially directed acyclic graphs. In Uncertainty in Artificial Intelligence (UAI), 2020.
data("ex1") # identified isIdentified(ex1$amat.cpdag, c(3, 5), 7) # not identified isIdentified(ex1$amat.cpdag, 3, 7) isIdentified(ex1$amat.cpdag, c(3, 5), 10)
data("ex1") # identified isIdentified(ex1$amat.cpdag, c(3, 5), 7) # not identified isIdentified(ex1$amat.cpdag, 3, 7) isIdentified(ex1$amat.cpdag, c(3, 5), 10)