Description Usage Arguments Examples
View source: R/simulate_hierarchically_sparse_data.R
function to estimate the hierarchical sparsity parameter for a desired level of sparsity for simulated hierarchical coefficients
1 2 3 4 5 6 7 8 | estimate.hier.sparsity.param(
ncats,
nvars,
avg.hier.zeros = 0.3,
nsims = 150,
effect.size.max = 0.5,
misspecification.prop = 0
)
|
ncats |
number of categories to stratify on |
nvars |
number of variables |
avg.hier.zeros |
desired percent of zero variables among the variables with hierarchical zero patterns. |
nsims |
number of simulations to estimate the average sparsity. A larger number will be more accurate but take much longer. |
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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | set.seed(123)
# estimate hier.sparsity.param for 0.15 total proportion of nonzero variables
# among vars with hierarchical zero patterns
## Not run:
hsp <- estimate.hier.sparsity.param(ncats = 3, nvars = 25, avg.hier.zeros = 0.15, nsims = 100)
## End(Not run)
# 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)
## Not run:
hsp2 <- estimate.hier.sparsity.param(ncats = 2, nvars = 100,
avg.hier.zeros = 0.30, nsims = 50) # 0.5778425
hsp3 <- estimate.hier.sparsity.param(ncats = 3, nvars = 100,
avg.hier.zeros = 0.30, nsims = 50) # 0.4336312
hsp4 <- estimate.hier.sparsity.param(ncats = 4, nvars = 100,
avg.hier.zeros = 0.30, nsims = 50) # 0.2670061
hsp5 <- estimate.hier.sparsity.param(ncats = 5, nvars = 100,
avg.hier.zeros = 0.30, nsims = 50) # 0.146682
## End(Not run)
# 0.07551241 for hsp6
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.