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

logkappa init and bounds #300

Open
kellijohnson-NOAA opened this issue Apr 9, 2021 · 10 comments
Open

logkappa init and bounds #300

kellijohnson-NOAA opened this issue Apr 9, 2021 · 10 comments

Comments

@kellijohnson-NOAA
Copy link

Starting with version VAST_v1_6_0 ...

Return = list("ln_H_input"=c(0,0), "beta1_ct"=NA, "gamma1_j"=rep(0,ncol(DataList$X_xj)), "gamma1_ctp"=array(0,dim=c(DataList$n_c,DataList$n_t,DataList$n_p)), "lambda1_k"=rep(0,ncol(DataList$Q_ik)), "L1_z"=NA, "L_omega1_z"=NA, "L_epsilon1_z"=NA, "logkappa1"=log(0.9), "Beta_mean1"=0, "logsigmaB1"=log(1), "Beta_rho1"=0, "Epsilon_rho1"=0, "eta1_vf"=NA, "Omegainput1_sf"=NA, "Epsiloninput1_sft"=NA, "beta2_ct"=NA, "gamma2_j"=rep(0,ncol(DataList$X_xj)), "gamma2_ctp"=array(0,dim=c(DataList$n_c,DataList$n_t,DataList$n_p)), "lambda2_k"=rep(0,ncol(DataList$Q_ik)), "L2_z"=NA, "L_omega2_z"=NA, "L_epsilon2_z"=NA, "logkappa2"=log(0.9), "Beta_mean2"=0, "logsigmaB2"=log(1), "Beta_rho2"=0, "Epsilon_rho2"=0, "logSigmaM"=rep(1,DataList$n_c)%o%c(log(5),log(2),log(1)), "eta2_vf"=NA, "Omegainput2_sf"=NA, "Epsiloninput2_sft"=NA )
I see that the initial value for logkappa is log(0.9) where before it was 0.0.

I am trying to fit models to data from the US West Coast within the US EEZ and I am getting the following error

Check bounds for the following parameters:
       Param starting_value     Lower        MLE      Upper final_gradient
42 logkappa2     -0.1053605 -6.061506 -0.8317317 -0.8317317     -0.1577178

Can you please point me to documentation on why the bounds are being set in this way and why the init value is log(0.9) for recent versions? The model fits if I enter the function and increase the upper bound but I am not sure if this is something that I actually should be doing and I wanted to ask if we should think about the init value being outside of the default bounds because of the distances that are being calculated. Thank you for any guidance that you can provide.

@James-Thorson-NOAA
Copy link
Owner

yeah, logkappa is translated into Range ( = distance with 13% correlations for an isotropic model). If Range is greater than the maximum distance among knots, or less than minimum distance, then the model typically loses the gradient for logkappa. I therefore use those bounds and back-translate to logkappa.

kappa is technically the decorrelation rate (decrease in correlation per unit distance). So logkappa hitting upper bound is equivalent to a fast decorrelation. This can sometimes be solved by increasing the number of knots, so that knots are closer together, which automatically results in a higher upper bound.

happy to keep chatting on this thread and definitely curious to hear what you conclude! Feel free to email me directly if that's easier.

@kellijohnson-NOAA
Copy link
Author

Thanks Jim, this was exactly what I needed. Changing the number of knots led to the bounds changing and the warning went away. I often start the number of knots at a small number to ensure that things are "working" prior to running a full model. Though, when I changed the upper bound here to Inf, the model did not converge. IMO it would be nice to allow users to change these bounds in a more simple way than entering the function via a browser call; not sure how easy that would be to code though.

@James-Thorson-NOAA
Copy link
Owner

James-Thorson-NOAA commented Apr 9, 2021 via email

@kellijohnson-NOAA
Copy link
Author

kellijohnson-NOAA commented Apr 9, 2021 via email

@Jason-Conner-NOAA
Copy link

Hi all,
In Modsquad, we have run into bounds issues with kappa as well, for some crab runs and for Pacific cod numeric abundance. Is there a way to set the initial bounds for kappa specifically in fit_model(), rather than relaxing all bounds using optimize_args? I am working through optimizing P. cod numbers for the eastern and northern Bering Sea, with the cold pool covariate, at 750 knots and ran into the upper bound for logkappa1 at -1.819147.

