Title: | An Automated Approach to Evaluating Dose-Effect Experiments Following Litchfield and Wilcoxon (1949) |
---|---|
Description: | The manual approach of Litchfield and Wilcoxon (1949) <http://jpet.aspetjournals.org/content/96/2/99.abstract> for evaluating dose-effect experiments is automated so that the computer can do the work. |
Authors: | Jean V. Adams [aut, cre] |
Maintainer: | Jean V. Adams <[email protected]> |
License: | GPL |
Version: | 1.1.0.9000 |
Built: | 2024-11-16 03:34:23 UTC |
Source: | https://github.com/jvadams/lw1949 |
Assess the fit of a dose-response curve using the chi-squared statistic. The curve is described by the intercept and slope of a straight line in the log dose vs. probit effect scale.
assessfit(params, DEdata, fit = gamtable1(), simple = TRUE)
assessfit(params, DEdata, fit = gamtable1(), simple = TRUE)
params |
A numeric vector of length two, with the estimated intercept and slope of the dose-effect relation on the log10 and probit scale. These parameters define the dose-response curve. |
DEdata |
A data frame of dose-effect data (typically, the output from
|
fit |
A model object that can be used to predict the corrected values
(as proportions) from |
simple |
A logical scalar indicating if the output should be restricted to just the P value, default TRUE. |
This function is used to find the dose-response curve that minimizes the
chi-squared statistic measuring the distance between the observed and
expected values of the response (the proportion affected).
Following Litchfield and Wilcoxon (1949, steps B1 and B2),
records with expected effects < 0.01% or > 99.99% are deleted, and
other expected effects are "corrected" using the
correctval
function.
If simple=FALSE
, a list of length two. The first element,
chi
, is a numeric vector of length three:
chistat
, chi-squared statistic;
df
, degrees of freedom; and
pval
, P value.
The second element,
contrib
, is a matrix of three numeric vectors the same length as
obsn
:
exp
, expected effects;
obscorr
, observed effects corrected; and
contrib
, contributions to the chi-squared.
If simple=TRUE
, a numeric scalar, the chi-squared statistic
(see details).
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
LWchi2
and chisq.test
.
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=conc, ntot=numtested, nfx=nalive) gamfit <- gamtable1() assessfit(log10(c(0.125, 0.5)), mydat, simple=FALSE)
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=conc, ntot=numtested, nfx=nalive) gamfit <- gamtable1() assessfit(log10(c(0.125, 0.5)), mydat, simple=FALSE)
Calculate the coefficients from a fitted probit regression model with confidence intervals.
coefprobit(pfit, alpha = 0.05)
coefprobit(pfit, alpha = 0.05)
pfit |
An object of class |
alpha |
A numeric scalar, the significance level used to generate
100*(1 - |
A numeric vector of length six, the intercept and slope of the
dose-response curve, each with 100*(1 - alpha
)%
confidence limits.
toxdat <- data.frame( dose=c(0.05, 0.0625, 0.125, 0.25, 0.5, 1), ntot=rep(8, 6), nfx = c(0, 1, 4, 4, 6, 8)) myfit <- fitprobit(toxdat) coefprobit(myfit)
toxdat <- data.frame( dose=c(0.05, 0.0625, 0.125, 0.25, 0.5, 1), ntot=rep(8, 6), nfx = c(0, 1, 4, 4, 6, 8)) myfit <- fitprobit(toxdat) coefprobit(myfit)
Constrain data to a specified range, assigning values from the specified range to those outside the range, typically for graphing purposes.
constrain(x, xrange)
constrain(x, xrange)
x |
A numeric vector of values to constrain. |
xrange |
A numeric vector of length two specifying the constraints, the minimum and
maximum value for |
A numeric vector, the same length as x
, in which the minimum
constraint is assigned to values of x
less than the minimum,
and the maximum constraint is assigned to values of x
greater than
the maximum.
constrain(1:20, c(3, 19))
constrain(1:20, c(3, 19))
Given an expected proportional effect, calculate the "corrected" proportional effect using a model fit of Litchfield and Wilcoxon's (1949) Table 1.
correctval(val, fit)
correctval(val, fit)
val |
A numeric vector of expected effects (as proportions). |
fit |
A model object to be used to predict the "corrected" effects
(as proportions) from |
A numeric vector of corrected effects (as proportions),
the same length as val
.
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
gamfit <- gamtable1() correctval(c(0.37, 0.5, 0.63), gamfit)
gamfit <- gamtable1() correctval(c(0.37, 0.5, 0.63), gamfit)
Prepare dose-effect data for evaluation.
dataprep(dose, ntot, nfx)
dataprep(dose, ntot, nfx)
dose |
A numeric vector of unique, chemical concentrations (see Details). |
ntot |
A numeric vector of the number of individuals that were tested at each dose. |
nfx |
A numeric vector of the number of individuals that were affected at each dose. |
The input data are expected to be summarized by dose. If duplicate doses are provided, an error will be thrown.
A data frame with eight columns (ordered by dose and proportion affected), seven numeric vectors and one logical vector:
dose
= chemical concentrations.
ntot
= the number of individuals that were tested at each
dose.
nfx
= the number of individuals that were affected at each
dose.
rec
= the record number corresponding to the input vectors
dose
, ntot
, nfx
.
pfx
= the proportion of individuals that were affected at
each dose.
log10dose
= log transformed dose, log10(dose)
.
bitpfx
= probit transformed proportional affected,
probit(pfx)
.
fxcateg
= effects category: 0 for none affected, 100 for all
affected, and 50 for other proportions affected.
LWkeep
= logical vector identifying records to keep for
Litchfield and Wilcoxon (1949, step A1) method.
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) dataprep(dose=conc, ntot=numtested, nfx=nalive)
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) dataprep(dose=conc, ntot=numtested, nfx=nalive)
Determine if a dose-effect relation is estimable based on available data.
estimable(DEdata)
estimable(DEdata)
DEdata |
A data frame of dose-effect data (typically, the output from
|
A dose-effect relation is defined to be estimable if and only if there are at least two test records and there is some (non-zero) variability in both the doses and the proportional effects. The input data are expected to be summarized by dose. If duplicate doses are provided, an error will be thrown.
A logical scalar indicating if a dose-effect relation is estimable.
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=conc, ntot=numtested, nfx=nalive) estimable(mydat) nalive2 <- rep(4, 5) mydat2 <- dataprep(dose=conc, ntot=numtested, nfx=nalive2) estimable(mydat2)
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=conc, ntot=numtested, nfx=nalive) estimable(mydat) nalive2 <- rep(4, 5) mydat2 <- dataprep(dose=conc, ntot=numtested, nfx=nalive2) estimable(mydat2)
Fill in missing values in a vector, using the last recorded value.
fill(x, resetWhen = rep(FALSE, length(x)))
fill(x, resetWhen = rep(FALSE, length(x)))
x |
A vector, can be character, numeric, or logical. |
resetWhen |
A logical vector, the same length as |
Similar to na.locf
in the zoo
package,
but works for "" in character vectors as well.
A vector the same length as x
, with all NAs or ""s replaced by
the last value for the vector.
Note that and missing values at the beginning of the vector will not
be replaced.
numvec <- c(NA, 1:5, NA, NA, NA, 10:12, NA) newgroup <- c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0) fill(numvec) fill(numvec, newgroup) charvec <- c("", letters[1:5], "", "", "", letters[10:12], "") fill(charvec)
numvec <- c(NA, 1:5, NA, NA, NA, 10:12, NA) newgroup <- c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0) fill(numvec) fill(numvec, newgroup) charvec <- c("", letters[1:5], "", "", "", letters[10:12], "") fill(charvec)
Use simple linear regression to describe a hand draw line fit to a dose-effect experiment.
fitHand(handDose, handPct)
fitHand(handDose, handPct)
handDose |
A numeric vector of doses for which expected effects are estimated from a hand drawn line, must have at least two unique values. |
handPct |
A numeric vector of the expected percent affected corresponding to (and
the same length as) |
A numeric vector of length two, the estimated intercept and slope of the dose-response curve on the log10-probit scale,
d <- c(0.0625, 0.125, 0.25, 0.5, 1) p <- c(9.5, 34, 67, 90.5, 98.6) fitHand(handDose=d, handPct=p)
d <- c(0.0625, 0.125, 0.25, 0.5, 1) p <- c(9.5, 34, 67, 90.5, 98.6) fitHand(handDose=d, handPct=p)
Determine coefficients (intercept and slope) from dose-effect data using simple linear regression on the log10 dose vs. probit effect scale.
fitlinear(DEdata, constr = c(5e-04, 0.9995))
fitlinear(DEdata, constr = c(5e-04, 0.9995))
DEdata |
A data frame of dose-effect data (typically, the output from
|
constr |
A numeric vector of length two, indicating the constraints
(see |
A numeric vector of length two, the estimated intercept and slope.
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=conc, ntot=numtested, nfx=nalive) fitlinear(mydat)
conc <- c(0.0625, 0.125, 0.25, 0.5, 1) numtested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=conc, ntot=numtested, nfx=nalive) fitlinear(mydat)
Use optimization to describe the best fitting line to a dose-effect experiment following the methods of Litchfield and Wilcoxon (1949).
fitLWauto(DEdata)
fitLWauto(DEdata)
DEdata |
A data frame of dose-effect data (typically, the output from
|
The input data are expected to be summarized by dose. If duplicate doses are provided, an error will be thrown.
A numeric vector of length two, the estimated intercept and slope of the dose-response curve on the log10-probit scale,
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) mydat fitLWauto(mydat)
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) mydat fitLWauto(mydat)
Fit a probit regression to dose-effect data, using the log10 of the dose as the response.
fitprobit(dat)
fitprobit(dat)
dat |
A data frame of toxicity data, including at least three variables: dose (the concentration of the tested chemical), ntot (the number of individuals tested), and nfx (the number of affected individuals). |
Only those rows with dose > 0
, ntot > 0
, and nfx >= 0
are used in fitting the model.
A an object of class glm
.
toxdat <- data.frame( dose=c(0.05, 0.0625, 0.125, 0.25, 0.5, 1), ntot=rep(8, 6), nfx = c(0, 1, 4, 4, 6, 8)) fitprobit(toxdat)
toxdat <- data.frame( dose=c(0.05, 0.0625, 0.125, 0.25, 0.5, 1), ntot=rep(8, 6), nfx = c(0, 1, 4, 4, 6, 8)) fitprobit(toxdat)
Define three effect categories, 0 for none affected, 100 for all affected, and 50 for other proportions affected.
fxcat(dat)
fxcat(dat)
dat |
A data frame of toxicity data, including at least two variables: ntot (the number of individuals tested) and nfx (the number of affected individuals). |
An integer vector the same length as prob
with
categories of 0, 50, or 100.
toxdat <- data.frame( dose=c(0.0625, 0.125, 0.25, 0.5), ntot=rep(8, 4), nfx = c(0, 4, 6, 8)) cbind(toxdat, fxcat(toxdat))
toxdat <- data.frame( dose=c(0.0625, 0.125, 0.25, 0.5), ntot=rep(8, 4), nfx = c(0, 4, 6, 8)) cbind(toxdat, fxcat(toxdat))
Fit a smooth GAM function to replace looking up values in Table 1 of Litchfield and Wilcoxon (1949).
gamtable1()
gamtable1()
Note that for an expected value of 37 Table 1 gives a corrected value of
9.4, but for an expected value of 63 it gives a corrected value of 90.5.
To ensure that both values add to 100, I used corrected values of 9.45
and 90.55. The expected and corrected values from Table 1 are then used
to build a GAM model, which is used as input to the
correctval
function.
A gamObject
that can be used to predict the corrected values
(as proportions) from distexpprop5
,
the distance between the expected values (as proportions) and 0.5
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
fit <- gamtable1() summary(fit) plot(fit)
fit <- gamtable1() summary(fit) plot(fit)
Convert values on the probit scale to their proportions on the 0 to 1 scale.
invprobit(quan)
invprobit(quan)
quan |
A numeric vector of probit quantiles. |
Simply calls pnorm(quan)
.
A numeric vector of proportions the same length as quan
.
invprobit(c(-3, -1, 0, 1, 3))
invprobit(c(-3, -1, 0, 1, 3))
Generate the index for eliminating values beyond a given maximum number of consecutive extremes allowed.
keeponly(x, extremes = c(0, 100), nconsec = 2)
keeponly(x, extremes = c(0, 100), nconsec = 2)
x |
A numeric vector, with no missing values. |
extremes |
A numeric vector of length two giving the boundary limits for |
nconsec |
An integer scalar, the maximum number of consecutive extreme values allowed, default 2. |
A logical vector for selecting all elements of x
without
exceeding nconsec
consecutive extreme values.
vec <- c(0, 0, 0, 4, 4, 4, 100, 100, 100, 100) vec[keeponly(vec)] # the original vector need not be ordered vec <- c(100, 4, 100, 4, 0, 100, 0, 4, 0, 100) keeponly(vec)
vec <- c(0, 0, 0, 4, 4, 4, 100, 100, 100, 100) vec[keeponly(vec)] # the original vector need not be ordered vec <- c(100, 4, 100, 4, 0, 100, 0, 4, 0, 100) keeponly(vec)
LW1949 is an automated approach to Litchfield and Wilcoxon's (1949) evaluation of dose-effect experiments. LW1949 was first introduced by Adams et al. (in preparation).
An example of how to use the functions in LW1949 is given in this
vignette
[link].
Use dataprep
to create a data frame with the results of a
dose-effect experiment.
Use fitLWauto
and LWestimate
to
fit dose-effect relations.
And use plotDELP
and plotDE
to plot the results.
U.S. Geological Survey (USGS) Computer Program LW1949 version 1.1.0.9000 Written by Jean V. Adams, USGS - Great Lakes Science Center glsc.usgs.gov, Ann Arbor, Michigan, USA. Written in programming language R (R Core Team, 2017, www.R-project.org), version 3.3.3 (2017-03-06). Run on a PC with Intel(R) Core(TM) I7-4600m CPU, 2.90 GHz processor, 16.0 GB RAM, and Microsoft Windows 7 Enterprise operating system 2009 Service Pack 1. Source code is available from Jean V. Adams on GitHub, github.com/JVAdams/LW1949, jvadams (at) usgs (dot) gov.
Disclaimer: Although this program has been used by the USGS, no warranty, expressed or implied, is made by the USGS or the United States Government as to the accuracy and functioning of the program and related program material nor shall the fact of distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith.
Adams, JV, KS Slaght, and MA Boogaard. 2016. An automated approach to Litchfield and Wilcoxon's evaluation of dose-effect experiments using the R package LW1949. Environmental Toxicology and Chemistry 35(12):3058-3061. DOI 10.1002/etc.3490. Adams, Jean V., Karen S. Slaght, and Michael A. Boogaard.",
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
Calculate the chi-squared statistic from observed and expected counts using the Litchfield and Wilcoxon (1949) approach.
LWchi2(obsn, expn, totn)
LWchi2(obsn, expn, totn)
obsn |
A numeric vector of observed counts. |
expn |
A numeric vector of expected counts, the same length as |
totn |
A numeric vector of total counts possible, the same length as |
The denominator of Litchfield and Wilcoxon's (1949) chi-squared estimate
is the minimum of the expn
and (totn
- expn
)
following their Nomograph No. 1. This ensures that the same chi-squared
value is calculated regardless of which proportion is reported (e.g.,
affected vs. not affected).
A list of length two.
The first element is a numeric vector of length three:
chistat
, chi-squared statistic;
df
, degrees of freedom; and
pval
, P value.
The second element is a numeric vector the same length as obsn
,
containing total contributions to the chi-squared. To get the
individual contributions to the chi-squared as reported in
Litchfield and Wilcoxon (1949), divide by totn
.
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
LWchi2(c(10, 8, 3), c(7, 7, 7), c(12, 12, 12))
LWchi2(c(10, 8, 3), c(7, 7, 7), c(12, 12, 12))
Generate Litchfield and Wilcoxon's (1949) estimates in the evaluation of dose-effect experiments.
LWestimate(estParams, DEdata)
LWestimate(estParams, DEdata)
estParams |
A numeric vector of length 2, the estimated parameters (intercept and
slope) of a straight line on the log10-probit scale, typically output
from |
DEdata |
A data frame of dose-effect data (typically, the output from
|
The input data are expected to be summarized by dose. If duplicate doses are provided, an error will be thrown.
A list of length three:
chi
= the chi-squared statistic with associated P value and
degrees of freedom,
params
= the estimated intercept and slope of the
dose-response curve on the log10 probit scale,
LWest
= the Litchfield Wilcoxon estimates of
ED50 with 95% confidence intervals and the number of records with
partial effects (npartfx) as well as other metrics used in their
step-by-step approach
(ED16, ED84, S with 95% confidence intervals, N', and fED50).
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) mydat intslope <- fitLWauto(mydat) LWestimate(intslope, mydat)
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) mydat intslope <- fitLWauto(mydat) LWestimate(intslope, mydat)
Recreate Litchfield and Wilcoxon's (1949) nomograph to estimate the contribution to the chi-squared from the expected percent effect and the observed minus the expected percent effect.
LWnomo1(values = FALSE, ...)
LWnomo1(values = FALSE, ...)
values |
A logical scalar indicating whether values should be output. |
... |
Additional parameters to |
Use the nomograph by laying a straight edge from the expected percent effect in the first scale to the observed (corrected, if necessary) minus the expected percent effect in the second scale and reading the point where the straight edge crosses the third scale as the contribution.
The formula behind the nomograph is (observed - expected)^2 / (100 * expected)
If values
is TRUE, a list of length four, with the x and y
coordinates and the corresponding values (all displayed in the log10
scale) of the end points of the three scales. Information is provided
twice for the first scale, once for the left tick marks and once for the
right tick marks.
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
LWnomo1()
LWnomo1()
User friendly evaluation of dose-effect experiments using automated Litchfield Wilcoxon (1949) and probit estimation methods. This function has been tailored for non-R users with input data set up in a particular way (see Details).
LWP(rawfile = NULL, descrcolz = 1:4, saveplots = TRUE, showplots = FALSE, saveresults = TRUE, showresults = TRUE, returnresults = FALSE)
LWP(rawfile = NULL, descrcolz = 1:4, saveplots = TRUE, showplots = FALSE, saveresults = TRUE, showresults = TRUE, returnresults = FALSE)
rawfile |
A character scalar specifying the path of the input data as a csv file. If NULL, default, the user will be prompted to browse to a file using a menu. |
descrcolz |
A numeric vector, the column numbers to use as the description of the test, default 1:4. |
saveplots |
A logical scalar indicating if plots should be saved to a pdf file, default TRUE. See details. |
showplots |
A logical scalar indicating if plots should be shown on screen, default FALSE. See details. |
saveresults |
A logical scalar indicating if results should be saved to a csv file, default TRUE. The csv file is given the same name (plus the suffix "Smry") and is placed in the same directory as the input file. |
showresults |
A logical scalar indicating if results should be printed to the console, default TRUE. These results include the chi-squared statistic, degrees of freedom, and p-value for the Litchfield Wilcoxon method. |
returnresults |
A logical scalar indicating if results should be returned by the function, default FALSE. |
The input data must include at least these seven columns, with these names in the header row:
Test ID
= A character or numeric vector,
the unique identifier for each test
Source
= A character vector, the source of the chemical
Batch
= A character or numeric vector, the batch of the
chemical
Species
= A character vector, the species tested
TFM Conc. (mg/L)
= A numeric vector, the concentration of
TFM in mg/L
No. Tested
= A numeric vector, the number of animals tested
No. Dead
= A numeric vector, the number of animals dead
The input data are expected to be summarized by dose. If duplicate doses are provided, an error will be thrown.
Both saveplots
and showplots
may be set to FALSE, in which
case no plots will be produced. But both may not be set to TRUE.
If returnresults=TRUE
, a data frame with 11 rows per test and
2 more columns than the input data. Three columns from the input data are
not included (TFM Conc. (mg/L)
, No. Tested
, and
No. Dead
). Five columns are added: the parameter (param
),
the method used (method
), the estimate (estimate
), and the
95% confidence interval of the estimate (lower95ci
and
upper95ci
)
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
## Not run: LWP() ## End(Not run)
## Not run: LWP() ## End(Not run)
Find the x and y coordinate corresponding to a specified point on a nomograph scale.
nomoCoord(df, val)
nomoCoord(df, val)
df |
A data frame with three columns, the |
val |
A numeric scalar identifying the point on the scale for which the coordinates will be returned. |
The function makes it easier to add points or lines to a nomograph for illustrative purposes.
Each scale is assumed to be displayed on the log10 scale.
A numeric vector of length two with the x and y coordinates of the specified point in plotting units of the nomograph.
scales <- LWnomo1(TRUE) fromxy <- nomoCoord(scales$scale1r, 34) toxy <- nomoCoord(scales$scale3, 16^2/(100*34)) segments(fromxy[1], fromxy[2], toxy[1], toxy[2], col="red")
scales <- LWnomo1(TRUE) fromxy <- nomoCoord(scales$scale1r, 34) toxy <- nomoCoord(scales$scale3, 16^2/(100*34)) segments(fromxy[1], fromxy[2], toxy[1], toxy[2], col="red")
Plot dose-effect experiments on the arithmetic scale.
plotDE(DEdata, xlab = "Dose", ylab = "Affected (%)", xlim = range(DEdata$dose, na.rm = TRUE), ylim = c(0, 100), ref = c(0, 50, 100), ...)
plotDE(DEdata, xlab = "Dose", ylab = "Affected (%)", xlim = range(DEdata$dose, na.rm = TRUE), ylim = c(0, 100), ref = c(0, 50, 100), ...)
DEdata |
A data frame of dose-effect data (typically, the output from
|
xlab |
A character scalar, the title for the dose (x) axis, default "Dose". |
ylab |
A character scalar, the title for the affected (y) axis, default "Affected (%)". |
xlim |
A numeric vector of length two giving the x coordinate range for dose, default range(DEdata$dose, na.rm=TRUE). |
ylim |
A numeric vector of length two giving the y coordinate range for affected (%), default c(0.1, 99.9). Observed effects beyond this range will be plotted at the limits of this range using an open symbol. |
ref |
A numeric vector specifying horizontal reference lines to be added to the plot, default c(0, 50, 100). |
... |
Additional arguments to |
predLines
, plotDELP
, predLinesLP
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDE(mydat)
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDE(mydat)
Plot dose-effect experiments on the log10-probit scale.
plotDELP(DEdata, xlab = "Dose", ylab = "Affected (%)", xlim = range(DEdata$dose[DEdata$dose > 0], na.rm = TRUE), ylim = c(0.1, 99.9), grid = TRUE, ...)
plotDELP(DEdata, xlab = "Dose", ylab = "Affected (%)", xlim = range(DEdata$dose[DEdata$dose > 0], na.rm = TRUE), ylim = c(0.1, 99.9), grid = TRUE, ...)
DEdata |
A data frame of dose-effect data (typically, the output from
|
xlab |
A character scalar, the title for the dose (x) axis, default "Dose". |
ylab |
A character scalar, the title for the affected (y) axis, default "Affected (%)". |
xlim |
A numeric vector of length two giving the x coordinate range for dose, default range(DEdata$dose, na.rm=TRUE). |
ylim |
A numeric vector of length two giving the y coordinate range for affected (%), default c(0.1, 99.9). Observed effects beyond this range will be plotted at the limits of this range using an open symbol. |
grid |
A logical scalar indicating if a background grid should be plotted, default TRUE. |
... |
Additional arguments to |
predLinesLP
, plotDE
, predLines
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDELP(mydat)
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDELP(mydat)
Determine the effective dose for a specified percent effect from the intercept and slope of a linear regression.
predlinear(pct, LWmod, simple = FALSE)
predlinear(pct, LWmod, simple = FALSE)
pct |
A numeric vector of effects (in percents) for which to estimate the effective dose(s). |
LWmod |
If |
simple |
A logical scalar indicating whether to carry out a simple estimation of effective doses from the intercept and slope (TRUE), or an estimation of effective doses with confidence intervals from the Litchfield and Wilcoxon model (default, FALSE). |
Follows methods outlined in Litchfield and Wilcoxon (1949). Specifically, for the 95% confidence intervals, see page 105, and equation 13 in the Appendix (corresponding to Nomograph 4).
If simple=TRUE
, a numeric vector the same length as pct
with
the estimated effective doses.
If simple=FALSE
, an n*4 numeric matrix with the given effects
(pct
), the effective doses (ED
), and Litchfield and
Wilcoxon's (1949) 95% confidence intervals for the effective doses
(lower
and upper
).
The number of rows of the matrix, n, is the length of pct
.
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
predlinear(c(16, 50, 84, 99.9), c(1.700875, 2.199559), simple=TRUE) dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) fLW <- LWestimate(fitLWauto(mydat), mydat) predlinear(c(25, 50, 99.9), fLW)
predlinear(c(16, 50, 84, 99.9), c(1.700875, 2.199559), simple=TRUE) dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) fLW <- LWestimate(fitLWauto(mydat), mydat) predlinear(c(25, 50, 99.9), fLW)
Add predictions from a Litchfield and Wilcoxon model fit to a plot of the results of a dose-effect experiment on the arithmetic scale.
predLines(fit, ...)
predLines(fit, ...)
fit |
A list of length three containing the result of a Litchfield and
Wilcoxon model fit, typically the output from |
... |
Additional arguments to |
A solid fitted line is added to the plot. Dashed lines are added to the plot representing the horizontal 95% confidence intervals for the predicted dose to elicit a given percent affected.
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDE(mydat) myfit <- LWestimate(fitLWauto(mydat), mydat) predLines(myfit)
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDE(mydat) myfit <- LWestimate(fitLWauto(mydat), mydat) predLines(myfit)
Add predictions from a Litchfield and Wilcoxon model fit to a plot of the results of a dose-effect experiment on the log10-probit scale.
predLinesLP(fit, ...)
predLinesLP(fit, ...)
fit |
A list of length three containing the result of a Litchfield and
Wilcoxon model fit, typically the output from |
... |
A solid fitted line is added to the plot. Dashed lines are added to the plot representing the horizontal 95% confidence intervals for the predicted dose to elicit a given percent affected.
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDELP(mydat) myfit <- LWestimate(fitLWauto(mydat), mydat) predLinesLP(myfit)
dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive <- c(1, 4, 4, 7, 8) mydat <- dataprep(dose=dose, ntot=ntested, nfx=nalive) plotDELP(mydat) myfit <- LWestimate(fitLWauto(mydat), mydat) predLinesLP(myfit)
Determine the effective dose for a specified percent effect from a fitted probit regression model.
predprobit(pct, pfit, alpha = 0.05, logbase = 10)
predprobit(pct, pfit, alpha = 0.05, logbase = 10)
pct |
A numeric scalar of the effect (as a percent) for which to estimate the effective dose. |
pfit |
An object of class |
alpha |
A numeric scalar, the significance level used to generate
100*(1 - |
logbase |
A numeric or logical scalar, the base of the log transformation used for
dose in |
A numeric vector of length three, the effective dose and the lower and
upper 100*(1 - alpha
)% confidence limits.
toxdat <- data.frame( dose=c(0.05, 0.0625, 0.125, 0.25, 0.5, 1), ntot=rep(8, 6), nfx = c(0, 1, 4, 4, 6, 8)) myfit <- fitprobit(toxdat) predprobit(50, myfit)
toxdat <- data.frame( dose=c(0.05, 0.0625, 0.125, 0.25, 0.5, 1), ntot=rep(8, 6), nfx = c(0, 1, 4, 4, 6, 8)) myfit <- fitprobit(toxdat) predprobit(50, myfit)
Compute a sequence of "round" values which cover the range of x
on
the log scale.
prettylog(x, lead = c(1, 5), extra = 5)
prettylog(x, lead = c(1, 5), extra = 5)
x |
A numeric vector. |
lead |
An integer vector giving the desired lead digits of pretty values on the log scale, default c(1, 5). |
extra |
An integer scalar giving the desired number of additional non-log scale values to include, default 5. |
A numeric vector of pretty values covering the range of x
on
the log scale.
vals <- rlnorm(100, 6) summary(vals) prettylog(vals, 1, 0) prettylog(vals, 1) prettylog(vals, c(1, 2, 5))
vals <- rlnorm(100, 6) summary(vals) prettylog(vals, 1, 0) prettylog(vals, 1) prettylog(vals, c(1, 2, 5))
Convert proportions to the probit scale.
probit(prob)
probit(prob)
prob |
A numeric vector of proportions. |
Simply calls qnorm(prob)
.
A numeric vector the same length as prob
with quantiles on
the probit scale.
probit(c(0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999))
probit(c(0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999))
Estimate of relative potency of two toxins using Litchfield and Wilcoxon's (1949) approach to evaluating dose-effect experiments.
relPotency(ED50nS1, ED50nS2, vec = FALSE)
relPotency(ED50nS1, ED50nS2, vec = FALSE)
ED50nS1 |
Either the list output from |
ED50nS2 |
Either the list output from |
vec |
A logical scalar indicating whether the inputs |
The ratios reported (both for slope and potency) have the first toxin in the numerator and the second toxin in the denominator, but the test results (both for parallelism and relative potency) are based on the ratios of the larger values over the smaller values.
No relative potency is estimated if the two dose-effect curves differ significantly from parallelism (with 95% confidence).
A list with two elements, SR
with three elements:
r
= a numeric vector of length three with the estimated
slope ratio with 95% confidence limits,
f
= a numeric scalar with the f of the slope ratio, and
parallel
= a logical scalar indicating whether the two
curves differ significantly from parallelism (FALSE).
and PR
with one (just difPotency
if parallel=FALSE
)
or three (if parallel=TRUE
) elements:
r
= a numeric vector of length three with the estimated
potency ratio with 95% confidence limits,
f
= a numeric scalar with the f of the potency ratio, and
difPotency
= a logical scalar indicating whether the two
toxins differ significantly in potency (FALSE).
Litchfield, JT Jr. and F Wilcoxon. 1949. A simplified method of evaluating dose-effect experiments. Journal of Pharmacology and Experimental Therapeutics 96(2):99-113. [link].
# Example starting from raw tox data dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive1 <- c(1, 4, 4, 7, 8) mydat1 <- dataprep(dose=dose, ntot=ntested, nfx=nalive1) nalive2 <- c(0, 1, 2, 6, 6) mydat2 <- dataprep(dose=dose, ntot=ntested, nfx=nalive2) fit1 <- LWestimate(fitLWauto(mydat1), mydat1) fit2 <- LWestimate(fitLWauto(mydat2), mydat2) relPotency(fit1, fit2) # Example from Litchfield and Wilcoxon (1949) # comparing Tagathen and Pyribenzamine relPotency(c(0.18, 1.72, 2.20, 1.60), c(0.60, 1.60, 2.34, 1.57), vec=TRUE) # Example in which curves differ significantly from parallelism. relPotency(c(0.18, 1.72, 2.20, 1.60), c(0.60, 1.60, 4.34, 1.57), vec=TRUE)
# Example starting from raw tox data dose <- c(0.0625, 0.125, 0.25, 0.5, 1) ntested <- rep(8, 5) nalive1 <- c(1, 4, 4, 7, 8) mydat1 <- dataprep(dose=dose, ntot=ntested, nfx=nalive1) nalive2 <- c(0, 1, 2, 6, 6) mydat2 <- dataprep(dose=dose, ntot=ntested, nfx=nalive2) fit1 <- LWestimate(fitLWauto(mydat1), mydat1) fit2 <- LWestimate(fitLWauto(mydat2), mydat2) relPotency(fit1, fit2) # Example from Litchfield and Wilcoxon (1949) # comparing Tagathen and Pyribenzamine relPotency(c(0.18, 1.72, 2.20, 1.60), c(0.60, 1.60, 2.34, 1.57), vec=TRUE) # Example in which curves differ significantly from parallelism. relPotency(c(0.18, 1.72, 2.20, 1.60), c(0.60, 1.60, 4.34, 1.57), vec=TRUE)