rbchan / unmarked

R package for hierarchical models in ecological research
https://rbchan.github.io/unmarked/
36 stars 25 forks source link

Bug in `fitted` for Dail-Madsen models with `dynamics="gompertz"` #278

Closed kenkellner closed 6 months ago

kenkellner commented 6 months ago

@rbchan

This line

https://github.com/rbchan/unmarked/blob/5b2b00e6cb1befc8a1bb73b1607968e7f014b0c3/R/unmarkedFit.R#L621

Should be

N[i,t] <- ...

right? And also L636 a little further down.

kenkellner commented 6 months ago

There's also a bug here

https://github.com/rbchan/unmarked/blob/5b2b00e6cb1befc8a1bb73b1607968e7f014b0c3/R/unmarkedFit.R#L584

Where omega is N x T-1 and lambda is N x 1 and so their sizes are incompatible. I assume lambda is supposed to multiply each column of omega.

rbchan commented 6 months ago

@rbchan

This line

https://github.com/rbchan/unmarked/blob/5b2b00e6cb1befc8a1bb73b1607968e7f014b0c3/R/unmarkedFit.R#L621

Should be

N[i,t] <- ...

right? And also L636 a little further down.

Yes, I think you're right. Pretty sure Jeff Hostetler @falafelbot wrote most of the stuff related to the gompertz model.

rbchan commented 6 months ago

There's also a bug here

https://github.com/rbchan/unmarked/blob/5b2b00e6cb1befc8a1bb73b1607968e7f014b0c3/R/unmarkedFit.R#L584

Where omega is N x T-1 and lambda is N x 1 and so their sizes are incompatible. I assume lambda is supposed to multiply each column of omega.

Shouldn't this work because of R's recycling rules? At least if lambda is a vector (and not a matrix)? Let me know if you can't figure it out, and I can try to dig deeper.

kenkellner commented 6 months ago

Shouldn't this work because of R's recycling rules? At least if lambda is a vector (and not a matrix)? Let me know if you can't figure it out, and I can try to dig deeper.

Yes, but as you say lambda is a matrix (because it's the output of a matrix multiplication). Looking at it again I think it's supposed to be recycled, so just need to drop.

falafelbot commented 6 months ago

I'd agree. Not sure how that 1 slipped in.

Jeff

From: Richard Chandler @.> Sent: Monday, April 1, 2024 9:27 AM To: rbchan/unmarked @.> Cc: Hostetler, Jeffrey A @.>; Mention @.> Subject: [EXTERNAL] Re: [rbchan/unmarked] Bug in fitted for Dail-Madsen models with dynamics="gompertz" (Issue #278)

This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.

@rbchanhttps://github.com/rbchan

This line

https://github.com/rbchan/unmarked/blob/5b2b00e6cb1befc8a1bb73b1607968e7f014b0c3/R/unmarkedFit.R#L621

Should be

N[i,t] <- ...

right? And also L636 a little further down.

Yes, I think you're right. Pretty sure Jeff Hostetler @falafelbothttps://github.com/falafelbot wrote most of the stuff related to the gompertz model.

- Reply to this email directly, view it on GitHubhttps://github.com/rbchan/unmarked/issues/278#issuecomment-2029758058, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAJRLOEAJDQZLPIOPN5CBRTY3FOCLAVCNFSM6AAAAABFOR4MGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRZG42TQMBVHA. You are receiving this because you were mentioned.Message ID: @.***>