Thanks!

@James-Thorson-NOAA
Copy link
Owner

its not super-easy to change individual bounds using the high-level interface, without running it twice. If you don't mind running it twice, you can do:

fit_orig = fit_model( ..., build_model=FALSE )
Lower = fit$tmb_list$Lower
# Change some bounds in Lower using grep(.) etc.
fit = fit_model( ..., Lower=Lower )

does that make sense?

@Jason-Conner-NOAA
Copy link

Yeah, that's great. Thanks Jim!

@HaikunXu
Copy link

HaikunXu commented Nov 8, 2021

Hi Jim,

I tried what you suggested here "fit = fit_model( ..., build_model=FALSE )" to change parameter bounds. But I did not find fit$tmb_list$Lower; fit$tmb_list only includes Map, Data, Parameters, and Random. FYI, I am using version 3.8.0. Thank you in advance.

@James-Thorson-NOAA
Copy link
Owner

Please try with fit = fit_model( ..., run_model=FALSE ) instead

kellijohnson-NOAA added a commit to pfmc-assessments/indexwc that referenced this issue May 20, 2022
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.
@Blevy2
Copy link

Blevy2 commented Jun 15, 2022

Hi everyone,

As a quick follow up, I was also trying the above method to change the lower bound for logkappa and I think that it needs to be entered as lower case in the fit_model call. It took some time to figure that out so I thought I would mention it here.

So that would be

fit_orig = fit_model( ..., run_model=FALSE )
Lower = fit$tmb_list$Lower
# Change some bounds in Lower using grep(.) etc.
fit = fit_model( ..., lower=Lower )

lower=Lower is the small difference

Ben

seananderson pushed a commit to pfmc-assessments/indexwc that referenced this issue Sep 14, 2022
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.

Former-commit-id: 1c9d08b
kellijohnson-NOAA added a commit to pfmc-assessments/indexwc that referenced this issue Sep 14, 2022
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.

Former-commit-id: a781b902d8cb8968e3d7d76ae6f6ca093f74e841 [formerly bde4aa4448bdbe9e9c812afd4ecd8ad164a297b0] [formerly bde4aa4448bdbe9e9c812afd4ecd8ad164a297b0 [formerly 637d6800b449833d0b88cec7de9734c175bb3f8e]] [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe] [formerly 768eea1811351b5a29e9cddb677bab1ec945a84c [formerly 768eea1811351b5a29e9cddb677bab1ec945a84c [formerly af7ad1ed6d058c23b9b73d359eaf30bed1650ef3]] [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe [formerly 1c9d08b]]]]
Former-commit-id: b318c8bbcbe0376a3a4cb45852e542fccf99ac76 [formerly f0f7e8b362af0e901294bfe276561e86343e9f34] [formerly f0f7e8b362af0e901294bfe276561e86343e9f34 [formerly 3a7af0a73a80e3969a5388fc7294bfd8409fdf1b]] [formerly 72a0221bb9a8ba0bf773593c36be01bd7655b02e [formerly 72a0221bb9a8ba0bf773593c36be01bd7655b02e [formerly 6cb86b6]]]
Former-commit-id: 72a0221bb9a8ba0bf773593c36be01bd7655b02e
Former-commit-id: 409c047d43ae94ecd00a27ff3a10d45cc1f2c21a [formerly 669cec9c4d86d83b37006b3512100ea11203ed8c]
Former-commit-id: 8cc09999a4f3d2b42d2b5544d7d8a302eb359297
kellijohnson-NOAA added a commit to pfmc-assessments/indexwc that referenced this issue Jun 9, 2023
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.

