Skip to contents

Extract a tidy dataset with results from an object of class simsum, summary.simsum, multisimsum, or summary.multisimsum.

Usage

# S3 method for simsum
tidy(x, stats = NULL, ...)

# S3 method for summary.simsum
tidy(x, stats = NULL, ...)

# S3 method for multisimsum
tidy(x, stats = NULL, ...)

# S3 method for summary.multisimsum
tidy(x, stats = NULL, ...)

Arguments

x

An object of class simsum.

stats

Summary statistics to include; can be a scalar value or a vector. Possible choices are:

  • nsim, the number of replications with non-missing point estimates and standard error.

  • thetamean, average point estimate.

  • thetamedian, median point estimate.

  • se2mean, average standard error.

  • se2median, median standard error.

  • bias, bias in point estimate.

  • rbias, relative (to the true value) bias in point estimate.

  • empse, empirical standard error.

  • mse, mean squared error.

  • relprec, percentage gain in precision relative to the reference method.

  • modelse, model-based standard error.

  • relerror, relative percentage error in standard error.

  • cover, coverage of a nominal level\

  • becover, bias-eliminated coverage of a nominal level\

  • power, power of a (1 - level)\ Defaults to NULL, in which case all summary statistics are returned.

...

Ignored.

Value

A data.frame containing summary statistics from a simulation study.

Examples

data(MIsim)
x <- simsum(
  data = MIsim, estvarname = "b", true = 0.5, se = "se",
  methodvar = "method"
)
#> 'ref' method was not specified, CC set as the reference
tidy(x)
#>           stat           est         mcse  method
#> 1         nsim  1.000000e+03           NA      CC
#> 2    thetamean  5.167662e-01           NA      CC
#> 3  thetamedian  5.069935e-01           NA      CC
#> 4      se2mean  2.163731e-02           NA      CC
#> 5    se2median  2.114245e-02           NA      CC
#> 6         bias  1.676616e-02 0.0047786757      CC
#> 7        rbias  3.353232e-02 0.0095573514      CC
#> 8        empse  1.511150e-01 0.0033807248      CC
#> 9          mse  2.309401e-02 0.0011338389      CC
#> 10     relprec  0.000000e+00 0.0000000000      CC
#> 11     modelse  1.470963e-01 0.0005274099      CC
#> 12    relerror -2.659384e+00 2.2054817330      CC
#> 13       cover  9.430000e-01 0.0073315073      CC
#> 14     becover  9.400000e-01 0.0075099933      CC
#> 15       power  9.460000e-01 0.0071473072      CC
#> 16        nsim  1.000000e+03           NA MI_LOGT
#> 17   thetamean  5.009231e-01           NA MI_LOGT
#> 18 thetamedian  4.969223e-01           NA MI_LOGT
#> 19     se2mean  1.820915e-02           NA MI_LOGT
#> 20   se2median  1.721574e-02           NA MI_LOGT
#> 21        bias  9.230987e-04 0.0041744101 MI_LOGT
#> 22       rbias  1.846197e-03 0.0083488201 MI_LOGT
#> 23       empse  1.320064e-01 0.0029532306 MI_LOGT
#> 24         mse  1.740913e-02 0.0008812805 MI_LOGT
#> 25     relprec  3.104634e+01 3.9374726448 MI_LOGT
#> 26     modelse  1.349413e-01 0.0006046041 MI_LOGT
#> 27    relerror  2.223259e+00 2.3323382138 MI_LOGT
#> 28       cover  9.490000e-01 0.0069569390 MI_LOGT
#> 29     becover  9.490000e-01 0.0069569390 MI_LOGT
#> 30       power  9.690000e-01 0.0054807846 MI_LOGT
#> 31        nsim  1.000000e+03           NA    MI_T
#> 32   thetamean  4.988092e-01           NA    MI_T
#> 33 thetamedian  4.939111e-01           NA    MI_T
#> 34     se2mean  1.791169e-02           NA    MI_T
#> 35   se2median  1.693191e-02           NA    MI_T
#> 36        bias -1.190835e-03 0.0042509767    MI_T
#> 37       rbias -2.381670e-03 0.0085019534    MI_T
#> 38       empse  1.344277e-01 0.0030073985    MI_T
#> 39         mse  1.805415e-02 0.0009112249    MI_T
#> 40     relprec  2.636816e+01 3.8423791135    MI_T
#> 41     modelse  1.338346e-01 0.0005856362    MI_T
#> 42    relerror -4.412233e-01 2.2695215740    MI_T
#> 43       cover  9.430000e-01 0.0073315073    MI_T
#> 44     becover  9.430000e-01 0.0073315073    MI_T
#> 45       power  9.630000e-01 0.0059691708    MI_T

