nls function settling the port algorithm is used.fit_LMCurve(values, values.bg, n.components=3, start_values,input.dataType="LM",
main="Default", sample_code="",sample_ID="",
LED.power=36, LED.wavelength=470,
log_scale="",cex.global=0.8,
fit.trace=FALSE,
fit.advanced=FALSE,
fit.calcError=FALSE,
bg.subtraction="polynomial",
output.path,
output.terminal=TRUE, output.terminaladvanced=TRUE,
output.plot=TRUE, output.plotBG=FALSE
)polynomial,
linear, channel, see Details). Note: input for values.bg isoutput.terminal=TRUE.
If output.terminal=FALSE no advanced output is possible.output.path is set.list objectnls object ($fit) for that generic methods are provided
e.g. summary, confint, profile for more details see nls.
(b) a data.frame containing the summarized parameters including the
error ($output.table).The function for the fitting has the general form : $$y = exp(0.5)*Im_1*x/xm_1)*exp(-x^2/(2*xm_1^2)) + ,\ldots, + exp(0.5)*Im_i*x/xm_i)*exp(-x^2/(2*xm_i^2))$$ where $1>= i <= 7$="" this="" function="" and="" the="" equations="" for="" conversion="" to="" b="" (detrapping="" probability)="" n0="" (initial="" intensity)="" have="" been="" taken="" from="" kittis="" et="" al.="" (2008):<="" p="">
$$xm_i=\sqrt{max(t)/b_i}$$ $$Im_i=exp(-0.5)n0/xm_i$$ background subtraction
Three methods for background subtraction are provided for a given background signal (values.bg).
polynomial: default method. A polynomial function is fitted using glm: and the resulting function
is used for the background subtraction:
$$y = a*x^4 + b*x^3 + c*x^2 + d*x + e$$
linear: a linear function is fitted using glm: and the resulting function
is used for the background subtraction:
$$y = a*x + b$$
channel: the background is subtracted channel by channel.
start values
The choice of the initial parameters for the nls-fitting is a crucial point and the fitting procedure may mainly fail due to ill chosen start parameters. Here two options are provided:
(a) If no start values (start_values) are provided by the user a cheap guess is tried by using
the detrapping values found by Jain et al. (2003) for quartz for a maximum of 7 components. Based
on this values the pseudo start parameters xm and Im have been recalculated for the given data set.
In all cases the fitting starts with the ultra-fast component and (deppending on n.components)
steps several times through the following values. If no fit could be achieved an error plot
(for output.plot=TRUE) with the pseudo curve (based on the pseudo start parameters) are provided.
This may give the opportunity to search for the start parameters graphically.
(b) If start values are prodided the function works like a simple nls fitting approach.
(c) If no start parameters have been provided and the option fit.advanced==TRUE has been chosen an
advanced start paramter estimation is applied using a stochastical attempt. Therefore the recalculated start parameters (a)
are used to contruct a normal disribution. The start parameters are then sampled randomly from this distribution.
A maximum of 100 attempts will be made. Note: This process may be really time consuming.
goodness of fit
The goodness of the fit is given by a pseudo-R^2 value (pseudo coefficient of determination). According to Lave (1970) the value is calculated as:
$$pseudoR^2 = 1 - RSS/TSS$$ where $RSS = Resdiual~Sum~of~Squares$ and $TSS = Total~Sum~of~Squares$
error of fitted component parameters
The 1-sigma error for the components is calculated using the function confint. Due to the needed calculation time this option is deactived by default. In addition the error for the components can be further estimated by using the internal R functions like summary. See the nls help page for more information.
For more details on the nonlinear regression in R see Ritz, C., Streibig, J.C. (2008).
=>Jain, M., Murray, A.S., Boetter-Jensen, L. (2003). Characterisation of blue-light stimulated luminescence components in different quartz samples: implications for dose measurement. Radiation Measurements, 37 (4-5), 441-449.
Kitis, G., Pagonis, V. (2008). Computerized curve deconvolution analysis for LM-OSL. Radiation Measurements, 43, 737-741.
Lave, C.A.T. (1970). The Demand for Urban Mass Transportation. The Review of Economics and Statistics, 52 (3), 320-323.
Ritz, C., Streibig, J.C. (2008). Nonlinear Regression with R. 1-150.
plot,nls##(1) fit LM data without background subtraction
data(ExampleData.FittingLM)
fit_LMCurve(values=values.curve,n.components=3,log_scale="x")
##==================================================##
##(2) fit LM data with background subtraction and export as JPEG
## -alter file path for your prefered system
##jpeg(file="~/Desktop/Fit_Output\%03d.jpg", quality=100,
## height=3000, width=3000,res=300)
data(ExampleData.FittingLM)
fit_LMCurve(values=values.curve, values.bg=values.curveBG,
n.components=2,log_scale="x", output.plotBG=TRUE)
##dev.off()
##==================================================##
##(3) fit LM data with manual start parameters
data(ExampleData.FittingLM)
fit_LMCurve(values=values.curve, values.bg=values.curveBG, n.components=3,log_scale="x",
start_values=data.frame(Im=c(170,25,400),xm=c(56,200,1500)))Run the code above in your browser using DataLab