Page 1 of 1

Code for CI for model averaged abundance

PostPosted: Fri Jun 24, 2022 8:44 pm
by jCeradini
Hi all.

Surely someone is going to make embarrassingly quick work of this. I'm trying to estimate confidence intervals for model averaged abundance estimates in R using the formula outlined in the Gentle MARK book: 14.10.1, 14-48 (http://www.phidot.org/software/mark/doc ... chap14.pdf). I'm likely just not interpreting the formula correctly (not my strong suite) and thus implementing the wrong thing in R. My attempts in Excel didn't succeed either (and the goal is in R).

Screenshot of formula:
https://drive.google.com/file/d/138eUSOhmpDf6SF30K7oBZEqfilWwADdE/view?usp=sharing

I am not able to match the value for C given in the example.
Correct C = 2.845
My C = 1.321641

Code: Select all
# Values given in MARK book example
var.uncond <- 31.867
f0 <- 9.839

# My attempt in one line
exp(1.96*(log(1 + (var.uncond / f0^2)))^1/2) # default log is ln
# 1.321641

# Step by step in hopes of reducing error (same result)
step1 <- 1 + (var.uncond / f0^2)
step2 <- log(step1) # default is ln
step3 <- step2^1/2
step4 <- step3 * 1.96
exp(step4)
# 1.321641


Thanks!

Re: Code for CI for model averaged abundance

PostPosted: Fri Jun 24, 2022 9:06 pm
by jhines
You need parentheses around the 1/2. Exponentiation takes precedence over division, so your equation raises step2 to the power of 1, then divides it by 2. The equation should be:

exp(1.96*(log(1 + (var.uncond / f0^2)))^(1/2) )

Re: Code for CI for model averaged abundance

PostPosted: Fri Jun 24, 2022 9:47 pm
by jCeradini
Aaaahhhh, thanks!!

I was a fool to mess with that fraction exponent in the first place, shoulda gone with decimal (should have thought to test that in my step by step version...). But, at least I learned more about coding and order of operations :D. Thanks!

Code: Select all
exp(1.96*(log(1 + (var.uncond / f0^2)))^0.5)
#2.844979