Former-commit-id: a781b902d8cb8968e3d7d76ae6f6ca093f74e841 [formerly bde4aa4448bdbe9e9c812afd4ecd8ad164a297b0] [formerly bde4aa4448bdbe9e9c812afd4ecd8ad164a297b0 [formerly 637d6800b449833d0b88cec7de9734c175bb3f8e]] [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe] [formerly 768eea1811351b5a29e9cddb677bab1ec945a84c [formerly 768eea1811351b5a29e9cddb677bab1ec945a84c [formerly af7ad1ed6d058c23b9b73d359eaf30bed1650ef3]] [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe [formerly c5e5c3e [formerly cd83817379f76689427bdb39f43793ef594136c4] [formerly 71334b7ce4137d624a5b15f0441e238817e4bf9d [formerly 4f69e3e4ec28788b831f633ccd07b028abe7e6df]] [formerly 3fbf388d9ebfb6e1d94f8f0fd2009ea127a4d07d [formerly d5d11a2607160bfd48d2db6847d55a4be4ca3470] [formerly f5ce05828667e7f5a89b0d3e6cdc367e23911e14 [formerly 7c6f24cf028e870fb3d813eceff14dfa7139a8cf]]] [formerly 6cb86b6] [formerly 5ef1cd270ed31fd31f8b864b511024aec5a9a8f6 [formerly 1c9d08b]]]]]]
Former-commit-id: b318c8bbcbe0376a3a4cb45852e542fccf99ac76 [formerly f0f7e8b362af0e901294bfe276561e86343e9f34] [formerly f0f7e8b362af0e901294bfe276561e86343e9f34 [formerly 3a7af0a73a80e3969a5388fc7294bfd8409fdf1b]] [formerly 72a0221bb9a8ba0bf773593c36be01bd7655b02e [formerly 72a0221bb9a8ba0bf773593c36be01bd7655b02e [formerly c5e5c3e [formerly cd83817379f76689427bdb39f43793ef594136c4] [formerly 71334b7ce4137d624a5b15f0441e238817e4bf9d [formerly 4f69e3e4ec28788b831f633ccd07b028abe7e6df]] [formerly 3fbf388d9ebfb6e1d94f8f0fd2009ea127a4d07d [formerly d5d11a2607160bfd48d2db6847d55a4be4ca3470] [formerly f5ce05828667e7f5a89b0d3e6cdc367e23911e14 [formerly 7c6f24cf028e870fb3d813eceff14dfa7139a8cf]]] [formerly 6cb86b6]]]]
Former-commit-id: 72a0221bb9a8ba0bf773593c36be01bd7655b02e
Former-commit-id: 409c047d43ae94ecd00a27ff3a10d45cc1f2c21a [formerly 669cec9c4d86d83b37006b3512100ea11203ed8c]
Former-commit-id: 8cc09999a4f3d2b42d2b5544d7d8a302eb359297
Former-commit-id: d1ccf47d3f8774663627b3adb353b91277c8c0df [formerly 84c0ce2]
Former-commit-id: 669eb6729810367a57b171b37b2f1232927aaa52
Former-commit-id: 405090f6cde1d747a19077698a55a8c79268a8d7 [formerly e24f399d51b0bd174c66c72f7c6fdbc9fb309471] [formerly 8cc28f5f307f9510b9716a9b8f679427d7db99ca [formerly 4328e07d4a1b6a819795180663ddffc13a329c81]]
Former-commit-id: d2f98580765d51a638d338c2d1054c4006f95a85 [formerly ade93cb6f166a9130b4af72720dbf7436a19ea95]
Former-commit-id: d6f82009c0dcf16e4f031212224999cf1951bf4f
kellijohnson-NOAA added a commit to pfmc-assessments/indexwc that referenced this issue Jun 9, 2023
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.

Former-commit-id: 5ef1cd270ed31fd31f8b864b511024aec5a9a8f6 [formerly 1c9d08b]
Former-commit-id: 6cb86b6
Former-commit-id: 3fbf388d9ebfb6e1d94f8f0fd2009ea127a4d07d [formerly d5d11a2607160bfd48d2db6847d55a4be4ca3470] [formerly f5ce05828667e7f5a89b0d3e6cdc367e23911e14 [formerly 7c6f24cf028e870fb3d813eceff14dfa7139a8cf]]
Former-commit-id: 71334b7ce4137d624a5b15f0441e238817e4bf9d [formerly 4f69e3e4ec28788b831f633ccd07b028abe7e6df]
Former-commit-id: cd83817379f76689427bdb39f43793ef594136c4
kellijohnson-NOAA added a commit to pfmc-assessments/indexwc that referenced this issue Jun 9, 2023
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.

