This is a high-level function that uses BAM to simulate age uncertainty in layer counted records, and stores this as an age-ensemble in a paleoData measurementTable, and in a model in chronData. If needed input variables are not entered, and cannot be deduced, it will run in interactive mode. BAM produces reasonable results for non-layer counted data, and can generate ensembles for unevenly spaced data, and thus is useful for generating ensembles for tie-point chronologies that are missing the necessary data to calculate ensembles properly. See Comboul et al. (2015) doi:10.5194/cp-10-825-2014 for details.

```
runBam(
L,
time.var = "year",
paleo.num = NA,
paleo.meas.table.num = NA,
chron.num = 1,
model.num = NA,
ens.table.number = NA,
make.new = FALSE,
n.ens = 1000,
model = NA
)
```

- L
A LiPD object - an R serialization of a single LiPD file. It's a list, and is typically created by `readLipd()`

- time.var
What is the time variable we're going to use for the basis of the simulation?

- paleo.num
the number of the paleoData object that you'll be working in

- paleo.meas.table.num
the number of the measurementTable you'll be working in

- chron.num
the number of the chronData object that you'll be working in

- model.num
the number of the chronData model where you want to store the model information

- ens.table.number
the number of the ensembleTable you want to put the output into

- make.new
Forces the creation of a new model (TRUE or FALSEdefault)

- n.ens
The number of members in the ensemble

- model
a list that describes the model to use in BAM

model$ns: number of samples

model$name: 'poisson' or 'bernoulli'

model$param: probability of growth band being perturbed (default: prob of missing band = prob of doubly-counted band = 0.05)

if model$param is a single argument, then the perturbations are symmetric (prob of missing band = prob of doubly-counted band)

if model$param = [a1 a2] and a1 neq a2 the model is asymmetric

a1 = prob(missing layer) - undercounted

a2 = prob(layer counted multiple times) - overcounted

if model$param: 2xp matrix, then different miscounting prob. are defined for each time series.

model$resize: do not resize: 0 (default), resize to shortest sample: -1, resize to longest sample: 1

model$tm: if a time model is provided, the code returns the corresponding perturbed data

L The single LiPD object that was entered, with ageEnsemble and chronData model added.

Other BAM:
`bamCorrect()`

,
`simulateBam()`

```
if (FALSE) {
#Run in interactive mode:
L = runBam(L)
#Run in noninteractive mode, describing everything:
L = runBam(L,paleo.num = 1, paleo.meas.table.num = 1, model.num = 3, make.new = TRUE,
nEns = 100, model = list(name = "poisson",param = 0.05, resize = 0, ns = n.ens))
}
```