aboutsummaryrefslogtreecommitdiff
path: root/inst
diff options
context:
space:
mode:
authorranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4>2006-05-11 15:53:07 +0000
committerranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4>2006-05-11 15:53:07 +0000
commit6d118690c0cae02fc5cd4b28c1a67eecde4d9f60 (patch)
tree8f923f7623604f78bd5a7228d413fdd2f0971010 /inst
parent513dfbdcdda94a901b5901b486ff5500c7d158b1 (diff)
- The vignette is in a publisheable state
- In addition to the Massart examples, the sample data from dintest (DIN 32645) has been tested - inverse.predict and calplot now also work on glm objects git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/chemCal@7 5fad18fb-23f0-0310-ab10-e59a3bee62b4
Diffstat (limited to 'inst')
-rw-r--r--inst/doc/Makefile12
-rw-r--r--inst/doc/chemCal-001.pdf4
-rw-r--r--inst/doc/chemCal.Rnw31
-rw-r--r--inst/doc/chemCal.aux1
-rw-r--r--inst/doc/chemCal.log83
-rw-r--r--inst/doc/chemCal.pdfbin105421 -> 107614 bytes
-rw-r--r--inst/doc/chemCal.tex127
7 files changed, 193 insertions, 65 deletions
diff --git a/inst/doc/Makefile b/inst/doc/Makefile
index 637b193..26fe678 100644
--- a/inst/doc/Makefile
+++ b/inst/doc/Makefile
@@ -1,6 +1,6 @@
# Makefile for Sweave documents containing both Latex and R code
# Author: Johannes Ranke <jranke@uni-bremen.de>
-# Last Change: 2006 Mai 10
+# Last Change: 2006 Mai 11
# based on the Makefile of Nicholas Lewin-Koh
# in turn based on work of Rouben Rostmaian
# SVN: $Id: Makefile.rnoweb 50 2006-04-18 11:13:52Z ranke $
@@ -14,14 +14,8 @@ TARGETS = $(patsubst %.Rnw,%.tex,$(RNWFILE)) $(patsubst %.Rnw,%.pdf,$(RNWFILES))
%.pdf: %.tex
pdflatex $<
-all: all-recursive $(TARGETS)
+all: $(TARGETS)
-clean: clean-recursive
+clean:
rm -f *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg \
*.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff
-
-all-recursive:
- for dir in $(wildcard *); do if [ -d $$dir ] && [ -f $$dir/Makefile ]; then cd $$dir; $(MAKE) all; cd ..; fi; done
-
-clean-recursive:
- for dir in $(wildcard *); do if [ -d $$dir ] && [ -f $$dir/Makefile ]; then cd $$dir; $(MAKE) clean; cd ..; fi; done
diff --git a/inst/doc/chemCal-001.pdf b/inst/doc/chemCal-001.pdf
index e5c8f5f..6e2f9b8 100644
--- a/inst/doc/chemCal-001.pdf
+++ b/inst/doc/chemCal-001.pdf
@@ -2,8 +2,8 @@
%ρ\r
1 0 obj
<<
-/CreationDate (D:20060510174125)
-/ModDate (D:20060510174125)
+/CreationDate (D:20060511175039)
+/ModDate (D:20060511175039)
/Title (R Graphics Output)
/Producer (R 2.3.0)
/Creator (R)
diff --git a/inst/doc/chemCal.Rnw b/inst/doc/chemCal.Rnw
index 2c902ab..26b224f 100644
--- a/inst/doc/chemCal.Rnw
+++ b/inst/doc/chemCal.Rnw
@@ -20,7 +20,7 @@ inverse prediction method given in \cite{massart97} would be implemented,
since it also covers the case of weighted regression.
At the moment, the package only consists of two functions, working
-on univariate linear models of class \texttt{lm}.
+on univariate linear models of class \texttt{lm} or \texttt{rlm}.
When calibrating an analytical method, the first task is to generate
a suitable model. If we want to use the \chemCal{} functions, we
@@ -59,9 +59,9 @@ given by the user in the case of weighted regression. By default,
the mean of the weights used in the linear regression is used.
\section*{Theory}
-Equation 8.28 in \cite{massart97} gives a general equation for predicting x
-from measurements of y according to the linear calibration function
-$ y = b_0 + b_1 \cdot x$:
+Equation 8.28 in \cite{massart97} gives a general equation for predicting the
+standard error $s_{\hat{x_s}}$ for an x value predicted from measurements of y
+according to the linear calibration function $ y = b_0 + b_1 \cdot x$:
\begin{equation}
s_{\hat{x_s}} = \frac{s_e}{b_1} \sqrt{\frac{1}{w_s m} + \frac{1}{\sum{w_i}} +
@@ -72,9 +72,30 @@ s_{\hat{x_s}} = \frac{s_e}{b_1} \sqrt{\frac{1}{w_s m} + \frac{1}{\sum{w_i}} +
with
\begin{equation}
-s_e = \sqrt{ \frac{\sum w_i (y_i - \hat{y})^2}{n - 2}}
+s_e = \sqrt{ \frac{\sum w_i (y_i - \hat{y_i})^2}{n - 2}}
\end{equation}
+where $w_i$ is the weight for calibration standard $i$, $y_i$ is the mean $y$
+value (!) observed for standard $i$, $\hat{y_i}$ is the estimated value for
+standard $i$, $n$ is the number calibration standards, $w_s$ is the weight
+attributed to the sample $s$, $m$ is the number of replicate measurements of
+sample $s$, $\bar{y_s}$ is the mean response for the sample,
+$\bar{y_w} = \frac{\sum{w_i y_i}}{\sum{w_i}}$ is the weighted mean of responses
+$y_i$, and $x_i$ is the given $x$ value for standard $i$.
+
+The weight $w_s$ for the sample should be estimated or calculated in accordance
+to the weights used in the linear regression.
+
+I adjusted the above equation in order to be able to take a different precisions
+in standards and samples into account. In analogy to Equation 8.26 from \cite{massart97}
+we get
+
+\begin{equation}
+s_{\hat{x_s}} = \frac{1}{b_1} \sqrt{\frac{{s_s}^2}{w_s m} +
+ {s_e}^2 \left( \frac{1}{\sum{w_i}} +
+ \frac{(\bar{y_s} - \bar{y_w})^2 \sum{w_i}}
+ {{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}
\begin{thebibliography}{1}
\bibitem{massart97}
diff --git a/inst/doc/chemCal.aux b/inst/doc/chemCal.aux
index 0eb51cc..20bfc98 100644
--- a/inst/doc/chemCal.aux
+++ b/inst/doc/chemCal.aux
@@ -14,4 +14,5 @@
\citation{massart97}
\citation{massart97}
\citation{massart97}
+\citation{massart97}
\bibcite{massart97}{1}
diff --git a/inst/doc/chemCal.log b/inst/doc/chemCal.log
index fadbc89..805f382 100644
--- a/inst/doc/chemCal.log
+++ b/inst/doc/chemCal.log
@@ -1,4 +1,4 @@
-This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=pdflatex 2006.4.5) 10 MAY 2006 17:41
+This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=pdflatex 2006.4.5) 11 MAY 2006 17:50
entering extended mode
**chemCal.tex
(./chemCal.tex
@@ -129,7 +129,7 @@ Style option: `fancyvrb' v2.6, with DG/SPQR fixes <1998/07/17> (tvz)
\FV@OutFile=\write4
No file fancyvrb.cfg.
-) (/usr/share/texmf-tetex/tex/latex/upquote/upquote.sty
+) (/usr/share/R/share/texmf/upquote.sty
Package: upquote 2003/08/11 v1.1 Covington's upright-quote modification to verb
atim and verb
@@ -301,64 +301,49 @@ LaTeX Font Info: Try loading font information for T1+aett on input line 16.
(/usr/share/texmf-tetex/tex/latex/ae/t1aett.fd
File: t1aett.fd 1997/11/16 Font definitions for T1/aett.
)
-
-LaTeX Warning: Citation `massart97' on page 1 undefined on input line 20.
-
<chemCal-001.pdf, id=7, 433.62pt x 433.62pt>
File: chemCal-001.pdf Graphic file (type pdf)
<use chemCal-001.pdf> [1
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
-
-LaTeX Warning: Citation `massart97' on page 2 undefined on input line 50.
-
LaTeX Font Info: Try loading font information for TS1+aett on input line 65.
-LaTeX Font Info: No file TS1aett.fd. on input line 65.
-
-LaTeX Font Warning: Font shape `TS1/aett/m/n' undefined
-(Font) using `TS1/cmr/m/n' instead
-(Font) for symbol `textasciigrave' on input line 65.
-
-
-LaTeX Warning: Citation `massart97' on page 2 undefined on input line 81.
+ (/usr/share/R/share/texmf/ts1aett.fd
+File: ts1aett.fd
+)
+LaTeX Font Info: Try loading font information for TS1+cmtt on input line 65.
+ (/usr/share/texmf-tetex/tex/latex/base/ts1cmtt.fd
+File: ts1cmtt.fd 1999/05/25 v2.5h Standard LaTeX font definitions
+)
+LaTeX Font Info: Font shape `TS1/aett/m/n' in size <10> not available
+(Font) Font shape `TS1/cmtt/m/n' tried instead on input line 65.
LaTeX Font Info: External font `cmex10' loaded for size
-(Font) <7> on input line 83.
+(Font) <7> on input line 82.
LaTeX Font Info: External font `cmex10' loaded for size
-(Font) <5> on input line 83.
-[2 <./chemCal-001.pdf>] [3] (./chemCal.aux)
-
-LaTeX Font Warning: Some font shapes were not available, defaults substituted.
-
-
-LaTeX Warning: There were undefined references.
-
-
-LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
-
- )
+(Font) <5> on input line 82.
+ [2 <./chemCal-001.pdf>]
+[3] (./chemCal.aux) )
Here is how much of TeX's memory you used:
- 3752 strings out of 94499
- 51374 string characters out of 1175814
- 95260 words of memory out of 1000000
- 6850 multiletter control sequences out of 10000+50000
- 24598 words of font info for 57 fonts, out of 500000 for 2000
+ 3764 strings out of 94499
+ 51832 string characters out of 1175814
+ 96290 words of memory out of 1000000
+ 6863 multiletter control sequences out of 10000+50000
+ 21774 words of font info for 52 fonts, out of 500000 for 2000
580 hyphenation exceptions out of 8191
- 35i,6n,21p,255b,255s stack positions out of 1500i,500n,5000p,200000b,5000s
+ 35i,7n,21p,255b,273s stack positions out of 1500i,500n,5000p,200000b,5000s
PDF statistics:
- 70 PDF objects out of 300000
- 9 named destinations out of 131072
+ 72 PDF objects out of 300000
+ 10 named destinations out of 131072
22 words of extra memory for PDF output out of 65536
-</usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmex10.pfb></usr/share/texmf-t
-etex/fonts/type1/bluesky/cm/cmmi5.pfb></usr/share/texmf-tetex/fonts/type1/blues
-ky/cm/cmmi7.pfb></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmsy10.pfb></usr
-/share/texmf-tetex/fonts/type1/bluesky/cm/cmr7.pfb></usr/share/texmf-tetex/font
-s/type1/bluesky/cm/cmmi10.pfb></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cm
-bx12.pfb> </var/cache/fonts/pk/ljfour/jknappen/tc/tcrm1000.600pk></usr/share/te
-xmf-tetex/fonts/type1/bluesky/cm/cmsltt10.pfb></usr/share/texmf-tetex/fonts/typ
-e1/bluesky/cm/cmbx10.pfb></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmtt10.
-pfb></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmr10.pfb></usr/share/texmf-
-tetex/fonts/type1/bluesky/cm/cmr12.pfb></usr/share/texmf-tetex/fonts/type1/blue
-sky/cm/cmr17.pfb>
-Output written on chemCal.pdf (3 pages, 105421 bytes).
+</usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmex10.pfb>
+</usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmsy10.pfb></usr/share/texmf-tet
+ex/fonts/type1/bluesky/cm/cmmi5.pfb></usr/share/texmf-tetex/fonts/type1/bluesky
+/cm/cmmi7.pfb></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmr7.pfb></usr/sha
+re/texmf-tetex/fonts/type1/bluesky/cm/cmmi10.pfb></usr/share/texmf-tetex/fonts/
+type1/bluesky/cm/cmbx12.pfb> </var/cache/fonts/pk/ljfour/jknappen/tc/tctt1000.6
+00pk></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmsltt10.pfb></usr/share/te
+xmf-tetex/fonts/type1/bluesky/cm/cmtt10.pfb></usr/share/texmf-tetex/fonts/type1
+/bluesky/cm/cmr10.pfb></usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmr12.pfb>
+</usr/share/texmf-tetex/fonts/type1/bluesky/cm/cmr17.pfb>
+Output written on chemCal.pdf (3 pages, 107614 bytes).
diff --git a/inst/doc/chemCal.pdf b/inst/doc/chemCal.pdf
index b0da323..e3c6a8c 100644
--- a/inst/doc/chemCal.pdf
+++ b/inst/doc/chemCal.pdf
Binary files differ
diff --git a/inst/doc/chemCal.tex b/inst/doc/chemCal.tex
new file mode 100644
index 0000000..a4b4459
--- /dev/null
+++ b/inst/doc/chemCal.tex
@@ -0,0 +1,127 @@
+\documentclass[a4paper]{article}
+%\VignetteIndexEntry{Short manual for the chemCal package}
+\newcommand{\chemCal}{{\tt chemCal}}
+\newcommand{\calplot}{{\tt calplot}}
+\newcommand{\calpredict}{{\tt calpredict}}
+\newcommand{\R}{{\tt R}}
+\usepackage{hyperref}
+
+\title{Basic calibration functions for analytical chemistry}
+\author{Johannes Ranke}
+
+\usepackage{/usr/share/R/share/texmf/Sweave}
+\begin{document}
+\maketitle
+
+The \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 could be heavily improved if the
+inverse prediction method given in \cite{massart97} would be implemented,
+since it also covers the case of weighted regression.
+
+At the moment, the package only consists of two functions, working
+on univariate linear models of class \texttt{lm} or \texttt{rlm}.
+
+When calibrating an analytical method, the first task is to generate
+a suitable model. If we want to use the \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:
+
+\begin{Schunk}
+\begin{Sinput}
+> library(chemCal)
+> data(massart97ex3)
+> attach(massart97ex3)
+> yx <- split(y, factor(x))
+> ybar <- sapply(yx, mean)
+> s <- round(sapply(yx, sd), digits = 2)
+> w <- round(1/(s^2), digits = 3)
+> weights <- w[factor(x)]
+> m <- lm(y ~ x, w = weights)
+> calplot(m)
+\end{Sinput}
+\end{Schunk}
+\includegraphics{chemCal-001}
+
+This is a reproduction of Example 8 in \cite{massart97}. We can
+see the influence of the weighted regression on the confidence
+and prediction bands of the calibration.
+
+If we now want to predict a new x value from measured y values,
+we use the \texttt{inverse.predict} function:
+
+\begin{Schunk}
+\begin{Sinput}
+> inverse.predict(m, 15, ws = 1.67)
+\end{Sinput}
+\begin{Soutput}
+$Prediction
+[1] 5.865367
+
+$`Standard Error`
+[1] 10.66054
+
+$Confidence
+[1] 29.59840
+
+$`Confidence Limits`
+[1] -23.73303 35.46376
+\end{Soutput}
+\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.
+
+\section*{Theory}
+Equation 8.28 in \cite{massart97} gives a general equation for predicting the
+standard error $s_{\hat{x_s}}$ for an x value predicted from measurements of y
+according to the linear calibration function $ y = b_0 + b_1 \cdot x$:
+
+\begin{equation}
+s_{\hat{x_s}} = \frac{s_e}{b_1} \sqrt{\frac{1}{w_s m} + \frac{1}{\sum{w_i}} +
+ \frac{(\bar{y_s} - \bar{y_w})^2 \sum{w_i}}
+ {{b_1}^2 \left( \sum{w_i} \sum{w_i {x_i}^2} - {\left( \sum{ w_i x_i } \right)}^2 \right) }}
+\end{equation}
+
+with
+
+\begin{equation}
+s_e = \sqrt{ \frac{\sum w_i (y_i - \hat{y_i})^2}{n - 2}}
+\end{equation}
+
+where $w_i$ is the weight for calibration standard $i$, $y_i$ is the mean $y$
+value (!) observed for standard $i$, $\hat{y_i}$ is the estimated value for
+standard $i$, $n$ is the number calibration standards, $w_s$ is the weight
+attributed to the sample $s$, $m$ is the number of replicate measurements of
+sample $s$, $\bar{y_s}$ is the mean response for the sample,
+$\bar{y_w} = \frac{\sum{w_i y_i}}{\sum{w_i}}$ is the weighted mean of responses
+$y_i$, and $x_i$ is the given $x$ value for standard $i$.
+
+The weight $w_s$ for the sample should be estimated or calculated in accordance
+to the weights used in the linear regression.
+
+I adjusted the above equation in order to be able to take a different precisions
+in standards and samples into account. In analogy to Equation 8.26 from \cite{massart97}
+we get
+
+\begin{equation}
+s_{\hat{x_s}} = \frac{1}{b_1} \sqrt{\frac{{s_s}^2}{w_s m} +
+ {s_e}^2 \left( \frac{1}{\sum{w_i}} +
+ \frac{(\bar{y_s} - \bar{y_w})^2 \sum{w_i}}
+ {{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}
+
+\begin{thebibliography}{1}
+\bibitem{massart97}
+Massart, L.M, Vandenginste, B.G.M., Buydens, L.M.C., De Jong, S., Lewi, P.J.,
+Smeyers-Verbeke, J.
+\newblock Handbook of Chemometrics and Qualimetrics: Part A,
+\newblock Elsevier, Amsterdam, 1997
+\end{thebibliography}
+
+\end{document}

Contact - Imprint