Learn R Programming

ecotox (version 1.4.1)

ratio_test: Ratio test

Description

Calculates a ratio test to compare two LC or LT values from two seperate 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)

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 disired 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 specfied 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 calcuate 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 tranformed. 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() tranformed. If FALSE results will not be back transformed.

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 detemined 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

Run this code
# NOT RUN {
# view lamprey_tox data

head(lamprey_tox)

# 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

# }

Run the code above in your browser using DataLab