Title: | Fit Hill Dose Response Models |
---|---|
Description: | Evaluate, fit, and analyze Hill dose response models (Goutelle et al., 2008 <doi:10.1111/j.1472-8206.2008.00633.x>), also sometimes referred to as four-parameter log-logistic models. Includes tools to invert Hill models, select models based on the Akaike information criterion (Akaike, 1974 <doi:10.1109/TAC.1974.1100705>) or Bayesian information criterion (Schwarz, 1978 <https://www.jstor.org/stable/2958889>), and construct bootstrapped confidence intervals both on the Hill model parameters and values derived from the Hill model parameters. |
Authors: | Anang Shelat [aut], Nathaniel Twarog [aut, cre] |
Maintainer: | Nathaniel Twarog <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.0 |
Built: | 2025-02-13 03:41:13 UTC |
Source: | https://github.com/cran/basicdrm |
By bootsttrapping a large number of vectors, this function estimates confidence intervals on the paramters of the given Hill model. If the model already has confidence intervals estimated, they will be replaced with a warning
calcHillBootstrap(hfit, ciLevs = c(0.025, 0.975), numBoot = NULL)
calcHillBootstrap(hfit, ciLevs = c(0.025, 0.975), numBoot = NULL)
hfit |
An object of class |
ciLevs |
The lower and upper p-values for the estimated confidence interval. The default values, 0.025 and 0.975, produce a 95% confidence interval. |
numBoot |
The number of bootstrapped coefficients to be sampled. If
|
An object of class hillrm
, containing all the values found in any
hillrm
object (see fitHillModel()
) as well as the following three
values:
ciLevs
: the values used to set the bounds of the confidence intervals
ciCoefs
: a width-4 array of all bootstrapped Hill model coefficents
sampled by the function
ciMat
: a 2-by-4 array of values representing the estimated confidence
intervals on the four Hill model parameters
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) cihfit <- calcHillBootstrap(hfit)
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) cihfit <- calcHillBootstrap(hfit)
Given a function from Hill model parameters to one or more model properties,
this function produces a confidence interval on that value or those values
using the bootstrapped model coefficents produced by calcHillBootstrap()
.
This is useful for estimating confidence intervals on other values like
IC50, or generating confidence intervals on fitted values for plots.
calcHillConfInt(hfit, parfunc, civals = NULL)
calcHillConfInt(hfit, parfunc, civals = NULL)
hfit |
An object of class |
parfunc |
A function from a four parameter Hill model vector (see
|
civals |
An optional set of upper and lower bounds on the confidence
interval to be estimated. If |
An n-by-3 array, where n is the length of the vector produced by
parfunc
. The first row is the lower bound of the confidence interval,
the second row is the function evaluated at the best-fit Hill model, and the
third row is the upper bound of the confidence interval.
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) cihfit <- calcHillBootstrap(hfit) ic50_ci <- calcHillConfInt(cihfit,function(h) invertHillModel(50,h))
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) cihfit <- calcHillBootstrap(hfit) ic50_ci <- calcHillConfInt(cihfit,function(h) invertHillModel(50,h))
The area under the curve, or AUC, is a commonly used and robust metric for evaluating and comparing dose response models. The area is calculated in a log-concentration space, and so is dependent not only on the concentration bounds, but also on the base of the logarithm used. By default, this function follows the common convention of using base 10.
calculateHillAUC(hpar, range, baseline = 0, logbase = 10)
calculateHillAUC(hpar, range, baseline = 0, logbase = 10)
hpar |
A four parameter vector specifying the Hill model. Parameter
details are found in the documentation for |
range |
A two element vector specifying the lower and upper bound of area being calculated |
baseline |
The reference baseline response around which the area is being calculated. The default value of 0 is generally the most intuitive choice, but a value of 1 (or 100 in percent) could be used if the dose-response model is fitting relative survival. |
logbase |
The base of the logarithm applied to concentrations |
A single value specifying the area under the curve in the given range
auc <- calculateHillAUC(c(1,3,0,75), c(0.05,10)) # Area *over* the curve in survival studies aoc <- -calculateHillAUC(c(0.1,2,1,0.1), c(0.01,1), baseline=1)
auc <- calculateHillAUC(c(1,3,0,75), c(0.05,10)) # Area *over* the curve in survival studies aoc <- -calculateHillAUC(c(0.1,2,1,0.1), c(0.01,1), baseline=1)
Estimate Akaike Information Criterion
estimateAIC(resid, npar)
estimateAIC(resid, npar)
resid |
A vector of residuals from a given fit |
npar |
The number of paramters in the model |
The Akaike informtion criterion (AIC) value for the fit
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit4p <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) hfit3p <- fitHillModel(conc,response,c(1,2,4),start=c(0.5,1,0,100)) aic4p <- estimateAIC(residuals(hfit4p),4) aic3p <- estimateAIC(residuals(hfit3p),3)
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit4p <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) hfit3p <- fitHillModel(conc,response,c(1,2,4),start=c(0.5,1,0,100)) aic4p <- estimateAIC(residuals(hfit4p),4) aic3p <- estimateAIC(residuals(hfit3p),3)
Estimate Bayesian Information Criterion
estimateBIC(resid, npar)
estimateBIC(resid, npar)
resid |
A vector of residuals from a given fit |
npar |
The number of paramters in the model |
The Bayesian informtion criterion (BIC) value for the fit
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit4p <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) hfit3p <- fitHillModel(conc,response,c(1,2,4),start=c(0.5,1,0,100)) aic4p <- estimateBIC(residuals(hfit4p),4) aic3p <- estimateBIC(residuals(hfit3p),3)
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit4p <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) hfit3p <- fitHillModel(conc,response,c(1,2,4),start=c(0.5,1,0,100)) aic4p <- estimateBIC(residuals(hfit4p),4) aic3p <- estimateBIC(residuals(hfit3p),3)
Evaluate a Hill dose response model
evalHillModel(conc, hpar)
evalHillModel(conc, hpar)
conc |
A vector of concentrations (including 0 or Inf) |
hpar |
A four parameter vector specifying the Hill model. The values of the parameter vector are, in order, the dose of median effect (also often referred to as the EC50), the Hill slope, the minimal effect (observed when no drug or dose is present), and the maximal effect (theoretically observed when the drug or dose is infinite). |
A vector of response values the same length as conc
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,100) response <- evalHillModel(conc, hpar)
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,100) response <- evalHillModel(conc, hpar)
Using the function fitHillModel()
, this function fits four Hill models
with minimal and maximal effects either varying or fixed at the given
default values; it then selects the best fitting model based on the Bayesian
information criterio or Akaike information criterion, and returns a Hill fit
object with information from all fits included.
findBestHillModel( formula, data, defaults, weights = NULL, start = NULL, direction = 0, lower = NULL, upper = NULL, useBIC = TRUE )
findBestHillModel( formula, data, defaults, weights = NULL, start = NULL, direction = 0, lower = NULL, upper = NULL, useBIC = TRUE )
formula |
Either an object of class |
data |
If |
defaults |
A two value numeric vector containing the default minimal effect and the default maximal effect, in that order |
weights |
A vector of weights (between 0 and 1) the same length as
|
start |
A vector of four starting values for the Hill model to be fit.
Any values not being fit will be fixed at these starting values. If left as
|
direction |
Determines the possible directionality of the dose response model. If 0 (the default) no additional constraints are placed on the parameters. If greater than 0, the fitting will require that the maximal effect is greater than the minimal effect. If less than 0, the fitting wll require tha the maximal effect is less than the minimal effect. |
lower |
A length-four vector of lower bounds on the Hill parameter
values. Any parameters for which you do not wish to specify a bound can be
set to |
upper |
A vector of upper bounds on the Hill parameter values. Works
the same as parameter |
useBIC |
Determines the information criterion to be used. If |
An object of class hillrm
. Contains all of the values found in
any hillrm
object (see fitHillModel()
), as well as allfits
, a named
list of lists containing the coefficients
and par
vectors for each of the
individual fits, as well as the Bayesian information criterion (bic
) and
Akaike informtion criterion (aic
) values for each fit.
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit <- findBestHillModel(conc,response,defaults=c(0,100))
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) hfit <- findBestHillModel(conc,response,defaults=c(0,100))
This function uses the R stats
function optim
to fit a Hill dose
response model to a given set of dose and response values. Four different
model settings are allowed, in which the minimal and maximal effects are
either fixed at a provided value or allowed to be fit to the data.
fitHillModel( formula, data, model, weights = NULL, start = NULL, direction = 0, lower = NULL, upper = NULL )
fitHillModel( formula, data, model, weights = NULL, start = NULL, direction = 0, lower = NULL, upper = NULL )
formula |
Either an object of class |
data |
If |
model |
A vector of values between 1 and 4, specifying the precise
model to be fit. The values correspond to the four parameters of the Hill
model: dose of median effect, Hill slope, minimal effect, and maximal effect
(see |
weights |
A vector of weights (between 0 and 1) the same length as
|
start |
A vector of four starting values for the Hill model to be fit.
Any values not being fit will be fixed at these starting values. If left as
|
direction |
Determines the possible directionality of the dose response model. If 0 (the default) no additional constraints are placed on the parameters. If greater than 0, the fitting will require that the maximal effect is greater than the minimal effect. If less than 0, the fitting wll require tha the maximal effect is less than the minimal effect. |
lower |
A vector of lower bounds on the Hill parameter values. Can be
the same length as |
upper |
A vector of upper bounds on the Hill parameter values. Works
the same as parameter |
An object of class hillrm
, containing the following values:
conc
: the given vector of concentraitons
act
: the given vector of responses
weights
: the vector of measurement weights used in minimizing the sum
of squared errors
coefficients
: the full four-parameter Hill parameter vector (accessible
by the function coef()
)
par
: the vector of paramters that were actually fit
fitted.values
: the predicted responses of the best fit model (accessible
by the functoin fitted()
)
residuals
: the difference between the actual responses and the predicted
responses (accessible by the function residuals()
)
model
: the vector of values between 1 and 4 specifying the precise model
that was fit
mname
: a character string naming the precise model that was fit. One of
"m2p", "m3plc", "m3puc", or "m4p"
start
: a four-value parameter vector used as the starting value for the
model fit
direction
: the direction constraint used in the fit
pbounds
: a two-by-four matrix of values specifying the lower and upper
bounds used in the fit
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) data <- data.frame(conc=conc,response=response,weight=c(0.5,rep(1,10),0.1)) hfit <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) hfit2 <- fitHillModel(response~conc,data,c(1,2,4),weight,start=c(0.5,1,0,100), direction=0,lower=c(NA,NA,0,0))
conc <- c(0,2^(-6:3),Inf) hpar <- c(1,3,0,75) response <- evalHillModel(conc, hpar) + rnorm(length(conc),sd=7.5) data <- data.frame(conc=conc,response=response,weight=c(0.5,rep(1,10),0.1)) hfit <- fitHillModel(conc,response,c(1,2,3,4),start=c(0.5,1,0,100)) hfit2 <- fitHillModel(response~conc,data,c(1,2,4),weight,start=c(0.5,1,0,100), direction=0,lower=c(NA,NA,0,0))
This funciton takes one or more desired response values and determines the doses that will produce the desired effects given a particular Hill dose response model. This is useful for estimating things like IC50.
invertHillModel(effect, hpar, invalidNA = FALSE)
invertHillModel(effect, hpar, invalidNA = FALSE)
effect |
A vector of desired response values |
hpar |
A four parameter vector specifying the Hill model. Parameter
details are found in the documentation for |
invalidNA |
Specifies what to do with values that are outside the range
of the given Hill model. If |
A vector of concentrations the same length as effect
.
invertHillModel(0.5, c(1,2,0,0.7)) invertHillModel(seq(0.1,0.9,by=0.1), c(0.1,4,0,0.65), invalidNA=TRUE)
invertHillModel(0.5, c(1,2,0,0.7)) invertHillModel(seq(0.1,0.9,by=0.1), c(0.1,4,0,0.65), invalidNA=TRUE)