ziGDS: Greedy DAG search for DAGs for zero-inflated data based on...

Description Usage Arguments Details Value Examples

View source: R/zero_est_graph.R

Description

Greedy DAG search for DAGs for zero-inflated data based on Hurdle conditionals.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
ziGDS(
  V,
  Y,
  parametrization,
  fixedGaps = NULL,
  maxDegree = Inf,
  maxInDegree = Inf,
  init = NULL,
  verbose = FALSE,
  no_check_DAG = FALSE,
  return_BIC = FALSE,
  cache_scores = TRUE,
  control = list()
)

Arguments

V

A matrix of 0/1s, equal to Y != 0.

Y

A data matrix of the same size as V.

parametrization

A string, either "abk" (canonical) or "pms" (moment).

fixedGaps

A logical square matrix of number of rows/columns equal to number of columns of Y. Similar to pcalg::gds(), if its [i,j] is TRUE, the result is guaranteed to have no edge between nodes i and j.

maxDegree

A positive integer, the maximum degree of a node.

maxInDegree

A positive integer, the maximum in-degree of a node.

init

An list of adjacency matrices or a single adjacency matrix, each of number of rows/columns equal to number of columns of Y, used as the initial graph. Defaults to NULL representing the empty graph. If a list is provided, each matrix will be used to initialize the algorithm once and the result with the lowest BIC will be returned.

verbose

A logical, whether to print intermediate steps.

no_check_DAG

A logical. If FALSE, check on whether the resulting graph is acyclic will not be performed in the forward and edge reversing stages.

return_BIC

A logical. If TRUE, returns the estimated matrix along with the minimized BIC.

cache_scores

A logical. If TRUE, nodewise BIC scores will be cached to speed up estimation, at the cost of a memory overhead.

control

A list passed to zi_fit(). Please consult ?zi_fit.

Details

Performs greedy DAG search for DAGs for zero-inflated data based on Hurdle conditionals. See Chickering (2003) or ?pcalg::gds for details. However, unlike the Gaussian case in their implementation that returns an equivalence class of DAGs, the DAG estimated by this function is exact.

Value

If return_BIC is FALSE, returns an adjacency matrix; otherwise returns a list with "graph" element being the estimated matrix and "BIC" being the estimated BIC.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
m <- 4; n <- 1000
adj_mat <- ZiDAG::make_dag(m, mode = "chain", shuffle=FALSE)
d <- ZiDAG::gen_zero_dat(seed=1, gen_para="pms", adj_mat=adj_mat, n=n, gen_uniform_degree=1)
est <- ZiDAG::ziGDS(V=d$V, Y=d$Y, parametrization="pms", verbose=FALSE,
    control=list("max_uniform_degree"=1L, "tol"=1e-8, "print_best_degree"=FALSE))
adj_mat == est

d <- ZiDAG::gen_zero_dat(seed=1, gen_para="abk", adj_mat=adj_mat, n=n, gen_uniform_degree=1)
est <- ZiDAG::ziGDS(V=d$V, Y=d$Y, parametrization="abk", verbose=FALSE,
    control=list(use_C=TRUE, maxit=1000, runs=2, report=0))
adj_mat == est

est <- ZiDAG::ziGDS(V=d$V, Y=d$Y, parametrization="pms", verbose=FALSE,
    control=list("max_uniform_degree"=1L, "tol"=1e-8, "print_best_degree"=FALSE))
adj_mat == est

est <- ZiDAG::ziGDS(V=d$V, Y=d$Y, parametrization="pms", verbose=FALSE,
    control=list("max_uniform_degree"=2L, "tol"=1e-8, "print_best_degree"=FALSE))
adj_mat == est

sqyu/ZiDAG documentation built on Jan. 19, 2021, 4:11 p.m.