Notes on Chapter 8

Back to notes on chapter 7

• p. 266 I have changed the behavior of profile (called by confint) so that it now returns the better-fitting parameter values as a vector — this simplifies putting them back in as new starting conditions etc.
``````prop[prop<=0] = minprop
prop[prop>=1] = 1-minprop```
```

you could say
````prop = pmin(pmax(prob,1-minprop),minprop)`
```

(slightly more efficient, albeit harder to understand): pmax is "parallel maximum" (substitute the maximum of the two vectors at each element), pmin is the same for minimum.
• p. 274 (Figure 8.4): the predicted peak in proportion eaten occurs (by Murphy's Law?) right in the middle of the gap in the data. If we were following up this experiment, it would be really nice to try some tadpoles with body sizes between 12 and 20 mm …
• p. 276 As noted on p. 251, the goby data are in the emdbookx package, which is not as easily available as the rest of the codes and data from the book: contact me if you want the data.
• p. 279 Here's an example using the formula interface to do the same problem. I define a dicweib function that takes either a vector or a two-column matrix with the first and last day(s) observed and computes the interval-censored Weibull likelihood, then use it to do the calculation.
``````dicweib <- function(x,shape,scale,log=FALSE) {
if (is.matrix(x)) {
day1 <- x[,1]
day2 <- x[,2]
} else {
day1 <- x[1]
day2 <- x[2]
}
v <- log(pweibull(day2,shape,scale)-pweibull(day1,shape,scale))
if (log) v else exp(v)
}
attach(GobySurvival)
on.exit(detach(GobySurvival))
totmeansurv = mean((d1+d2)/2)
day1 = d1-1
day2 = ifelse(d2==70,Inf,d2-1)

fexper <- factor(exper)
mle2(cbind(day1,day2)~dicweib(exp(shape),exp(scale)),
parameters=list(scale~fexper+qual*density),
start=list(scale=log(totmeansurv),shape=0))```
```
• p. 283: I should really do a Bayesian/WinBUGS example of all of this …
• p. 291: I need to write a predict method for mle!
• p. 294: it would be nice to put a hierarchical model here that handled the species as random effects drawn from a distribution.
• pp. 293-294: the line breaks in the code are ugly. Oh well.

On to notes on chapter 9

page revision: 4, last edited: 06 Mar 2010 16:42