pcrfit {qpcR} | R Documentation |
This is the main workhorse function of the qpcR package that fits one of the available models to qPCR data using nonlinear least-squares fitting from nls
,
with sensible starting parameters obtained from either nls.lm
, optim
or genoud
.
pcrfit(data, cyc = 1, fluo, model = l4, do.optim = TRUE, opt.method = "LM", nls.method = "port", start = NULL, robust = FALSE, control = nls.control(), ...)
data |
the name of the dataframe containing the qPCR runs. |
cyc |
the column containing the cycle data. Defaults to 1. |
fluo |
the column containing the raw fluorescence data of the run. |
model |
the model to be used for the analysis. Defaults to l4. |
do.optim |
if FALSE , refinement of starting values by nls.lm , optim or nls.lm will be skipped. |
opt.method |
one of the available refinement methods. See 'Details'. |
nls.method |
one of the available methods in nls . Default is "port" , which works quite well. |
start |
a vector of starting values that can be supplied externally. |
robust |
logical. If TRUE , robust nonlinear regression is used. See 'Details'. |
control |
an optional list of control settings for nls or qpcR:::rnls . |
... |
other parameters to be passed to optim , genoud or nls . |
The fitting procedure works as follows (hopefully ensuring maximum safeness against convergence errors):
1) Approximate starting values are acquired from model$ssfct
.
2) Starting values are refined by any of the methods available in optim
, the genoud
method
from the 'rgenoud' package or the Levenberg-Marquardt algorithm (nls.lm
). The opt.method
s can be combined to tweak the robustness, whereby the starting parameters are passed to
each succeeding method, i.e. rep("Nelder", 5) will do 5 successive Nelder-Mead optimisations or c("GA", "Nelder") will pass the starting
values from "GA" to "Nelder". If problems arise, "GA" has shown to be very robust (but slow!) in the refinement of starting values.
Levenberg-Marquardt ("LM") is very fast and relatively reliable in many scenarios and is thus the default.
3) One of the possible methods from nls
is then applied with the starting values obtained from 2).
This function is to be used at the single run level. Otherwise use pcrbatch
or modlist
.
The output from the optim methods is checked by ensuring all eigenvalues from the hessian are positive, otherwise a notice will occur.
If robust = TRUE
, robust nonlinear fitting will be used. To do this, the internal function qpcR:::rnls
is called
which is a modification of the nlrob
function of the 'robustbase' package. Modifications were done such that all available generic functions
for objects of class 'nls' can be used on the output of qpcR:::rnls
, such as predict
, confint
etc.
A model of class 'nls' and 'pcrfit' with the following items attached:
DATA |
the initial data used for fitting. |
MODEL |
the model used for fitting. |
call2 |
the call to pcrfit . |
parMat |
the trace of the starting values for each applied method. Can be used to track problems. |
opt.method |
the parameter opt.method . |
Andrej-Nikolai Spiess
Bioassay analysis using R.
Ritz C & Streibig JC.
J Stat Soft (2005), 12: 1-22.
A Method for the Solution of Certain Problems in Least Squares.
K. Levenberg.
Quart Appl Math (1944), 2: 164-168.
An Algorithm for Least-Squares Estimation of Nonlinear Parameters.
D. Marquardt.
SIAM J Appl Math (19639), 11: 431-441.
## simple l4 fit of F1.1 of the 'reps' dataset pcrfit(reps, 1, 2, l4) ## same with five-parameter model ## use "GA" method for optim pcrfit(reps, 1, 2, l5, opt.method = "GA") ## using BFGS and Nelder from 'optim' pcrfit(reps, 1, 2, l5, opt.method = c("BFGS", "Nelder")) ## skip 'optim' method and supply ## own starting values pcrfit(reps, 1, 2, l4, do.optim = FALSE, start = c(-5, -0.05, 11, 16)) ## make a robust model pcrfit(reps, 1, 2, l4, robust = TRUE)