B.K. Sandercock wrote:I downloaded the updated Appendix B - thanks for posting. Anybody else doing this, note that you have to click the link for the PDF and then click Reload to get the new version, otherwise you might just retrieve the old version out of your cache.
You should have an add-on for Firefox or Chrome that does this automatically anyway (i.e., clears your cache when you turn off your browser). Not only does this save you the hassle of not knowing if you have the most current version of something, but it is a 'best practice' for basic security.
The var-covar matrix on B-22 has the updated numbers, but the beta coefficients on B-20 are still the old numbers.
Yeah, but close enough. I had rather assumed people would not use the values written in the book - which are rounded to make the formatting reasonable - but would actually run the analysis, and cut-and-paste everything from their output, ensuring full precision. I see what Brett is trying to do - kindly provide a script with all the numbers so that people using it don't have to do any work at all. Well, given that Brett is being so kind, I suggest he take it one step further, run the analysis himself, and copy and paste the estimates (betas, VC) into his script.
Moreover, be advised that the numbers you get might differ >5th decimal place, depending on the optimization algorithm you use, and whether you're running 32- or 64-bit MARK. I occasionally flip back and forth between the default procedures, and simulated annealing. Depending on the problem, you might notice the numbers differ somewhat, especially for the VC matrix. Generally these differences aren't large enough to be important to the final result.
Here is an R script with the revised numbers.
# Revised numbers
# Page B-20 Example 4 variance of back-transformed estimates - a bit harder still
# phihat = exp(-1*(int+beta1+beta2))/(1+exp(-1*(int+beta1+beta2)))
mass = 110; mass.mean = 109.97; mass.SD = 24.79
mass2 = mass^2; mass2.mean = 12707.46; mass2.SD = 5532.03
mass.z = (mass - mass.mean)/mass.SD; mass2.z = (mass2 - mass2.mean)/mass2.SD
par.name = c("int", "beta1", "beta2")
par.mean = c(int= 0.2567333, beta1=1.1750545*mass.z, beta2=-1.0555046*mass2.z)
par.varcovar = matrix(c(0.0009006961, -0.0004109935, 0.0003662581,
-0.0004109935, 0.0373907263, -0.0364270112,
0.0003662581, -0.0364270112, 0.0362796588), nrow = 3, byrow = T)
(phihat=plogis(as.numeric(sum(par.mean))))
(phihat.var = deltavar(exp(-1*(int+beta1+beta2))/(1+exp(-1*(int+beta1+beta2))), meanval=par.mean, vars=par.name, Sigma=par.varcovar))
(phihat.SE = sqrt(phihat.var))
# check answers, mass=110, phihat=0.5925, var(phihat) = 0.00007387, SE(phihat) = 0.00860
# check answers, mass=120, phihat=(not given), var(phihat) = 0.000074214, SE(phihat) = 0.008615
Unfortunately, the function still gives slightly different answers versus Appendix B.
phihat
[1] 0.5924384
phihat.var
[1] 9.488934e-05
phihat.SE
[1] 0.009741116
I'll follow Evan's advice and try the calculations in a different platform like Matlab. Thanks for the help with trouble-shooting.
Brett.
Thats a waste of time, and implies that I have it wrong somehow. I don't. Two different CAS give *exactly* the result reported by MARK. I could run it in MATLAB, or Octave, or Derive, or SciPy, but that would be redundant verging on silly. I would bet significant sums of $$$ they'd give 'exactly' the same answer.
Basically, it comes down to this -- if you have all the right values (betas, VC matrix), and are sure your script is right, then Bolker's function has a problem. Suggesting otherwise implies that not only is MARK wrong, but very high-end CAS environments.