Skip to contents

Calculates a ratio test to compare two LC or LT values from two separate probit or logit models. This function is based on the ratio test developed in Wheeler et al. 2006. 10.1897/05-320R.1 which has been suggested as a replacement to the common method of comparing confidence intervals to determine differences.

Usage

ratio_test(model_1, model_2, percentage = NULL,
           type = NULL, compare = NULL, log_base = NULL, log_x = TRUE,
           obj_type = NULL, conf_type = NULL)

Arguments

model_1

first model used in the ratio test. Should be an object of either a probit or logit model created using the glm() function. See example.

model_2

second model used in the ratio test. Should be an object of either a probit or logit model created using the glm() function. See example.

percentage

either a single value or a vector for given LC or LT percentage desired to compare. Percentage is the same value used for the argument p in all LC_ and LT_ functions. For example, 50 will return and compare LC50 values for the two models. If more than one LC value is desired specify by creating a vector. LC values can be calculated down to the 1e-16 of a percentage (e.g. LC99.99). However, the tibble produced can and will round to nearest whole number.

type

Link type needs to be specified to either "probit" which is default and will return and used in calculations for a probit model for the desired LCs or LTs. If specified to "logit" then ratio_test will return and calculate using a logit model for the desired LCs or LTs.

compare

Supply a character string to be used in the output letting the user know what models the LCs or LTs are being compared. Default output is "Model 1 - Model 2". See example.

log_base

default is 10 and will be used to calculate results using the anti of log10() given that the x variable has been log10 transformed. If FALSE results will not be back transformed.

log_x

default is TRUE and will calculate results using the antilog of determined by log_base given that the x variable has been log() transformed. If FALSE results will not be back transformed.

obj_type

default is "list" which requires both model_1 and model_2 arguments to be model objects, in the form of a list, from glm() functions. Alternatively "df" can be used which will require both model_1 and model_2 arguments to be data.frame objects created when running either LC_ or LT_ functions.

conf_type

default is "fl" which if "df" is supplied will correct covariance values if h is above 1 as fudicial confidence limits use a heterogeneity factor, h, to correct variances when chi-square p value is less than 0.15. conf_type can also be "dm", delta method, which doesn't use a heterogeneity correction factor therefore covariance will not be uncorrected. This argument is only needed if you are using the dataframe objects from LC_ or LT_ functions and have used the delta method in that analysis.

Value

A tibble with percentage for the LC or LT value desired for the above percentage argument, dose_1 and dose_2 displayed calculated backtransformed or untransformed doses for the desired LC or LT values. Standard Error (se), Z test statistic (test_stat) and p_value determined using Z test statistic as determined using formulas in Wheeler et al. 2006. .

References

Wheeler, M.W., Park, R.M., and Bailey, A.J., 2006. Comparing median lethal concentration values using confidence interval overlap or ratio tests, Environ. Toxic. Chem. 25(5), 1441-1444.10.1897/05-320R.1

Examples

# view lamprey_tox data

head(lamprey_tox)
#> # A tibble: 6 × 7
#>   nominal_dose tank  month  dose response survive total
#>          <dbl> <chr> <chr> <dbl>    <dbl>   <dbl> <dbl>
#> 1          0   S     May    0.19        0      20    20
#> 2          0.7 A     May    0.79        0      20    20
#> 3          0.7 L     May    0.8         1      19    20
#> 4          0.7 M     May    0.76        0      20    20
#> 5          1.1 B     May    1.36       13       8    21
#> 6          1.1 K     May    1.22       10       9    19

# using glm() to detemine LC values using probit model for May and June

m <- glm((response / total) ~ log10(dose),
         data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
         subset = c(month == "May"),
         weights = total,
         family = binomial(link = "probit"))


j <- glm((response / total) ~ log10(dose),
         data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
         subset = c(month == "June"),
         weights = total,
         family = binomial(link = "probit"))

# now that both May and June models have been made. use ratio_test to
# compare LC50 values or whatever LC values of interest.

ratios <- ratio_test(model_1 = m, model_2 = j, percentage = 50,
compare = "May - June")

# view ratio test results

ratios
#> # A tibble: 1 × 7
#>   compare    percentage dose_1 dose_2    se test_stat p_value
#>   <chr>           <dbl>  <dbl>  <dbl> <dbl>     <dbl>   <dbl>
#> 1 May - June         50   1.25   2.66 0.110      2.98 0.00292

# you can also use LC_probit to create the models and use ratio test

m_1 <- LC_probit((response / total) ~ log10(dose), p = c(50, 99),
weights = total,
data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
subset = c(month == "May"))



j_1 <- LC_probit((response / total) ~ log10(dose), p = c(50, 99),
weights = total,
data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
subset = c(month == "June"))



ratios_2 <- ratio_test(model_1 = m_1, model_2 = j_1, percentage = 50,
compare = "May - June", obj_type = "df")

ratios_2
#> # A tibble: 1 × 7
#>   compare    percentage dose_1 dose_2    se test_stat p_value
#>   <chr>           <dbl>  <dbl>  <dbl> <dbl>     <dbl>   <dbl>
#> 1 May - June         50   1.25   2.66 0.110      2.98 0.00292