mdscheuerell / AukeCoho

Development site for an integrated population model for Auke Creek coho salmon
Other
2 stars 0 forks source link

Important change in salmonIPM re: covariates #3

Closed ebuhle closed 4 years ago

ebuhle commented 5 years ago

Hey @DavidTallmon, just a heads-up that I realized there was an issue in the IPM_SMaS_np Stan code in salmonIPM that affects our inference re environmental covariates at the end of yesterday's code-jam session. As part of my efforts to diagnose the parallel-chains error, I had intentionally commented out the lines where the regression predictors enter into smolt production and SAR, and forgot to restore them before we fit the fit_BH_env model. I've done that now, and pushed the "real" model to salmonIPM@ICchinook-models, so the next time you work on the analysis you should unleash these lines to reinstall the package:

#unleash below to update master branch version of IPM
detach(package:salmonIPM, unload = TRUE)
devtools::install_github("ebuhle/salmonIPM@ICchinook-models")
library("salmonIPM")

I'll try to make sure the package repo is fully functional (for everyone but me) from now on, although I can't guarantee that in the immediate future.

FWIW, there's still nothing going on with stream temp or hatchery releases, but there is a 96% probability that PDO has a positive effect on SAR.

DavidTallmon commented 5 years ago

Thanks, Eric. Seems to work just fine. Got a warning about $ operator being invalid for atomic vectors in response to line under ##Truncate fish data to non-missing covariate data, but program seems to be working - chains are running.

ebuhle commented 5 years ago

Are you using the current version of the script? I seem to recall getting that warning because env_data had been converted from a data frame to a matrix, but the script doesn't do that anymore.

DavidTallmon commented 4 years ago

Hey Eric. I'm back to working on this project. Is working with the package you listed above in this string still the one to use?

ebuhle commented 4 years ago

Hi @DavidTallmon, you have two options for installing salmonIPM at the moment. One is to use the master branch, which is stable and should behave exactly as before. You can do that with

devtools::install_github("ebuhle/salmonIPM")

Alternatively, you could try the develop branch which is new and improved in a couple of ways. The biggest change is that I switched over to the "Stan-approved" package structure created with rstantools. For the user, the upshot is that the models are now precompiled and start sampling immediately when called. In addition, I finally figured out how to set up the priors on the initial states (spawner abundance and age structure in years 1:max_age) in a way that fully uses the information in the data. Unfortunately, the one model where this hasn't been implemented yet is IPM_SMaS_np (i.e., the one you want) owing to the extra complexity of the juvenile age structure. I plan to do this eventually, but it's not near the top of the priority list. You can install the develop branch with

devtools::install_github("ebuhle/salmonIPM@develop")

I would actually be interested to hear if this works, since I'm always building the package from my local copy of the repo rather than installing from GH.

One last note: we still don't have user-specified priors, so that business about the prior scale on the obs error SD (if I'm remembering correctly) may still be an issue.

DavidTallmon commented 4 years ago

Looks like the former command worked to install from the master branch , but the latter yielded the following from the develop branch after scolding me for not have the version of Rtools compatible with R 3.5.1 and then successfully unpacking a few things:

Hope that's helpful.

ebuhle commented 4 years ago

Hmm. Well, do you have Rtools35 installed? (FYI, the current version of R is 4.0.2 and there's a new version of the toolchain [Rtools40] to go with R 4.x, so I'd suggest upgrading anyway.)

If so, then maybe you should try the suggestion here to use remotes::install_github() instead of devtools::install_github(), even though it sounds like the issue described in that thread has since been fixed.

That said, I don't see why this problem, whatever it is, would only affect the develop branch, which makes me suspicious that installation from master is in fact succeeding. To be certain, try removing your existing installation of salmonIPM before installing from GH.

DavidTallmon commented 4 years ago

OK. I've updated my R version and re-installed everything successfully except for openssl and backports. Those seem to give me grief whether I try to install from the source packages or get binaries. Not sure if I'm safe to go in and remove older versions of openssl and backports as wants me to.....

devtools::install_github("ebuhle/salmonIPM") Using github PAT from envvar GITHUB_PAT Downloading GitHub repo ebuhle/salmonIPM@master These packages have more recent versions available. It is recommended to update all of them. Which would you like to update?

