Hi Ken, hopefully I’ve addressed each of your questions below! Let me know if there is anything else that still isn’t clear.
replacing the RV correctly:
I just ran the code I had suggested, and you are right, it does not correctly replace the values as I had thought. My apologies for leading you astray, the functionality is a bit finicky because Mimi currently appends unique numbers to the names of the random variables in the simulation’s definition under the hood, so the random variable that you are trying to replace isn’t actually called :climatesensitivity
, it’s called :climatesensitivity!265
. I had forgotten this, and it is obviously not ideal behavior, given how misleading that is, and is something we are hoping to change about these functions in the future.
For now though, you can use the replaceRV!
function with the name :climatesensitivity!265
in the following way:
using Distributions
using Mimi
using MimiFUND
simdef = MimiFUND.getmcs();
Mimi.replaceRV!(simdef, :climatesensitivity!265, Normal(1.5, 0.003));
Mimi.addSave!(simdef, :climatedynamics, :climatesensitivity);
m = MimiFUND.get_model();
sim_results = run(simdef, m, 100);
It should be understood though that this solution is a bit brittle, because if something changes in MimiFUND’s SimulationDefinition, the number appended to the climatesensitivity’s name could also change. I more robust (but lengthier) solution would be to simply copy the code from MimiFUND for defining the whole Simulation (including all random variables) and simply modify the line for climatesensitivity (here: https://github.com/fund-model/MimiFUND.jl/blob/master/src/montecarlo/defmcs.jl)
viewing the full list of values:
the returned value from the following is a DataFrame object, but if you extract the values from the desired column as a vector it might display the way you are hoping in notebook:
df = sim_results[:climatedynamics, :climatesensitivity];
values = df[!, :climatesensitivity]
Computing the social cost of carbon:
The compute_scco2
function in MimiFUND does not currently support passing in a modified SimulationDefinition (something we may add later). So in order to calculate the SC-CO2 with your modified simulation, you will have to dig in to MimiFUND’s code a bit more, copy out the relevant functions yourself, and just replace your modified SimulationDefinition where necessary. That code is all available on MimiFUND’s github repository, most of the relevant code should be in the “src/new_marginaldamages.jl” file.
other keyword arguments to the run
function:
So there are two run
methods implemented in Mimi: one which runs a single model over one set of it’s default values, which looks like:
run(m)
and the second which runs a Simulation for a given model and a SimulationDefinition (which defines all of the random variables to sample from) and looks like:
run(simdef, m, N)
This second one is the one I mentioned that has other optional keyword arguments. In a Julia REPL, if you type a single question mark ?
that should open the “help” bar, and if you then type a function name it should display the docstrings, which will describe the other optional arguments.
julia> ?
help?> run
If you are primarily working in notebook, I’m not sure what the best way to view the docstring is. If you can’t find a way to view it, let me know and I can just paste it here instead.
Alternatively, this page in the Docs under “Step 4” shows the various arguments, but doesn’t go into detail about all of them: https://www.mimiframework.org/Mimi.jl/stable/tutorials/tutorial_4/#Advanced-Post-trial-Functions-1 So let me know if you have specific questions about any of them.