Skip to contents

This function serves as a wrapper to run various Spearman-Karber (SK) and Trimmed Spearman-Karber (TSK) analyses using a single interface. It returns a standardized one-row data frame for easy comparison.

Usage

analyze_SK(x, n, r, method, conf.level = 0.95, ...)

Arguments

x

Numeric vector of concentrations.

n

Numeric vector of total subjects per concentration.

r

Numeric vector of responses (e.g., dead) per concentration.

method

The analysis method to use. Must be one of:

  • "SK_modified" (your custom SpearmanKarber_modified function)

  • "tsk_auto_log" (drcHelper::tsk_auto with log-doses)

  • "tsk_auto_linear" (drcHelper::tsk_auto with linear doses)

  • "ecotox_SK" (ecotoxicology::SpearmanKarber)

conf.level

The confidence level for intervals (default 0.95).

...

Additional arguments passed to the underlying functions (e.g., max.trim for tsk_auto).

Value

A single-row data frame containing the standardized analysis results.

Examples

x <- c(0, 0.2, 0.3, 0.375, 0.625, 2)
n <- c(30, 30, 30, 30, 30, 30)
r <- c(0, 1, 3, 16, 24, 30)

# Run a single analysis
analyze_SK(x, n, r, method = "SK_modified")
#>        method    scale trim_or_A     LC50       LCL       UCL  log10LC50
#> 1 SK_modified log-dose        NA 0.449918 0.3908845 0.5178671 -0.3468666
#>   SD_LC50   SD_log10 GSD notes
#> 1      NA 0.03116634  NA      

# Run multiple analyses and combine into a single table
methods_to_run <- c("SK_modified", "tsk_auto_log", "tsk_auto_linear", "ecotox_SK")
all_results <- lapply(methods_to_run, function(m) {
  analyze_SK(x, n, r, method = m)
})
#> tsk_auto: zero dose with log transform detected; applying auto-trim = 0.0333
comparison_table <- do.call(rbind, all_results)
print(comparison_table)
#>            method       scale  trim_or_A      LC50       LCL       UCL
#> 1     SK_modified    log-dose         NA 0.4499180 0.3908845 0.5178671
#> 2    tsk_auto_log    log-dose 0.03333333 0.4438306 0.3822956 0.5152705
#> 3 tsk_auto_linear linear-dose 0.00000000 0.5620833 0.4414692 0.6826975
#> 4       ecotox_SK    log-dose         NA 0.4659196 0.3991858 0.5438096
#>    log10LC50    SD_LC50   SD_log10      GSD notes
#> 1 -0.3468666         NA 0.03116634       NA      
#> 2 -0.3527827         NA 0.07614879 1.079123      
#> 3 -0.2501993 0.06153895         NA       NA      
#> 4 -0.3316890         NA 0.03356796       NA