Description Usage Arguments Examples
View source: R/simulate_hierarchically_sparse_data.R
function to generate coefficient matrix with hierarchical sparsity
1 2 3 4 5 6 7 8 | genHierSparseBeta(
ncats,
nvars,
hier.sparsity.param = 0.5,
avg.hier.zeros = NULL,
effect.size.max = 0.5,
misspecification.prop = 0
)
|
ncats |
number of categories to stratify on |
nvars |
number of variables |
hier.sparsity.param |
parameter between 0 and 1 which determines how much hierarchical sparsity there is. To achieve a desired total level of sparsity among the variables with hierarchical sparsity, this parameter can be estimated using the function 'estimate.hier.sparsity.param' |
avg.hier.zeros |
desired percent of zero variables among the variables with hierarchical zero patterns. If this is specified, it will override the given hier.sparsity.param value and estimate it. This takes a while |
effect.size.max |
maximum magnitude of the true effect sizes |
misspecification.prop |
proportion of variables with hierarchical missingness misspecified |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | set.seed(123)
# estimate hier.sparsity.param for 0.15 total proportion of nonzero variables
# among vars with hierarchical zero patterns
# NOT RUN: Takes a long time
# hsp <- estimate.hier.sparsity.param(ncats = 3, nvars = 25, avg.hier.zeros = 0.15, nsims = 100)
# the above results in the following value
hsp <- 0.6341772
# check that this does indeed achieve the desired level of sparsity
mean(replicate(100, mean(genHierSparseBeta(ncats = 3,
nvars = 25, hier.sparsity.param = hsp) != 0) ))
sparseBeta <- genHierSparseBeta(ncats = 3, nvars = 25, hier.sparsity.param = hsp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.