-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(sort of) fixed priors with multiple covariates. #1
Open
acannistra
wants to merge
26
commits into
HuckleyLab:master
Choose a base branch
from
acannistra:fixing-priors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been trying for a while to figure out why the code that was written to give priors on multiple environmental covariates wasn't working, and I think I figured it out today. The purpose of this pull request is to detail what went wrong, and to start a conversation about how we might fix it. I think we should wait to merge this PR until we get a better idea of how to use multiple environmental covariates as priors.
The Problem
When I downloaded this code for the first time, we had functions
e.max
ande.min
defined asThen, later, the prior function was:
I was stuck on this, because nothing looked terribly wrong. From the GRaF documentation, the documentation for the
prior
parameter states that it isI opened an issue on the GrAF repo (goldingn/GRaF#13) to see if Nick had advice, and he told me that the prior returns a single probability of presence for each set of environmental covariates, rather than an estimate of presence based on a single covariate. This is where our function went awry. Instead of an N element vector (a (N,1) shaped-matrix), we were returning an (N,3) shaped matrix using
cbind
.The "Solution"
To temporarily fix this problem (without a good understanding of what
e.min
ande.max
are actually trying to accomplish), I simply multiplied (66d0c55#diff-9b16e6b217254fc15823def0d4289364R195) the result ofe.min
ande.max
together, attempting a conditional probability. To my dismay, this didn't solve the problem. The following error still occurred:Several days later (today, 3/27), I discovered that the problem lies in the downstream
qnorm
function, which is defined asInf
forqnorm(1)
andNaN
forqnorm(0)
. This means that the prior can seemingly never have values of exactly 1 or exactly 0.Looking above at
e.min
ande.max
, they are defined exactly this way, with 0 and 1. I altered them (66d0c55#diff-9b16e6b217254fc15823def0d4289364R190) to have 0.1 and 0.8 as thresholds instead, and the code works.Next Steps
The issue here is that I'm not at all sure whether multiplying the result of
e.min
ande.max
makes any sense. However, this work shows that the prior has to be within 0 and 1, inclusive, and it must consume a dataframe with N rows and all environmental covariates and produce an N-length, 1-dimensional vector with the probability of presence given those covariates. That's some progress.