nlsLM of the 'minpack.lm' package.pcrfit(data, cyc = 1, fluo, model = l4, start = NULL,
offset = 0, weights = NULL, verbose = TRUE, ...)MAK methods. See 'Details' and 'Example'.data containing possible weights for the nonlinear fit, or an expression to calculate weights from. See 'Details'.TRUE, fitting and convergence results will be displayed in the console.nlsLM.pcrfit."LM".pcrfit. It is a much simpler implementation containing only the LM-Algorithm for fitting, but this fitting routine has proven to be so robust that other optimization routines (such as in optim) could safely be removed. The fitting is done with the new nlsLM function of the 'minpack.lm' package, which gives a model of class 'nls' as output.
This function is to be used at the single run level or on replicates (by giving several columns). The latter will build a single model based on the replicate values. If many models should be built on a cohort of replicates, use modlist and replist.
The offset value defines the offset cycles from the second derivative maximum that is used as a cut-off criterion in the MAK methods. See 'Examples'.
Since version 1.3-7, an expression given as a character string can be supplied to the weights argument.
This expression, which is transferred to qpcR:::wfct, defines how the vector of weights is calculated from the data. In principle, five different parameters can be used to define weights:
"x" relates to the cycles $x_i$,
"y" relates to the raw fluorescence values $y_i$,
"error" relates to the error $\sigma(y_{i, j})$ of replicates $j$,
"fitted" relates to the fitted values $\hat{y}_i$ of the fit,
"resid" relates to the residuals $y_i - \hat{y}_i$ of the fit.
For "fitted" and "resid", the model is fit unweighted by pcrfit, the fitted/residual values extracted and these subsequently used for refitting the model with weights.
These parameters can be used solely or combined to create a weights vector for different regimes. The most commonly used are (see also 'Examples'):
Inverse of response (raw fluorescence) $\frac{1}{y_i}$: "1/y"
Square root of predictor (Cycles) $\sqrt{x_i}$: "sqrt(x)"
Inverse square of fitted values: $\frac{1}{\hat{y}^2_i}$: "1/fitted^2"
Inverse variance $\frac{1}{\sigma^2(y_{i, j})}$: "1/error^2"## simple l4 fit of F1.1 of the 'reps' dataset
m1 <- pcrfit(reps, 1, 2, l4)
plot(m1)
## supply own starting values
pcrfit(reps, 1, 2, l4, start = c(-5, -0.05, 11, 16))
## make a replicate model,
## use inverse variance as weights
m2 <- pcrfit(reps, 1, 2:5, l5, weights = "1/error^2")
plot(m2)
## fit a mechanistic 'mak2' model
## to -1 cycle from SDM
m3 <- pcrfit(reps, 1, 2, mak2, offset = -1)
plot(m3)Run the code above in your browser using DataLab