knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 5.7,
  fig.height = 7
  )

Main simulation results for MEPS paper, from fitting maximum likelihood value (and confidence interval) of $b$ for each combination of 10,000 simulated data sets, four binning methods and two fitting methods (MLEmid or MLEbin). Reproduces MEPS Figures 4 and 5 and Table S.3. Then does the same analyses with $x$~min~$=16$ (Figures S.35 and S.36 and Table S.4), and with $x$~min~$=1$ but only sampling above a cutoff value of 16 (Figures S.37 and S.38 and Table S.5).

The simulated data take over an hour (on a fast laptop) to generate, bin and fit. So results are saved within the package in the lists MLEbin.MEPS.default, MLEbin.MEPS.xmin16 and MLEbin.MEPS.cutoff16. Each list contains the fitted maximum likelihood value (and confidence interval) of $b$ for each combination of 10,000 simulated data sets, four binning methods and two fitting methods (MLEmid or MLEbin).

library(sizeSpectra)

Reproducing main simulation results of MEPS paper -- Figures 4 and 5 and Table S.3

To create MLEbin.MEPS.default run the next line (which is not evaluated by this vignette but is run once in data-raw/simulate-data2.R to save the list as part of this package):

MLEbin.MEPS.default <- MLEbin.simulate()

The list contains three items (see ?MLEbin.simulate):

summary(MLEbin.MEPS.default)
dim(MLEbin.MEPS.default$MLE.array)

with example MLEs of $b$:

MLEbin.MEPS.default$MLE.array[ 1:5, , ]

Example confidence intervals are

MLEbin.MEPS.default$MLEconf.array[1:5, "Linear 1", "MLEmid", ]

and the associated parameter values and binning types used for the simulations are:

MLEbin.MEPS.default$MLE.array.parameters

Figure 4 shows histograms of the estimates of $b$ for the MLEs for both methods and all four binning types:

MLEmid.MLEbin.hist(MLEbin.MEPS.default)

Figure 5 gives the confidence intervals for the MLEs for both methods and all four binning types:

# These two lines just give a different inset for panel (e):
insetMat = matrix(rep(c(-0.01, -0.04), 4),
                  ncol=2,
                  byrow=TRUE)
insetMat[3, 1] = 0.3

MLEmid.MLEbin.conf(MLEbin.MEPS.default,
                   insetMat = insetMat)

Make a dataframe of the results and show here, reproducing Table S.3:

knitr::kable(MLEmid.MLEbin.table(MLEbin.MEPS.default))

Setting $x$~min~$=16$ -- Figures S.35 and S.36 and Table S.4

Similarly, the simulation results obtained from setting $x$~min~$=16$ are saved in the object MLEbin.MEPS.xmin16, obtained by running the next line (which is not evaluated by this vignette but is run once in data-raw/simulate-data2.R):

MLEbin.MEPS.xmin16 <- MLEbin.simulate(xmin.known = 16)

Figure S.35 is then

MLEmid.MLEbin.hist(MLEbin.MEPS.xmin16)

Figure S.36 shows the confidence intervals:

MLEmid.MLEbin.conf(MLEbin.MEPS.xmin16)

And Table S.4 is:

knitr::kable(MLEmid.MLEbin.table(MLEbin.MEPS.xmin16))

Setting $x$~min~$=1$ but only sampling data above the cutoff value of 16 -- Figures S.37 and S.38 and Table S.5)

Similarly, the simulation results obtained from setting $x$~min~$=1$ again but only sampling above the cutoff value of 16 are saved in the object MLEbin.MEPS.cutoff16, obtained by running the next line (which is not evaluated by this vignette but is run once in data-raw/simulate-data2.R):

MLEbin.MEPS.cutoff16 <- MLEbin.simulate(cut.off = 16)

Figure S.37 is then

MLEmid.MLEbin.hist(MLEbin.MEPS.cutoff16)

Figure S.38 shows the confidence intervals:

MLEmid.MLEbin.conf(MLEbin.MEPS.cutoff16)

And Table S.5 is:

knitr::kable(MLEmid.MLEbin.table(MLEbin.MEPS.cutoff16))


andrew-edwards/sizeSpectra documentation built on June 28, 2023, 7:09 p.m.