# Extracting only bias and coverage:
tidy(x, stats = c("bias", "cover"))
#>    stat           est        mcse  method
#> 1  bias  0.0167661608 0.004778676      CC
#> 2 cover  0.9430000000 0.007331507      CC
#> 3  bias  0.0009230987 0.004174410 MI_LOGT
#> 4 cover  0.9490000000 0.006956939 MI_LOGT
#> 5  bias -0.0011908351 0.004250977    MI_T
#> 6 cover  0.9430000000 0.007331507    MI_T

xs <- summary(x)
tidy(xs)
#>           stat           est         mcse  method        lower        upper
#> 1         nsim  1.000000e+03           NA      CC           NA           NA
#> 2    thetamean  5.167662e-01           NA      CC           NA           NA
#> 3  thetamedian  5.069935e-01           NA      CC           NA           NA
#> 4      se2mean  2.163731e-02           NA      CC           NA           NA
#> 5    se2median  2.114245e-02           NA      CC           NA           NA
#> 6         bias  1.676616e-02 0.0047786757      CC  0.007400129  0.026132193
#> 7        rbias  3.353232e-02 0.0095573514      CC  0.014800257  0.052264386
#> 8        empse  1.511150e-01 0.0033807248      CC  0.144488895  0.157741093
#> 9          mse  2.309401e-02 0.0011338389      CC  0.020871727  0.025316293
#> 10     relprec  0.000000e+00 0.0000000000      CC  0.000000000  0.000000000
#> 11     modelse  1.470963e-01 0.0005274099      CC  0.146062561  0.148129970
#> 12    relerror -2.659384e+00 2.2054817330      CC -6.982048962  1.663280569
#> 13       cover  9.430000e-01 0.0073315073      CC  0.928630510  0.957369490
#> 14     becover  9.400000e-01 0.0075099933      CC  0.925280684  0.954719316
#> 15       power  9.460000e-01 0.0071473072      CC  0.931991535  0.960008465
#> 16        nsim  1.000000e+03           NA MI_LOGT           NA           NA
#> 17   thetamean  5.009231e-01           NA MI_LOGT           NA           NA
#> 18 thetamedian  4.969223e-01           NA MI_LOGT           NA           NA
#> 19     se2mean  1.820915e-02           NA MI_LOGT           NA           NA
#> 20   se2median  1.721574e-02           NA MI_LOGT           NA           NA
#> 21        bias  9.230987e-04 0.0041744101 MI_LOGT -0.007258595  0.009104792
#> 22       rbias  1.846197e-03 0.0083488201 MI_LOGT -0.014517189  0.018209584
#> 23       empse  1.320064e-01 0.0029532306 MI_LOGT  0.126218211  0.137794663
#> 24         mse  1.740913e-02 0.0008812805 MI_LOGT  0.015681848  0.019136404
#> 25     relprec  3.104634e+01 3.9374726448 MI_LOGT 23.329036439 38.763645587
#> 26     modelse  1.349413e-01 0.0006046041 MI_LOGT  0.133756280  0.136126285
#> 27    relerror  2.223259e+00 2.3323382138 MI_LOGT -2.348039558  6.794558240
#> 28       cover  9.490000e-01 0.0069569390 MI_LOGT  0.935364650  0.962635350
#> 29     becover  9.490000e-01 0.0069569390 MI_LOGT  0.935364650  0.962635350
#> 30       power  9.690000e-01 0.0054807846 MI_LOGT  0.958257860  0.979742140
#> 31        nsim  1.000000e+03           NA    MI_T           NA           NA
#> 32   thetamean  4.988092e-01           NA    MI_T           NA           NA
#> 33 thetamedian  4.939111e-01           NA    MI_T           NA           NA
#> 34     se2mean  1.791169e-02           NA    MI_T           NA           NA
#> 35   se2median  1.693191e-02           NA    MI_T           NA           NA
#> 36        bias -1.190835e-03 0.0042509767    MI_T -0.009522596  0.007140926
#> 37       rbias -2.381670e-03 0.0085019534    MI_T -0.019045193  0.014281852
#> 38       empse  1.344277e-01 0.0030073985    MI_T  0.128533294  0.140322080
#> 39         mse  1.805415e-02 0.0009112249    MI_T  0.016268182  0.019840118
#> 40     relprec  2.636816e+01 3.8423791135    MI_T 18.837236583 33.899085938
#> 41     modelse  1.338346e-01 0.0005856362    MI_T  0.132686735  0.134982387
#> 42    relerror -4.412233e-01 2.2695215740    MI_T -4.889403808  4.006957286
#> 43       cover  9.430000e-01 0.0073315073    MI_T  0.928630510  0.957369490
#> 44     becover  9.430000e-01 0.0073315073    MI_T  0.928630510  0.957369490
#> 45       power  9.630000e-01 0.0059691708    MI_T  0.951300640  0.974699360