Code for CI for model averaged abundance

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Code for CI for model averaged abundance

Postby jCeradini » Fri Jun 24, 2022 8:44 pm

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!
jCeradini
 
Posts: 72
Joined: Mon Oct 13, 2014 3:53 pm

Re: Code for CI for model averaged abundance

Postby jhines » Fri Jun 24, 2022 9:06 pm

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) )
jhines
 
Posts: 599
Joined: Fri May 16, 2003 9:24 am
Location: Laurel, MD, USA

Re: Code for CI for model averaged abundance

Postby jCeradini » Fri Jun 24, 2022 9:47 pm

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
jCeradini
 
Posts: 72
Joined: Mon Oct 13, 2014 3:53 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 11 guests