Description Usage Arguments Value Author(s) References See Also Examples
Estimates the connectivity matrix of a directed causal graph, using various possible methods. Supported methods at the moment are ARGES, backShift, bivariateANM, bivariateCAM, CAM, FCI, FCI+, GES, GIES, hiddenICP, ICP, LINGAM, MMHC, rankARGES, rankFci, rankGES, rankGIES, rankPC, regression, RFCI and PC.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | getParents(
X,
environment = NULL,
interventions = NULL,
parentsOf = 1:ncol(X),
method = c("arges", "backShift", "bivariateANM", "bivariateCAM", "CAM", "fci",
"fciplus", "ges", "gies", "hiddenICP", "ICP", "LINGAM", "mmhc", "rankArges",
"rankFci", "rankGes", "rankGies", "rankPc", "rfci", "pc", "regression")[12],
alpha = 0.1,
mode = c("raw", "parental", "ancestral")[1],
variableSelMat = NULL,
excludeTargetInterventions = TRUE,
onlyObservationalData = FALSE,
indexObservationalData = 1,
returnAsList = FALSE,
sparse = FALSE,
directed = FALSE,
pointConf = FALSE,
setOptions = list(),
assumeNoSelectionVars = TRUE,
verbose = FALSE,
...
)
|
X |
A (n x p)-data matrix with n observations of p variables. |
environment |
An optional vector of length n, where the entry for
observation i is an index for the environment in which observation i took
place (Simplest case: entries |
interventions |
A optional list of length n. The entry for observation
i is a numeric vector that specifies the variables on which interventions
happened for observation i (a scalar if an intervention happened on just
one variable and |
parentsOf |
The variables for which we would like to estimate the
parents. Default are all variables. Currently only used with |
method |
A string that specfies the method to use. The methods
|
alpha |
The level at which tests are done. This leads to confidence
intervals for |
mode |
Determines output type - can be "raw" or one of the queries "isParent",
"isMaybeParent", "isNoParent", "isAncestor","isMaybeAncestor", "isNoAncestor".
If "raw", |
variableSelMat |
An optional logical matrix of dimension (p x p). An
entry |
excludeTargetInterventions |
When looking for parents of variable k
in 1,...,p, set to |
onlyObservationalData |
If set to |
indexObservationalData |
Index in |
returnAsList |
If set to |
sparse |
If set to |
directed |
If |
pointConf |
If |
setOptions |
A list that can take method-specific options; see the individual documentations of the methods for more options and their possible values. |
assumeNoSelectionVars |
Set to |
verbose |
If |
... |
Parameters to be passed to underlying method's function. |
If option returnAsList
is FALSE
, a sparse matrix,
where a 0 entry in position (j,k) corresponds to an estimate of "no edge"
j
-> k
, while an entry 1 corresponds to an
estimated egde. If option pointConf
is TRUE
, the 1 entries
will be replaced by numerical values that are either point estimates of the
causal coefficients or confidence bounds (see above).
If option returnAsList
is TRUE
, a list will be returned.
The k-th entry in the list is the numeric vector with the indices of the
estimated parents of node k
.
Christina Heinze-Deml heinzedeml@stat.math.ethz.ch, Nicolai Meinshausen meinshausen@stat.math.ethz.ch
Naftali Harris and Mathias Drton: PC Algorithm for Nonparanormal Graphical Models. J. Mach. Learn. Res. 14(1) 2013.
getParentsStable
for stability selection-based
estimation of the causal graph.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | ## load the backShift package for data generation and plotting functionality
if(require(backShift) & require(pcalg)){
# Simulate data with connectivity matrix A with assumptions
# 1) hidden variables present
# 2) precise location of interventions is assumed unknown
# 3) different environments can be distinguished
## simulate data
myseed <- 1
# sample size n
n <- 10000
# p=3 predictor variables and connectivity matrix A
p <- 3
labels <- c("1", "2", "3")
A <- diag(p)*0
A[1,2] <- 0.8
A[2,3] <- 0.8
A[3,1] <- -0.4
# divide data in 10 different environments
G <- 10
# simulate
simResult <- backShift::simulateInterventions(n, p, A, G, intervMultiplier = 3,
noiseMult = 1, nonGauss = TRUE, hiddenVars = TRUE,
knownInterventions = FALSE, fracVarInt = NULL, simulateObs = TRUE,
seed = myseed)
X <- simResult$X
environment <- simResult$environment
## apply all methods given in vector 'methods'
## (using all data pooled for pc/LINGAM/rfci/ges -- can be changed with option
## 'onlyObservationalData=TRUE')
methods <- c("backShift", "LINGAM") #c("pc", "rfci", "ges")
# select whether you want to run stability selection
stability <- FALSE
# arrange graphical output into a rectangular grid
sq <- ceiling(sqrt(length(methods)+1))
par(mfrow=c(ceiling((length(methods)+1)/sq),sq))
## plot and print true graph
cat("\n true graph is ------ \n" )
print(A)
plotGraphEdgeAttr(A, plotStabSelec = FALSE, labels = labels, thres.point = 0,
main = "TRUE GRAPH")
## loop over all methods and compute and print/plot estimate
for (method in methods){
cat("\n result for method", method," ------ \n" )
if(!stability){
# Option 1): use this estimator as a point estimate
Ahat <- getParents(X, environment, method=method, alpha=0.1, pointConf = TRUE)
}else{
# Option 2): use a stability selection based estimator
# with expected number of false positives bounded by EV=2
Ahat <- getParentsStable(X, environment, EV=2, method=method, alpha=0.1)
}
# print and plot estimate (point estimate thresholded if numerical estimates
# are returned)
print(Ahat)
if(!stability)
plotGraphEdgeAttr(Ahat, plotStabSelec = FALSE, labels = labels,
thres.point = 0.05,
main=paste("POINT ESTIMATE FOR METHOD\n", toupper(method)))
else
plotGraphEdgeAttr(Ahat, plotStabSelec = TRUE, labels = labels,
thres.point = 0, main = paste("STABILITY SELECTION
ESTIMATE\n FOR METHOD", toupper(method)))
}
}else{
cat("\nThe packages 'backShift' and 'pcalg' are needed for the examples to
work. Please install them.")
}
|
Loading required package: backShift
Attaching package: 'backShift'
The following object is masked from 'package:CompareCausalNetworks':
simulateInterventions
Loading required package: pcalg
true graph is ------
[,1] [,2] [,3]
[1,] 0.0 0.8 0.0
[2,] 0.0 0.0 0.8
[3,] -0.4 0.0 0.0
result for method backShift ------
1 2 3
1 0.0000000 0.802217975 -0.05583784
2 0.0047767 0.000000000 0.78766266
3 -0.4062989 -0.006501869 0.00000000
result for method LINGAM ------
1 2 3
1 0 0 -1.942239
2 0 0 0.000000
3 0 0 0.000000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.