immccull95 / GLEON_Bayesian_WG

A working group studying algae blooms in Lake Sunapee, NH
5 stars 5 forks source link

Plug n play for JAGS models #15

Closed jzwart closed 5 years ago

jzwart commented 5 years ago

Expanded on @wbeck1990 script for quickly running Bayes models for different sites, dates, and model types. The run_bayes_model.R script is where you adjust options for sites / dates / model and it calls helper functions to retrieve data and JAGS model variables. The end of the script plots model output.

Below is a code snippet of where you would make changes to model runs. @wbeck1990 I think there might need to be a little more guidance for changing beta.m and beta.v. If it is model dependent, then we can make a function for that and then the user would only have to change model_name rather than changing beta's. I left your plotting as is and mostly moved up all changeable variables to the top of the script as well as turn some stuff into functions.

#1) Model options => pick date range, site, time step, and type of model -----------------------------------------------------

start_date = '2007-01-01' # in YYYY-MM-DD format 
end_date = '2015-12-31' 
site = c('midge') # options are midge, coffin, newbury, or fichter 
model_timestep = 1 # model timestep in days if filling in dates
fill_dates = TRUE  # T/F for filling in dates w/o observations with NA's 

beta.m <- as.vector(c(0,0,0)) ##CHANGE THE NUMBER OF BETAS TO MATCH YOUR MODEL
beta.v <- solve(diag(1E-03,3)) ##CHANGE THE NUMBER OF BETAS TO MATCH YOUR MODEL

model_name = 'RandomWalk' # options are RandomWalk, RandomWalkZip, DayLength, DayLength_Quad, TempExp, Temp_Quad, or Logistic