MLEbin.simulate: Simulate, bin and fit data using four different binning...

View source: R/simulating.R

MLEbin.simulateR Documentation

Simulate, bin and fit data using four different binning methods and two likelihood approaches

Description

Simulate multiple data sets from a known individual size distribution (the PLB distribution), bin them using linear bins of width 1, 5 and 10, and using bins that progressively double in width, and then fit each data set using the MLEmid and MLEbin likelihood methods. As in Figures 4, 5, and S.35-S.38, and Tables S.3-S.5 of MEPS paper. See MEPS_reproduce_2.Rmd vignette for code for those figures and tables. All simulated data sets have the same parameters for PLB and the same sample size n. Individual data sets are not saved as they quickly take up a lot of memory (would be num.reps \times n random numbers, which for the default values is 10^7).

Usage

MLEbin.simulate(
  n = 1000,
  b.known = -2,
  xmin.known = 1,
  xmax.known = 1000,
  num.reps = 10000,
  seed = 42,
  binType = list(1, 5, 10, "2k"),
  vecDiffVal = 0.5,
  cut.off = NA,
  full.mult = 1.5
)

Arguments

n

sample size of each simulated data set (numeric)

b.known

known fixed value of b for all simulations

xmin.known

known fixed value of xmin (minimum allowable x value); currently needs to be a power of two (since makes it simpler to define the bin widths that double in size).

xmax.known

known fixed value of xmax (maximum allowable x value)

num.reps

number of random samples to draw, where each sample is a set of n random numbers (like throwing n PLB dice num.reps times)

seed

seed for random number generator (default is the same as for MEE paper)

binType

list containing numeric values for linear bin widths and/or "2k" (the only other option for now) for bins that double in size. Values other than the defaults have not yet been tested but should work.

vecDiffVal

value to go into profLike() to compute confidence intervals.

cut.off

cut-off value - data are only sampled \geq cut.off, for Figure S.37 and S.38 and Table S.5 in MEPS paper. Each resulting sample still has size n.

full.mult

multiplier to generate desired sample size when using a cut.off value.

Value

list containing:

  • MLE.array: three-dimensional array with element ⁠[i, j, k]⁠ representing the estimate of b obtained from random sample i, bin type j, and MLE method k. Size is num.reps \times length(binType) \times 2.

  • MLEconf.array: four-dimensional array with vector MLEconf.array[i, j, k, ] being the confidence interval c(confMin, confMax) for random sample i, bin type j, and MLE method k.

  • MLE.array.parameters: list containing values of n, b.known, xmin.known, xmax.known, num.reps, binType, binTypes, binType.name

Author(s)

Andrew Edwards


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