diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2018-07-17 17:29:14 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2018-07-17 17:38:29 +0200 |
commit | 280d36230052de4f94e384648c1283031fbc9840 (patch) | |
tree | df0ba9e07386b593cc396b8b6976210d42ee1a46 /vignettes/chemCal.R | |
parent | e636c17f0d354a8e74546fc1469431dbe502dc76 (diff) |
Fix inverse predictions for replicate measurements
For details, see NEWS.md
Diffstat (limited to 'vignettes/chemCal.R')
-rw-r--r-- | vignettes/chemCal.R | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/vignettes/chemCal.R b/vignettes/chemCal.R index 701db7b..d9015e9 100644 --- a/vignettes/chemCal.R +++ b/vignettes/chemCal.R @@ -1,36 +1,23 @@ -### R code from vignette source '/home/jranke/git/chemCal/vignettes/chemCal.Rnw' - -################################################### -### code chunk number 1: chemCal.Rnw:38-42 -################################################### +## ------------------------------------------------------------------------ library(chemCal) -data(massart97ex3) m0 <- lm(y ~ x, data = massart97ex3) calplot(m0) +## ------------------------------------------------------------------------ +plot(m0, which=3) -################################################### -### code chunk number 2: chemCal.Rnw:49-50 -################################################### -plot(m0,which=3) - +## ---- message = FALSE, echo = TRUE--------------------------------------- +weights <- with(massart97ex3, { + yx <- split(y, x) + ybar <- sapply(yx, mean) + s <- round(sapply(yx, sd), digits = 2) + w <- round(1 / (s^2), digits = 3) +}) +massart97ex3.means <- aggregate(y ~ x, massart97ex3, mean) -################################################### -### code chunk number 3: chemCal.Rnw:56-63 -################################################### -attach(massart97ex3) -yx <- split(y, 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) +m <- lm(y ~ x, w = weights, data = massart97ex3.means) - -################################################### -### code chunk number 4: chemCal.Rnw:69-71 -################################################### +## ------------------------------------------------------------------------ inverse.predict(m, 15, ws=1.67) inverse.predict(m, 90, ws = 0.145) - |