anthofflab / MimiDICE2013.jl

Other
2 stars 3 forks source link

example dice scc code #1

Closed corakingdon closed 2 years ago

FrankErrickson commented 6 years ago

Just leaving some pseudo code on how I usually set up the SCC type stuff. This does it one function and (should) work with the getdiceexcel( ) set up you currently have.


# PARAMETER DESCRIPTIONS
# discount_type = indicator for type of discounting (:Constant or :Ramsey)
# emissions_year = when the CO2 pulse occurs
# constant = constant discounting rate
# eta = elasticity of marginal utility (for Ramsey discounting)
# prtp = pure rate of time preference (for Ramsey discounting)
# clim_sens = equilibrium climate sensitivity

function dice_scc(discount_type; emission_year=2010, constant=0.03, eta=1.5, prtp=0.015, clim_sens=3.0)  

    # Get base and marginal versions of dice
    base = getdiceexcel( )
    marginal = getdiceexcel( )

    # Override standard parameter settings with your equilibrium climate sensitivity.
    setparameter(base, :climatedynamics, :t2xco2, clim_sens)
    setparameter(marginal, :climatedynamics, :t2xco2, clim_sens)

    # Do the whole adder thing for the emission pulse
    ADDER STUFF

    # Run your models
    run(base)
    run(marginal)

    # Extract damages
    DAMAGES HERE

    # Discounting set up
    if discount_type == :Ramsey
        calculate Ramsey discounting
    else
        calculate constant discouting
    end

    # Calcualte SCC
    scc= sum(discounted damages)

    return scc
end

With this framework, you can use it for the climate sensitivity Monte Carlos


#Assuming you have a function that pulls samples from a Roe and Baker pdf.
n_samples = 10000
ecs_sample = sample_RB(n_samples)

#Create an array to hold your results
scc = zeros(n_samples)

#Loop through 
for i in 1:n_samples
    scc[i] = dice_scc(:Constant, clim_sens = ecs_sample[i])
end