This function automatically determines the appropriate trim level for TSK analysis and applies it. It first tries with no trimming, and if that fails due to responses not spanning the required range, it automatically calculates and applies the minimum required trim level based on the data characteristics.
Usage
tsk_auto(x, ...)
# S3 method for class 'numeric'
tsk_auto(
x,
n,
r,
control = 0,
conf.level = 0.95,
use.log.doses = TRUE,
max.trim = 0.45,
...
)
# S3 method for class 'data.frame'
tsk_auto(
x,
control = 0,
conf.level = 0.95,
use.log.doses = TRUE,
max.trim = 0.45,
...
)Arguments
- x
A numeric vector of doses (for numeric method) or a data frame containing columns 'x', 'n', and 'r' (for data.frame method).
- ...
Additional arguments passed to the tsk function.
- n
A numeric vector of total counts (for numeric method only).
- r
A numeric vector of response counts (for numeric method only).
- control
A numeric value indicating the control dose (default is 0).
- conf.level
A numeric value indicating the confidence level (default is 0.95).
- use.log.doses
A logical value indicating whether to use log-transformed doses (default is TRUE).
- max.trim
A numeric value indicating the maximum allowed trim level (default is 0.45, must be < 0.5).
Details
The automatic trimming is triggered when the response proportions don't increase from the trim level to 1-trim level, which typically occurs when responses are too close to 0% or 100% at the extreme doses.
Examples
if (FALSE) { # \dontrun{
# With numeric vectors - data that needs trimming
doses <- c(0, 1, 2, 3, 4, 5)
total <- rep(20, 6)
responses <- c(0, 2, 8, 14, 18, 20) # Goes from 0 to 100%
result <- tsk_auto(doses, total, responses)
# With data frame - moderate responses that may not need trimming
data <- data.frame(
x = c(0.1, 0.5, 1, 2, 4, 8),
n = rep(20, 6),
r = c(2, 5, 8, 12, 15, 17)
)
result <- tsk_auto(data)
# Using hamilton dataset (if available)
if (exists("hamilton")) {
# Try with one of the hamilton datasets
result <- tsk_auto(hamilton$dr1a)
}
} # }