pacific-hake / hake-assessment

:zap: :fish: Build the assessment document using latex and knitr
MIT License
13 stars 6 forks source link

download mcmc run for model 2020.01.33 #613

Closed aaronmberger-nwfsc closed 4 years ago

aaronmberger-nwfsc commented 4 years ago

A mcmc folder has been uploaded to the google drive for the fecundity run where historical fecundity is the average of data over the first 10 years. You will need to download that folder and then I suppose either delete the Rdata file and rebuild it or specifically call that model name in the build which I think would be: build(.run_forecasts = TRUE, .run_retrospectives = TRUE, .run_extra_mcmc = TRUE, .run_catch_levels_default_hr = TRUE, .run_catch_levels_spr_100 = TRUE, .run_catch_levels_stable_catch = TRUE, .model_name = "2020.01.33_eqFecund_early10")

Correct me if I'm wrong here. These results will go in an appendix, similar to age-1 survey results.

Check boxes just below...

aaronmberger-nwfsc commented 4 years ago

darn - trying check boxes again:

cgrandin commented 4 years ago

That call is close...

build(.run_forecasts = TRUE,
         .run_retrospectives = TRUE,
         .run_extra_mcmc = TRUE,
         .run_catch_levels_default_hr = TRUE,
         .run_catch_levels_spr_100 = TRUE,
         .run_catch_levels_stable_catch = TRUE,
         .model_list = "2020.01.33_eqFecund_early10")

Note it is .model_list not .model_name

andrew-edwards commented 4 years ago

So close Aaron.... Just realised may as well run the 2020.01.23_age1Survey one as well the same way (in a separate R window), to save time when we actually put them into the document. I can set up the appendices, we have a sample one from last year for MCMC results.

cgrandin commented 4 years ago

Retrospective 10 fails for me for this one. Anyone else?

andrew-edwards commented 4 years ago

Yes, just about to say that!

finished benchmark, forecast, and sdreporting
5 1819 -log(L): 530.144  Spbio: 1.75307e+006 463846
Warning -- Hessian does not appear to be positive definite
Hessian does not appear to be positive definite
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In shell(shell_command) :
  'cd c:/andy18/github/hake-assessment/models/2020.01.33_eqFecund_early10/retrospectives/retro-10 & ss.exe -nox' execution failed with error code 1
2: In file(con, "r") :
  cannot open file 'c:/andy18/github/hake-assessment/models/2020.01.33_eqFecund_early10/retrospectives/retro-10/data.ss_new': No such file or directory
aaronmberger-nwfsc commented 4 years ago

Same here - we can spend time figuring out why that is another day. In fact, retrospectives are MLE based so I don't even think we need them for 2020.01.23 and 2020.01.33. All we want is the mcmc results and decision tables in the appendices to compare them with the base model. So I propose we run: build(.run_forecasts = TRUE, .run_retrospectives = FALSE, .run_extra_mcmc = TRUE, .run_catch_levels_default_hr = TRUE, .run_catch_levels_spr_100 = TRUE, .run_catch_levels_stable_catch = TRUE, .model_list = "2020.01.33_eqFecund_early10") -- and then also for 2020.01.23_age1Survey

andrew-edwards commented 4 years ago

Good idea. My 2020.01.23_age1Survey is still running and the retros ran okay, so looks like it doesn't matter if you do it either way for 2020.01.23_age1Survey. #602 (just to link to that issue).

andrew-edwards commented 4 years ago

2020.01.23_age1Survey ran fine with all TRUE. I need to restart 2020.01.33... as I think I should have deleted some files (I got Report.sso appears to be early version from before Hessian was estimated.).

andrew-edwards commented 4 years ago

In case anyone else has issues.... My error was:

!warning: Report.sso appears to be early version from before Hessian was estimated.
          equilibrium yield estimates not included in output.
warning.sso file is missing the string 'N warnings'!
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'c:/andy18/github/hake-assessment/models/2020.01.33_eqFecund_early10/retrospectives/retro-10/data.ss_new': No such file or directory

Aha - I hadn't deleted the retro folders, so it gets in a mess when looking for them and getting to retro-10 that never finished before. Deleting the retrospectives/ folder and then just doing

build(.model_list = "2020.01.33_eqFecund_early10")

since all the calculations are already done, it just needs to build the .RData file. Seems to have worked.

andrew-edwards commented 4 years ago

Just assigning Kelli to tick the box up at the top! Presumably it should all work for others.

kellijohnson-NOAA commented 4 years ago

Figured out why the retro doesn't converge, it is just an SS thing that I will let Rick know about. You can manually change the OM of the retro to have the main recruitment period end in 2008 instead of 2019 and it will estimate the hessian. The problem is that the retro changes the main period of recruitment to endyearofmodel-10 (i.e., 2009), which is not the same as endofmainrecruitmentinbase-10 (i.e., 2008). The bad end year of main recruitment deviations leads to changes in the estimate of M, R_0, and h b/c it has a hard time estimating that last year of recruits given there are no data to do so. We should think about how this could be leading to biased results in the "real" retros that we have for the base model.

aaronmberger-nwfsc commented 4 years ago

Interesting - I noticed the gradient was horrible for retro 8, 9 and 10 for every model we did retro's for. We should do a test and manually do the retros for our base model and see if it makes any difference. If so, we should manually change those before we build on the last day.

kellijohnson-NOAA commented 4 years ago

For the run that we are talking about, which is not the base model obviously, the retro 10 gradient was changed from 5.54276 to 2.93182, so still not good.

kellijohnson-NOAA commented 4 years ago

On the building side of things, should it make the retro folder or try them if I run build(T,F,T,T,T,T) because it did. I am thinking that run in should be altered to unpack the ... items and only run_forecasts() if the value is TRUE.

aaronmberger-nwfsc commented 4 years ago

I had the same thing happen. Even when F for retro's it still would build them. Perhaps that's because it 'has to' build them and the F only implies that it won't build them again (but they have to already exist)???

andrew-edwards commented 4 years ago

Nice detective work Kelli! The build should work. Once it's run with build(T, F, T,...) just delete the retro folder if it gets created (even if empty). See above for what worked with me (I had the failed retros folder still in there, but once I deleted that I think it didn't appear again).

aaronmberger-nwfsc commented 4 years ago

Ha, my temporary workaround was to just copy retro-9 files into retro-10 as we aren't using that info anyway, just to get past the hangup.

cgrandin commented 4 years ago

For all the run() type functions for running models, if you chose TRUE, then the first thing that happens is that the whole directory is deleted. If you chose FALSE it will leave the directory, unless it doesn't exist in which case it will run the procedure anyway (if there is an mcmc folder). Here's what the code looks like in the beginning of these functions. The unlink() deletes everything in the directory. This one is retrospectives (https://github.com/pacific-hake/hake-assessment/blob/master/R/retrospectives.R) but they are all similar:

  model_path <- model$path
  retro_path <- file.path(model_path, "retrospectives")
  if(!run_retrospectives & dir.exists(retro_path)){
    return(invisible())
  }
  dir.create(retro_path, showWarnings = FALSE)
  unlink(file.path(retro_path, "*"), recursive = TRUE)
kellijohnson-NOAA commented 4 years ago

okay, so an empty folder would lead to them not being run, i just didn't understand what was going on, thanks @cgrandin for shedding light on this! We can probably close this issue now right?