CPSS_path: Generates a path of estimates of adjacency matrix using...

Description Usage Arguments Details Value Examples

View source: R/stability_function.R

Description

Generates a path of estimates of adjacency matrix given the frequencies of each entry in the estimates using subsamples drawn as complementary pairs.

Usage

1
CPSS_path(freq_B, B = 50, force_acyclic = TRUE)

Arguments

freq_B

A square matrix returned from CPSS_fit(), the frequency of each entry inn the adjacency matrix in the estimates using the 2*B sets of subsamples.

B

An integer, number of pairs of subsamples to be drawn, should be equal to the B used when calling CPSS_fit(). Defaults to 50.

force_acyclic

A logical, whether return estimated adj matrices that correspond to acyclic graphs only.

Details

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().

Value

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.

Examples

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)

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