1: All 2: CRAN packages only 3: None 4: backports (1.1.7 -> 1.1.8) [CRAN] 5: openssl (1.4.1 -> 1.4.2) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 1 backports (1.1.7 -> 1.1.8) [CRAN] openssl (1.4.1 -> 1.4.2) [CRAN] Installing 2 packages: backports, openssl Installing packages into ‘C:/Users/datallmon/R_LIBS’ (as ‘lib’ is unspecified)

There are binary versions available but the source versions are later: binary source needs_compilation backports 1.1.7 1.1.8 TRUE openssl 1.4.1 1.4.2 TRUE

installing the source packages ‘backports’, ‘openssl’

trying URL 'https://cran.rstudio.com/src/contrib/backports_1.1.8.tar.gz' Content type 'application/x-gzip' length 18047 bytes (17 KB) downloaded 17 KB

trying URL 'https://cran.rstudio.com/src/contrib/openssl_1.4.2.tar.gz' Content type 'application/x-gzip' length 1204168 bytes (1.1 MB) downloaded 1.1 MB

'\sync-al\files$\JD-880061-A2\datallmon\Desktop\RStudioPractice' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. ERROR: failed to lock directory 'C:/Users/datallmon/R_LIBS' for modifying Try removing 'C:/Users/datallmon/R_LIBS/00LOCK-backports' Error: Failed to install 'salmonIPM' from GitHub: (converted from warning) installation of package ‘backports’ had non-zero exit status

devtools::install_github("ebuhle/salmonIPM") Using github PAT from envvar GITHUB_PAT Downloading GitHub repo ebuhle/salmonIPM@master These packages have more recent versions available. It is recommended to update all of them. Which would you like to update?

1: All 2: CRAN packages only 3: None 4: backports (1.1.7 -> 1.1.8) [CRAN] 5: openssl (1.4.1 -> 1.4.2) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 4 backports (1.1.7 -> 1.1.8) [CRAN] Installing 1 packages: backports Installing package into ‘C:/Users/datallmon/R_LIBS’ (as ‘lib’ is unspecified)

There is a binary version available but the source version is later: binary source needs_compilation backports 1.1.7 1.1.8 TRUE

trying URL ' https://cran.rstudio.com/bin/windows/contrib/4.0/backports_1.1.7.zip' Content type 'application/zip' length 81641 bytes (79 KB) downloaded 79 KB

package ‘backports’ successfully unpacked and MD5 sums checked Error: Failed to install 'salmonIPM' from GitHub: (converted from warning) cannot remove prior installation of package ‘backports’

On Mon, Jun 29, 2020 at 4:24 PM ebuhle notifications@github.com wrote:

Hmm. Well, do you have Rtools35 installed? (FYI, the current version of R is 4.0.2 and there's a new version of the toolchain [Rtools40] to go with R 4.x, so I'd suggest upgrading anyway.)

If so, then maybe you should try the suggestion here https://github.com/r-lib/rlang/issues/661 to use remotes::install_github() instead of devtools::install_github(), even though it sounds like the issue described in that thread has since been fixed.

That said, I don't see why this problem, whatever it is, would only affect the develop branch, which makes me suspicious that installation from master is in fact succeeding. To be certain, try removing your existing installation of salmonIPM before installing from GH.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mdscheuerell/AukeCoho/issues/3#issuecomment-651439686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIT6EPU6L5FAB5PX2QUTUJTRZEWCTANCNFSM4G6D6XIA .

ebuhle commented 4 years ago

Enter one or more numbers, or an empty line to skip updates:

You should be fine skipping those updates. You can also use the upgrade = FALSE argument to install_github() to skip all updates.

DavidTallmon commented 4 years ago

Hmm. Now it seems to be telling me there is no backports package....

detach(package:salmonIPM, unload = TRUE) Error in detach(package:salmonIPM, unload = TRUE) : invalid 'name' argument

devtools::install_github("ebuhle/salmonIPM",upgrade=FALSE) Error: .onLoad failed in loadNamespace() for 'pkgload', details: call: loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) error: there is no package called ‘backports’

On Tue, Jun 30, 2020 at 8:17 AM ebuhle notifications@github.com wrote:

Enter one or more numbers, or an empty line to skip updates:

You should be fine skipping those updates. You can also use the upgrade = FALSE argument to install_github() to skip all updates.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mdscheuerell/AukeCoho/issues/3#issuecomment-651898858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIT6EPVJBEYUI6YZX4LZLPDRZIF2RANCNFSM4G6D6XIA .