Skip to content
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

check out math and maybe try changing initial values for ubermini_2.stan #12

Closed
lizzieinvancouver opened this issue Nov 6, 2020 · 6 comments
Assignees

Comments

@lizzieinvancouver
Copy link
Owner

See ubermini_2.R. This relates also to this issue and and OSPREE issue 388 where we can NEVER get the model out of initial value issues. If much preferred you can play with code there (see ../phylogeny/compare_ospreedat_ubermini_2.R).

See 'Cholesky Factors of Covariance Matrices' in the Stan manual)

And one maybe or maybe not useful post from Stan Discourse:

"..it is not really a bug, just a numerical problem. You could also do init_r = some number less than the default of 2." here

@FaithJones to keep us cross-referenced!

@lizzieinvancouver
Copy link
Owner Author

@legault Hello! I'd like to roll this rock a little further down its path this week -- any updates on this?

@legault
Copy link
Collaborator

legault commented Nov 19, 2020

See commit e6fabd5 for a fix to the vcv function, sig2, and adding a prior to sigma_y. This addresses some of the modeling issues such that we now correctly infer the parameter values in ubermini_2.R

The Cholesky decomp may no longer be necessary.

@lizzieinvancouver
Copy link
Owner Author

@legault Thanks for this, but the issue wasn't about the vcv, are you sure it was wrong? Can you provide a little more details on what was wrong (and thus what you fixed here)? I'd like to understand and it's not so clear what errors you found in the math from your notes and the commit.

@legault
Copy link
Collaborator

legault commented Nov 20, 2020

I shouldn't have said "fix" as all I did was re-specify things using sigma instead variance (in vcv). Commit d85d59e has some additional changes, notably the addition of a function that sets initial values which avoid the numerical issues we've been seeing.

@lizzieinvancouver
Copy link
Owner Author

@legault's commit mentioned above seems to have solved the initial conditions issue. Yay!

@lizzieinvancouver
Copy link
Owner Author

A few more notes what happened here (from an email from @legault on 20 Nov 2020):

  • I rewrote the vcv function so that it uses standard deviation instead of variance. I didn't make the connection that sig2 meant sigma ^ 2 (i.e., variance). I also rewrote the function so that it creates the covariance matrix using the associated variance matrix and correlation matrix as opposed to multiplying a matrix by a constant (they're equivalent though, apparently).
    -- Interestingly, the newer version seems to be more efficient (i.e., fewer iterations to obtain a good set of samples). I don't know why exactly but it might be a numerical issue (e.g., easier to work with x than it is to work with x^2)

  • I added a prior for sigma_y in the model block

I will likely revert the changes to keep things organized as before. From working with the previous version, I can't tell what the problem is. Is there an issue beyond the messages that pop up during initialization? The estimates seem ok if you run things long enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants