Chapter 5 - Analytical Sciences Digital Library
Chapter 5 - Analytical Sciences Digital Library
Chapter 5 - Analytical Sciences Digital Library
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
196 <strong>Analytical</strong> Chemistry 2.0<br />
> inverse.predict(model, sample, alpha = 0.05)<br />
$Prediction<br />
[1] 0.2412597<br />
$`Standard Error`<br />
[1] 0.002363588<br />
$Confidence<br />
[1] 0.006562373<br />
Figure 5.24 Output from R’s command for predicting the analyte’s<br />
concentration, C A , from the sample’s signal, S samp .<br />
$`Confidence Limits`<br />
[1] 0.2346974 0.2478221<br />
You may have noticed that this way of<br />
defining weights is different than that<br />
shown in equation 5.28. In deriving equations<br />
for a weighted linear regression, you<br />
can choose to normalize the sum of the<br />
weights to equal the number of points, or<br />
you can choose not to—the algorithm in<br />
R does not normalize the weights.<br />
Practice Exercise 5.7<br />
Use Excel to complete the<br />
regression analysis in Practice<br />
Exercise 5.4.<br />
Click here to review your answer<br />
to this exercise.<br />
Let’s use this command to complete Example 5.12. First, we need to create<br />
an object containing the weights, which in R are the reciprocals of the standard<br />
deviations in y, (s y i )–2 . Using the data from Example 5.12, we enter<br />
> syi=c(0.02, 0.02, 0.07, 0.13, 0.22, 0.33)<br />
> w=1/syi^2<br />
to create the object containing the weights. The commands<br />
> modelw = lm(signal ~ conc, weights = w)<br />
> summary(modelw)<br />
generate the output shown in Figure 5.25. Any difference between the<br />
results shown here and the results shown in Example 5.12 are the result of<br />
round-off errors in our earlier calculations.<br />
> modelw=lm(signal~conc, weights = w)<br />
> summary(modelw)<br />
Call:<br />
lm(formula = signal ~ conc, weights = w)<br />
Residuals:<br />
1 2 3 4 5 6<br />
-2.223 2.571 3.676 -7.129 -1.413 -2.864<br />
Figure 5.25 The summary of R’s regression analysis for<br />
a weighted linear regression. The types of information<br />
shown here is identical to that for the unweighted linear<br />
regression in Figure 5.22.<br />
Coefficients:<br />
Estimate Std. Error t value Pr(>|t|)<br />
(Intercept) 0.04446 0.08542 0.52 0.63<br />
conc 122.64111 0.93590 131.04 2.03e-08 ***<br />
---<br />
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1<br />
Residual standard error: 4.639 on 4 degrees of freedom<br />
Multiple R-Squared: 0.9998, Adjusted R-squared: 0.9997<br />
F-statistic: 1.717e+04 on 1 and 4 DF, p-value: 2.034e-08