Description Usage Arguments Details Value Examples
View source: R/stability_function.R
Generates a path of estimates of adjacency matrix given the frequencies of each entry in the estimates using subsamples drawn as complementary pairs.
1 |
freq_B |
A square matrix returned from |
B |
An integer, number of pairs of subsamples to be drawn, should be equal to the |
force_acyclic |
A logical, whether return estimated adj matrices that correspond to acyclic graphs only. |
Assuming fitting_func
takes a list of indices and returns an adjacency matrix, each entry in freq_B <- CPSS_fit(n, fitting_func, B)
returns the number of times that entry equals to 1
in the 2*B
estimated adjacency matrices.
CPSS_path(freq_B, B)
returns a path of graph estimates by gradually decreasing the frequency threshold.
The path is a list containing "graph"
(a list of adjacency matrices), "freq"
(a vector of numbers in [0,1], the frequency threshold), and "actual_fdr"
(a vector of numbers in [0,1], the actual FDR controlled), each corresponding to a final estimate. For each estimate, entries in freq_B
that have frequency above 2*B*freq
are set to 1, and 0 otherwise, while actual_fdr
is calculated as in Shah and Samworth (2012).
For example, if freq_B
is [0 84 10; 0 0 71; 0 12 0] and force_acyclic == TRUE
, the function returns a path with graphs [0 1 0; 0 0 0; 0 0 0] (freq
0.84), [0 1 0; 0 0 1; 0 0 0] (freq
0.71), [0 1 0; 0 0 1; 0 1 0] (freq
0.12), [0 1 1; 0 0 1; 0 1 0] (freq
0.10).
Fore more details, see Shah and Samworth (2012) and the documentation on CPSS_fit()
.
Note: The user is expected to call CPSS_fit()
, followed by CPSS_path()
, and then followed by CPSS_control()
.
A list containing "graph"
(a list of adjacency matrices), "freq"
(a vector of numbers in [0,1]), and "actual_fdr"
(a vector of numbers in [0,1]), all of the same length; see Details.
1 2 3 4 5 6 7 8 | m <- 3; n <- 100; B <- 10
adj_mat <- ZiDAG::make_dag(m, mode = "chain")
d <- ZiDAG::gen_zero_dat(seed=1, gen_para="pms", adj_mat=adj_mat, n=n, gen_uniform_degree=1)
fitting_func <- function(indices) return (
ZiDAG::ziGDS(V=d$V[indices,], Y=d$Y[indices,], parametrization="pms", verbose=FALSE,
control=list("max_uniform_degree"=1L, "tol"=1e-8, "print_best_degree"=FALSE)))
freq_B <- ZiDAG::CPSS_fit(nrow(d$V), fitting_func, B=B, parallel=TRUE, num_cores=1)
cpss_path <- CPSS_path(freq_B, B = B)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.