Description Usage Arguments Value Examples
View source: R/MICE_functions.R
This function drives the model. It creates and initializes objects by reading two files (input_params.csv and diet_prefs.csv) into data frames, replaces the "params" data frame if an alternative is passed in by the user, and then steps through years and intra-year timesteps, calculating population numbers-at-age, recruits, catch, etc. for each species. Species interactions are possible because the calculations for each species are done at least once per year. It returns a list of data and plots for each species. Note: the order of some operations matters. This function must initialize the simulationParams object before Species objects; do prey calculations before predators; calculate sardine numbers before anchovy (because anchovy reproduction depends on sardine numbers); update population numbers before recruitment and catch (because catch and recruitment may depend on population size).
1 | runMICE(Params, inputdir, scenario = "base", nYears = 100, nSteps = 4)
|
inputdir |
A directory where the input_params.csv and diet_prefs.csv files are. |
scenario |
Character. A scenario name (must match a column name in the input file.) |
nYears |
Integer. Number of years for the simulation. |
nSteps |
Integer. Number of timesteps within a year (ignored by some species). |
params |
A data frame of parameters |
A list with several components: $input_params: the simulationParams object that was used to make the run. $Anchovy: anchovy results. This has two components: $data: a data frame of some of the most commonly-used results $plots: a set of plots, which may be accessed as a group or individually $Sardine (same as Anchovy), etc. $species. The species objects that contain all values used. $Anchovy: the anchovy object $Sardine: the sardine object, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
result<-simulate() #uses default input files
#Instead of using the default, modify some values in the parameter object
my_params<-new("simulationParams") #create a new simulationParams object
my_params<-set_simParam(my_params) #initialize the object with data from stored files
p<-my_params@params #Get the input parameter data frame
p[p$species=="Sardine",1:7] #Look at the parameters for one species.
p$base[p$species=="Sardine" & p$parameter=="fished"]<-TRUE #Set fished to TRUE in the base scenario
my_params@params<-p #put the changed value back into the simulationParams object.
#Re-run the model with the changed values (Alternatively, one could re-make the .csv input files).
result<-runMICE(my_params) #uses a modified simulationParams object
#Look at the results
result$Pelican$plots #Show Pelican plots
anchovy.df<-result$Anchovy$data #save the Anchovy data to a data frame for further analysis
#Look at a slot in one of the Species objects
res$species$Anchovy@wv #weight at age
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.