Description Usage Arguments Details Value Examples
View source: R/stability_function.R
Applies a fit function repeatedly to subsamples drawn as complementary pairs (CPSS).
1 |
n |
An integer >= 2, the sample size. |
fitting_func |
A function that takes a vector of indices (a subvector of |
B |
An integer, number of pairs of subsamples to be drawn. Defaults to |
parallel |
A logical that indicates whether |
num_cores |
An integer, number of cores to be used if |
A complementary pair of sub-indices of 1:n
is a pair of disjoint subvectors 1:n
each with length floor(n/2)
.
The function draws B
such pairs, and apply fitting_func()
to each of these 2*B
lists of sub-indices.
Finally, the sum of the 2*B
returned values/vectors/matrices from fitting_func()
are returned.
Assuming fitting_func
takes a list of indices and returns an adjacency matrix, each entry in CPSS_fit(n, fitting_func, B)
returns the number of times that entry equals to 1
in the 2*B
estimated adjacency matrices.
Note: The user is expected to call CPSS_fit()
, followed by CPSS_path()
, and then followed by CPSS_control()
.
The sum of results from fitting_func()
applied to 2*B
lists of sub-indices of 1:n
.
1 2 3 4 5 6 7 | m <- 3; n <- 200; B <- 5
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.