Former-commit-id: a781b902d8cb8968e3d7d76ae6f6ca093f74e841 [formerly bde4aa4448bdbe9e9c812afd4ecd8ad164a297b0] [formerly bde4aa4448bdbe9e9c812afd4ecd8ad164a297b0 [formerly 637d6800b449833d0b88cec7de9734c175bb3f8e]] [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe] [formerly 768eea1811351b5a29e9cddb677bab1ec945a84c [formerly 768eea1811351b5a29e9cddb677bab1ec945a84c [formerly af7ad1ed6d058c23b9b73d359eaf30bed1650ef3]] [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe [formerly 957c76225fbe186c5ca227a8c1fe9c7dcca8aabe [formerly a51a873 [formerly 2aebfc425f459f392f7824a247a072ddc422cec7] [formerly d9ce8bc9ac6bbab27ba398c1eec59486fad9f4d7 [formerly 50a6056cd0a6c77d4a06034876f317dded85bd6e]] [formerly 5132b4d060524d26364414d772985d99b48b33fc [formerly 7a0244f4db1393ad559033cb5b281ea1d0e7ff32] [formerly 0bb903e985f042f874c31ce572261c9b2b5175ec [formerly c5e5c3e]]] [formerly cd83817379f76689427bdb39f43793ef594136c4] [formerly 71334b7ce4137d624a5b15f0441e238817e4bf9d [formerly 4f69e3e4ec28788b831f633ccd07b028abe7e6df]] [formerly 3fbf388d9ebfb6e1d94f8f0fd2009ea127a4d07d [formerly d5d11a2607160bfd48d2db6847d55a4be4ca3470] [formerly f5ce05828667e7f5a89b0d3e6cdc367e23911e14 [formerly 7c6f24cf028e870fb3d813eceff14dfa7139a8cf]]] [formerly 6cb86b6] [formerly 5ef1cd270ed31fd31f8b864b511024aec5a9a8f6 [formerly d16c9a1 [formerly d52e5bb6c3137e90cac96753ec81791ce74246f0] [formerly ccedaefc3b38bd99f8b497892ee51141267af7f0 [formerly 094daba021335dc5efcd158ae9f99ebd931c2f04]] [formerly a7ef685610e2281e5f21c3ae75cdf17b02ab56a1 [formerly 2ca6f6ee216df4c52b835e8eccc6fd1d7bda381c] [formerly 5ef1cd270ed31fd31f8b864b511024aec5a9a8f6 [formerly 1c9d08b]]]]]]]]]
Former-commit-id: b318c8bbcbe0376a3a4cb45852e542fccf99ac76 [formerly f0f7e8b362af0e901294bfe276561e86343e9f34] [formerly f0f7e8b362af0e901294bfe276561e86343e9f34 [formerly 3a7af0a73a80e3969a5388fc7294bfd8409fdf1b]] [formerly 72a0221bb9a8ba0bf773593c36be01bd7655b02e [formerly 72a0221bb9a8ba0bf773593c36be01bd7655b02e [formerly a51a873 [formerly 2aebfc425f459f392f7824a247a072ddc422cec7] [formerly d9ce8bc9ac6bbab27ba398c1eec59486fad9f4d7 [formerly 50a6056cd0a6c77d4a06034876f317dded85bd6e]] [formerly 5132b4d060524d26364414d772985d99b48b33fc [formerly 7a0244f4db1393ad559033cb5b281ea1d0e7ff32] [formerly 0bb903e985f042f874c31ce572261c9b2b5175ec [formerly c5e5c3e]]] [formerly cd83817379f76689427bdb39f43793ef594136c4] [formerly 71334b7ce4137d624a5b15f0441e238817e4bf9d [formerly 4f69e3e4ec28788b831f633ccd07b028abe7e6df]] [formerly 3fbf388d9ebfb6e1d94f8f0fd2009ea127a4d07d [formerly d5d11a2607160bfd48d2db6847d55a4be4ca3470] [formerly f5ce05828667e7f5a89b0d3e6cdc367e23911e14 [formerly 7c6f24cf028e870fb3d813eceff14dfa7139a8cf]]] [formerly 6cb86b6]]]]
Former-commit-id: 72a0221bb9a8ba0bf773593c36be01bd7655b02e
Former-commit-id: 409c047d43ae94ecd00a27ff3a10d45cc1f2c21a [formerly 669cec9c4d86d83b37006b3512100ea11203ed8c]
Former-commit-id: 8cc09999a4f3d2b42d2b5544d7d8a302eb359297
Former-commit-id: d1ccf47d3f8774663627b3adb353b91277c8c0df [formerly ebb75fb [formerly e41ff35a22027d3568cf66993794b4dae21b860d] [formerly 0931969d4f70354dfea2cc333ac73777d104c37c [formerly 0bf21e4e3362fabe8965988968af1f00807e0e80]] [formerly f1b8f4760f5439abc21ffad5f33a62acccdbd25d [formerly ea68f0215f5f208e359cee2fb7cd50af3ff2f518] [formerly bdbed00745101a49499e5523c568c758e1490443 [formerly 84c0ce2]]]]
Former-commit-id: 669eb6729810367a57b171b37b2f1232927aaa52
Former-commit-id: 405090f6cde1d747a19077698a55a8c79268a8d7 [formerly e24f399d51b0bd174c66c72f7c6fdbc9fb309471] [formerly 8cc28f5f307f9510b9716a9b8f679427d7db99ca [formerly 4328e07d4a1b6a819795180663ddffc13a329c81]]
Former-commit-id: d2f98580765d51a638d338c2d1054c4006f95a85 [formerly ade93cb6f166a9130b4af72720dbf7436a19ea95]
Former-commit-id: d6f82009c0dcf16e4f031212224999cf1951bf4f
Former-commit-id: b9911ea7ec987b0a86cfcf5b8c61c46dc8388345 [formerly 79894aa930e38dd0f3223107e9b3a75bb9968afd] [formerly f287c2711e9948dd8234a7342f60141cf900f16d [formerly 55f1951]]
Former-commit-id: 4f796d09294300576a9793b6466e33e5ad9da28a [formerly 7c56fe8bf0b0a93fa38acab3da4793915f154beb]
Former-commit-id: 7425303ed4e62e2a6c0cd0af03a1c94461851ad3
kellijohnson-NOAA added a commit to pfmc-assessments/indexwc that referenced this issue Jun 9, 2023
using VAST_3.9.0 the upper bound of logkappa2 is reached
using the default settings b/c of the small number of mesh points.
This commit changes the upper bound to 10 using
run_model = FALSE to get the correct map.
This trick can be found in
James-Thorson-NOAA/VAST#300
which was started by @kellijohnson-NOAA b/c of similar issues
when running the model for West Coast species.

