This package is intended to provide the data used to produce the figures in my MSc thesis, and generic functions which can be used to generate similar figures, produced with possibly different parameters.
In order to reproduce the figures of the different two-stage methods’ characteristics appearing in the thesis (their FWER and their number of true rejections), the following code should be used:
library(twostageshrink)
#>
#> Attaching package: 'twostageshrink'
#> The following object is masked from 'package:stats':
#>
#> simulate
# Prints the plot comparing the true rejections number of
# the different methods, under the 1st configuration:
reproduce(1, "trej")
# Prints the plot comparing the FWER of
# the different methods, under the 2nd configuration:
reproduce(2, "fwer")
# Prints the plot of the different MSE-ratio for
# different cases, under the 1st configuration:
shrink_reproduce(1)
The above lines demonstrate the main usage of this package. The
reproduce()
function uses the data in the data/
directory, which is
generated with scripts that can be found in the data-raw/
directory.
However, if you wish to produce variants of these figures with changes
in parameters, you can use it similarly to the scripts. The function
that might help you are simulate()
, perform()
, evaluate()
and
measure()
, in this order. For the shrinkage figures, the relevant
functions to generate data and manipulate it similarly to the shown in
the thesis are shrink_simulate()
, shrink_estimate()
,
shrink_evaluate()
and shrink_reproduce()
, in this order.
Usage example for user-defined parameters for the two-stage figures:
simulate(
nobs = seq(from = 10, to = 50, by = 10),
nexper = 30,
nhyp = 30,
config = tibble::tribble(
~altr, ~gaddend, ~gfactor, ~gexp, ~baddend, ~bfactor, ~bexp, ~prop,
FALSE, 0, 0, 0, 0, 0, 0, 0.5,
FALSE, 0, 3, 3/4, 0, 0, 0, 0.0,
FALSE, 0, 3, 1/2, 0, 0, 0, 0.4,
FALSE, 0, 3, 1/3, 0, 0, 0, 0.0,
FALSE, 1, 3, 1/2, 0, 0, 0, 0.0,
TRUE, 0, 3, 1/2, 0, 3, 1/2, 0.1,
TRUE, 0, 3, 1/3, 0, 3, 1/2, 0.0,
TRUE, 1, 3, 1/2, 0, 3, 1/2, 0.0
)
) %>%
perform(
filt_test = pmin(gpval, bpval) < 0.001,
base_pval = pmax(gpval, bpval),
base_thrl = 0.1,
base_thrl_adj_method = function(thrl) { thrl / sum(!is.na(thrl)) },
nobs, exper
) %>%
evaluate(nobs, exper) %>%
measure(nobs)
#> # A tibble: 5 x 2
#> nobs fwer
#> <dbl> <dbl>
#> 1 10 0.0333
#> 2 20 0.0333
#> 3 30 0.0667
#> 4 40 0.1
#> 5 50 0.0333
Usage example for user-defined parameters for the MSE-ratio figures:
shrink_simulate(
nobs = seq(from = 10, to = 50, by = 10),
nrep = 30,
config = tibble::tribble(
~gexp, ~gfactor, ~bexp, ~bfactor,
0.5, 1, 0.6, 1,
0.5, 1, 0.5, 1,
0.5, 2, 0.5, sqrt(5/3),
0.5, 2, 0.5, 2,
0.4, 2, 0.4, 1
)
) %>%
shrink_estimate(
filtexp = 0.7, filtfactor = 1,
estim_base = gestim*bestim, estim_filt = abs(gestim*bestim)
) %>%
shrink_evaluate(nobs, case)
#> # A tibble: 25 x 5
#> nobs case mse_base mse_comp mse_ratio
#> <dbl> <int> <dbl> <dbl> <dbl>
#> 1 10 1 0.0136 0.0109 0.800
#> 2 10 2 0.0294 0.0272 0.925
#> 3 10 3 0.0660 0.0773 1.17
#> 4 10 4 0.0579 0.0679 1.17
#> 5 10 5 0.0786 0.0871 1.11
#> 6 20 1 0.00575 0.00493 0.857
#> 7 20 2 0.00353 0.00361 1.02
#> 8 20 3 0.0203 0.0233 1.15
#> 9 20 4 0.0185 0.0230 1.25
#> 10 20 5 0.0185 0.0200 1.08
#> # ... with 15 more rows
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.