From 9e0dae397df8c18e7333d2604cae96b2a7927420 Mon Sep 17 00:00:00 2001 From: ranke Date: Fri, 23 Jun 2006 15:33:27 +0000 Subject: - inverse.predict now has a var.s argument instead of the never tested ss argument. This is documented in the updated vignette - loq() now has w.loq and var.loq arguments, and stops with a message if neither are specified and the model has weights. - calplot doesn't stop any more for weighted regression models, but only refrains from drawing prediction bands - Added method = "din" to lod(), now that I actually have it (DIN 32645) and was able to see which approximation is used therein. - removed the demos, as the examples and tests are already partially duplicated - The vignette is more of a collection of various notes, but should certainly be helpful for the user. - Version bump to 0.1-xxx git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/chemCal@16 5fad18fb-23f0-0310-ab10-e59a3bee62b4 --- inst/doc/chemCal.tex | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'inst/doc/chemCal.tex') diff --git a/inst/doc/chemCal.tex b/inst/doc/chemCal.tex index e26172f..0469848 100644 --- a/inst/doc/chemCal.tex +++ b/inst/doc/chemCal.tex @@ -9,15 +9,29 @@ \begin{document} \maketitle -When calibrating an analytical method, the first task is to generate -a suitable model. If we want to use the \texttt{chemCal} functions, we -will have to restrict ourselves to univariate, possibly weighted -\footnote{ -For the weighted case, the function \texttt{predict.lm} would have to be -adapted (Bug report PR\#8877), in order to allow for weights for the x values -used to predict the y values. This affects the functions \texttt{calplot} -and \texttt{lod}. -}, linear regression so far. +The \texttt{chemCal} package was first designed in the course of a lecture and lab +course on "analytics of organic trace contaminants" at the University of Bremen +from October to December 2004. In the fall 2005, an email exchange with +Ron Wehrens led to the belief that it would be desirable to implement the +inverse prediction method given in \cite{massart97} since it also covers the +case of weighted regression. Studies of the IUPAC orange book and of DIN 32645 +as well as publications by Currie and the Analytical Method Committee of the +Royal Society of Chemistry and a nice paper by Castillo and Castells provided +further understanding of the matter. + +At the moment, the package consists of four functions, working on univariate +linear models of class \texttt{lm} or \texttt{rlm}, plus to datasets for +validation. + +A \href{http://bugs.r-project.org/cgi-bin/R/wishlst-fulfilled?id=8877;user=guest}{bug +report (PR\#8877)} and the following e-mail exchange on the r-devel mailing list about +prediction intervals from weighted regression entailed some further studies +on this subject. However, I did not encounter any proof or explanation of the +formula cited below yet, so I can't really confirm that Massart's method is correct. + +When calibrating an analytical method, the first task is to generate a suitable +model. If we want to use the \texttt{chemCal} functions, we will have to restrict +ourselves to univariate, possibly weighted, linear regression so far. Once such a model has been created, the calibration can be graphically shown by using the \texttt{calplot} function: @@ -26,8 +40,7 @@ shown by using the \texttt{calplot} function: \begin{Sinput} > library(chemCal) > data(massart97ex3) -> attach(massart97ex3) -> m0 <- lm(y ~ x) +> m0 <- lm(y ~ x, data = massart97ex3) > calplot(m0) \end{Sinput} \end{Schunk} @@ -49,6 +62,7 @@ is proposed which can be reproduced by \begin{Schunk} \begin{Sinput} +> attach(massart97ex3) > yx <- split(y, x) > ybar <- sapply(yx, mean) > s <- round(sapply(yx, sd), digits = 2) @@ -58,9 +72,6 @@ is proposed which can be reproduced by \end{Sinput} \end{Schunk} -Unfortunately, \texttt{calplot} does not work on weighted linear models, -as noted in the footnote above. - If we now want to predict a new x value from measured y values, we use the \texttt{inverse.predict} function: @@ -100,8 +111,8 @@ $`Confidence Limits` \end{Schunk} The weight \texttt{ws} assigned to the measured y value has to be -given by the user in the case of weighted regression. By default, -the mean of the weights used in the linear regression is used. +given by the user in the case of weighted regression, or alternatively, +the approximate variance \texttt{var.s} at this location. \section*{Theory for \texttt{inverse.predict}} Equation 8.28 in \cite{massart97} gives a general equation for predicting the @@ -143,6 +154,10 @@ s_{\hat{x_s}} = \frac{1}{b_1} \sqrt{\frac{{s_s}^2}{w_s m} + {{b_1}^2 \left( \sum{w_i} \sum{w_i {x_i}^2} - {\left( \sum{ w_i x_i } \right)}^2 \right) } \right) } \end{equation} +where I interpret $\frac{{s_s}^2}{w_s}$ as an estimator of the variance at location +$\hat{x_s}$, which can be replaced by a user-specified value using the argument +\texttt{var.s} of the function \texttt{inverse.predict}. + \begin{thebibliography}{1} \bibitem{massart97} Massart, L.M, Vandenginste, B.G.M., Buydens, L.M.C., De Jong, S., Lewi, P.J., -- cgit v1.2.1