Former-commit-id: 5ef1cd270ed31fd31f8b864b511024aec5a9a8f6 [formerly d16c9a1 [formerly d52e5bb6c3137e90cac96753ec81791ce74246f0] [formerly ccedaefc3b38bd99f8b497892ee51141267af7f0 [formerly 094daba021335dc5efcd158ae9f99ebd931c2f04]] [formerly a7ef685610e2281e5f21c3ae75cdf17b02ab56a1 [formerly 2ca6f6ee216df4c52b835e8eccc6fd1d7bda381c] [formerly 5ef1cd270ed31fd31f8b864b511024aec5a9a8f6 [formerly 1c9d08b]]]]
Former-commit-id: 6cb86b6
Former-commit-id: 3fbf388d9ebfb6e1d94f8f0fd2009ea127a4d07d [formerly d5d11a2607160bfd48d2db6847d55a4be4ca3470] [formerly f5ce05828667e7f5a89b0d3e6cdc367e23911e14 [formerly 7c6f24cf028e870fb3d813eceff14dfa7139a8cf]]
Former-commit-id: 71334b7ce4137d624a5b15f0441e238817e4bf9d [formerly 4f69e3e4ec28788b831f633ccd07b028abe7e6df]
Former-commit-id: cd83817379f76689427bdb39f43793ef594136c4
Former-commit-id: 5132b4d060524d26364414d772985d99b48b33fc [formerly 7a0244f4db1393ad559033cb5b281ea1d0e7ff32] [formerly 0bb903e985f042f874c31ce572261c9b2b5175ec [formerly c5e5c3e]]
Former-commit-id: d9ce8bc9ac6bbab27ba398c1eec59486fad9f4d7 [formerly 50a6056cd0a6c77d4a06034876f317dded85bd6e]
Former-commit-id: 2aebfc425f459f392f7824a247a072ddc422cec7
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

5 participants