| correctSingleHeap | R Documentation |
While correctHeaps corrects regular heaping patterns,
this function allows correction of a single specific heap value.
This is useful when heaping occurs at irregular intervals or when
only a particular age shows excessive heaping.
correctSingleHeap(
x,
heap,
before = 2,
after = 2,
method = "lnorm",
fixed = NULL,
seed = NULL,
na.action = "omit",
verbose = FALSE,
sd = NULL
)
x |
numeric vector representing ages (typically integers). |
heap |
numeric value specifying the age for which heaping should
be corrected. Must be present in |
before |
numeric value specifying the number of years before the heap to use as the lower bound for replacement values. Will be rounded to an integer. Default is 2. |
after |
numeric value specifying the number of years after the heap to use as the upper bound for replacement values. Will be rounded to an integer. Default is 2. |
method |
character string specifying the distribution used for correction:
|
fixed |
numeric vector of indices indicating observations that should not be changed. Useful for preserving known accurate values. |
seed |
optional integer for random seed to ensure reproducibility. |
na.action |
character string specifying how to handle |
verbose |
logical. If |
sd |
optional numeric value for standard deviation when |
Correct a specific age heap in a vector containing ages.
A numeric vector of the same length as x with the specified
heap corrected, or a list with diagnostics if verbose = TRUE.
Matthias Templ, Bernhard Meindl
correctHeaps for correcting regular heaping patterns.
Other heaping correction:
correctHeaps()
# Create artificial age data
set.seed(123)
age <- rlnorm(10000, meanlog = 2.466869, sdlog = 1.652772)
age <- round(age[age < 93])
# Artificially introduce a heap at age 23
age23 <- c(age, rep(23, length = sum(age == 23)))
# Correct with reproducible results
age23_corrected <- correctSingleHeap(age23, heap = 23, before = 5, after = 5,
method = "lnorm", seed = 42)
# Get diagnostic information
result <- correctSingleHeap(age23, heap = 23, before = 5, after = 5,
verbose = TRUE, seed = 42)
print(result$n_changed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.