sim.hdist: Simulate h-Statistic Distribution

View source: R/Francis_bomb_functions.R

sim.hdistR Documentation

Simulate h-Statistic Distribution

Description

sim.hdist Uses simulation to generate the distribution of the statistic h, which measures how well we can expect test and reference bomb radiocarbon data sets to agree, given the extent of sampling error associated with each. A positive (or negative) value of h implies that the test data is, on average, to the right (or left) of the reference line.

Usage

sim.hdist(
  ref,
  test,
  nsim = 5000,
  diag = 0,
  age = "age",
  age.err = "age.err",
  cy = "catch.year",
  y = "C14",
  y.err = "C14.err",
  s.age = "samp.age",
  b.yr = "C14year"
)

Arguments

ref

reference data used to develop a reference line; a data frame in which each row corresponds to one reference datum.

test

data frame containing the data from the species whose ages are being validated.

nsim

number of simulated data sets.

diag

integer, with possible values of 0, 1 and 2 that controls what, if any, diagnostic plots are plotted:

0

no diagnostic plots are constructed

1

plot actual data (refrence and test) and also the data considered 'true' for the simulations; does no simulations; returns the 'true test data.

2

plots one panel per simulation, 16 panels per page, with each panel showing the simulated (solid line) and true (broken line) reference lines and the simulated test data, with the estimated h-statistic given above the panel. (Note - use of this option is not sensible when nsim is 'large')

age

TBD

age.err

TBD

cy

TBD

y

TBD

y.err

TBD

s.age

TBD

b.yr

TBD

Value

A dataframe with components (each with length nrow(samp)) with components X, Y - x & y coordinates of closest points - and optionally (if incl.dist = TRUE) dist - signed distance from reference curve. Optionally plots (if plot = TRUE) the data, including lines joining each sample point to its closest point.

See Also

Other Bomb Radiocarbon Analyses: bias.plot.BR(), calc.bias(), calc.h(), closest.pt(), get.h.from.bias(), get.nearest(), get.ref.line()

Examples

data(snapper)
snapper.red <- snapper[snapper$C14year >= 1955 & snapper$C14year <= 1972, ]
data(bluenose)
bluenose.red <- bluenose[bluenose$C14year >= 1955 &
  bluenose$C14year <= 1972, ]
bluenose.red <- bluenose.red[bluenose.red$C14 >= -506 &
  bluenose.red$C14 <= 94.0, ]
ref <- get.ref.line(snapper.red$C14year, snapper.red$C14)
sim.hdist(ref = snapper.red, test = bluenose.red, nsim = 16, diag = 0)
sim.hdist(ref = snapper.red, test = bluenose.red, nsim = 16, diag = 1)
sim.hdist(ref = snapper.red, test = bluenose.red, nsim = 16, diag = 2)

ballengerj/FishyR documentation built on June 17, 2022, 10:33 p.m.