# -*- coding: utf-8 -*-
"""
Created on Sun Jan  3 10:50:02 2021

@author: Mateo
"""

from HARK.Calibration.Calibration import (
    ParseIncomeSpec,
    findProfile,
    Cagetti_income,
    CGM_income,
)

import numpy as np
import matplotlib.pyplot as plt

# %% CGM calibration
adjust_infl_to = 1992

age_min = 21
age_max = 100

ages = np.arange(age_min, age_max + 1)

plt.figure()
for spec in CGM_income.items():

    label = spec[0]

    params = ParseIncomeSpec(
        age_min=age_min, age_max=age_max, adjust_infl_to=adjust_infl_to, **spec[1]
    )
    MeanY = findProfile(params["PermGroFac"], params["P0"])

    plt.plot(ages, MeanY, label=label)

plt.title("CGM")
plt.legend()
plt.show()

# %% Cagetti calibration

age_min = 25
age_max = 91
# Cagetti has a year trend in his specification, so we have to say on what
# year agents enter the model.
start_year = 1980

ages = np.arange(age_min, age_max + 1)

plt.figure()
for spec in Cagetti_income.items():

    label = spec[0]

    params = ParseIncomeSpec(
        age_min=age_min,
        age_max=age_max,
        adjust_infl_to=adjust_infl_to,
        start_year=start_year,
        **spec[1]
    )
    MeanY = findProfile(params["PermGroFac"], params["P0"])

    plt.plot(ages, MeanY, label=label)

plt.title("Cagetti")
plt.legend()
plt.show()

@@ -256,49 +256,188 @@
 %0A%0A# 
-%25%25 CGM calibration%0Aadjust_infl_to = 1992%0A
+What year to use as the base monetary year?%0A# (pick 1992 as it is used by both of the papers we are comparing)%0Aadjust_infl_to = 1992%0A%0A# %25%25 Cocco, Gomes, Maenhout (2005) calibration
 %0Aage
@@ -802,13 +802,222 @@
 tle(
-%22CGM%22
+%0A    %22Mean paths of permanent income calibrations in%5Cn%22%0A    + %22Cocco, Gomes & Maenhout (2005)%22%0A)%0Aplt.xlabel(%22Age%22)%0Aplt.ylabel(%0A    %22Mean Permanent Income,%5Cn%22 + %22Thousands of %7B%7D U.S. dollars%22.format(adjust_infl_to)%0A
 )%0Apl
@@ -1051,16 +1051,23 @@
  Cagetti
+ (2003)
  calibra
@@ -1624,16 +1624,195 @@
 le(%22
-Cagetti%22
+Mean paths of permanent income calibrations in%5Cn%22 + %22Cagetti (2003)%22)%0Aplt.xlabel(%22Age%22)%0Aplt.ylabel(%0A    %22Mean Permanent Income,%5Cn%22 + %22Thousands of %7B%7D U.S. dollars%22.format(adjust_infl_to)%0A
 )%0Apl

Improve presentation in income example file