Hi,
Thanks for your prompt response and for the provided code.
The function appears to run, and I am able to reproduce the figure above with no problem.
By my calculations, my ESW for the overall model is: mu = W * Pa = 800 * 0.41 = 331.43 metres.
I would therefore expect my ESW in lower sea states to be greater than this and vice versa in higher sea states.
However, when I substitute in my model intercept, scale coefficients and shape coefficient, even at a Sea State of zero, my ESW is only 217 metres with the ESW reduced to 58 metres at a Sea State of 5.
Additionally, the functions appear to have a much smaller shoulder compared to the original model. I thought I understood which values needed replacing (please see attached) but now I am less sure.
If you’re able to provide any confirmation or correction regarding this, then I’d be very grateful.
I have attached the output figure provided by yours and Tiago’s code as well as the shape of the original model and my edited code, in case it is of any help in diagnosing my mistake.
Thank you in advance.
Best,
Tim
beaustates <- c("State 0","State 1", "State 2", "State 3", "State4")
beaucoeff <- c(0, -0.3979885, -0.5518057, -0.8339985, -1.3146111)
esw <- vector(mode="numeric", length=length(beaustates))
for (i in 1:length(beaustates)) {
esw[i] <- integrate(gz, 0, 800,
beta=.4260557, sigintercept = 5.4885488, sigcoef = beaucoeff[i], DistWin=FALSE)$value
if(i==1) {
plot(seq(0,800),
gz(beta=0.4142978, sigintercept = 5.4885488, sigcoef = beaucoeff[i], z=seq(0,800), DistWin=FALSE),
lwd=3, type="l", col=i, main="Det fns by sea state", xlab="Distance", ylab="Detection probability")
} else {
lines(seq(0,800),
gz(beta=.4260557, sigintercept = 5.4885488, sigcoef = beaucoeff[i], z=seq(0,800), DistWin=FALSE),
lwd=3, type="l", col=i)
}
}
msg <- paste(beaustates, title="Estimated ESW", round(esw, 1))
legend("topright", legend=msg, lwd=2, col=1:5)