def setUp(self):

        # Parameters from Mehra and Prescott (1985):
        Avg = 1.08  # equity premium
        Std = 0.20  # standard deviation of rate-of-return shocks

        RiskyDstnFunc = cpm.RiskyDstnFactory(
            RiskyAvg=Avg, RiskyStd=Std)  # Generates nodes for integration
        RiskyDrawFunc = cpm.LogNormalRiskyDstnDraw(
            RiskyAvg=Avg, RiskyStd=Std
        )  # Function to generate draws from a lognormal distribution

        init_portfolio = copy.copy(
            param.init_idiosyncratic_shocks
        )  # Default parameter values for inf horiz model - including labor income with transitory and permanent shocks
        init_portfolio['approxRiskyDstn'] = RiskyDstnFunc
        init_portfolio['drawRiskyFunc'] = RiskyDrawFunc
        init_portfolio[
            'RiskyCount'] = 2  # Number of points in the approximation; 2 points is minimum
        init_portfolio[
            'RiskyShareCount'] = 25  # How many discrete points to allow for portfolio share
        init_portfolio[
            'Rfree'] = 1.0  # Riskfree return factor (interest rate is zero)
        init_portfolio['CRRA'] = 6.0  # Relative risk aversion

        # Uninteresting technical parameters:
        init_portfolio['aXtraMax'] = 100
        init_portfolio['aXtraCount'] = 50
        init_portfolio[
            'BoroCnstArt'] = 0.0  # important for theoretical reasons
        init_portfolio[
            'DiscFac'] = 0.92  # Make them impatient even wrt a riskfree return of 1.08

        # Create portfolio choice consumer type
        self.pcct = cpm.PortfolioConsumerType(**init_portfolio)

        # %% {"code_folding": []}
        # Solve the model under the given parameters

        self.pcct.solve()
# %% Calibration and solution

# Import parameters from external file
sys.path.append(os.path.realpath('../')) 
# Loading the parameters from the ../Code/Calibration/params.py script
from Calibration.params import dict_portfolio, time_params, det_income, Mu, Rfree, Std, norm_factor

# Create new dictionary
merton_dict = copy(dict_portfolio)

# Adjust certain parameters to align with Merton-Samuleson
# Log normal returns (Overwriting Noramal returns defined in params)
mu = Mu + Rfree
RiskyDstnFunc = cpm.RiskyDstnFactory(RiskyAvg=mu, RiskyStd=Std) # Generates nodes for integration
RiskyDrawFunc = cpm.LogNormalRiskyDstnDraw(RiskyAvg=mu, RiskyStd=Std) # Generates draws from the "true" distribution

# Make agent inifitely lived. Following parameter examples from ConsumptionSaving Notebook
merton_dict['approxRiskyDstn'] = RiskyDstnFunc
merton_dict['drawRiskyFunc'] = RiskyDrawFunc

agent = cpm.PortfolioConsumerType(**merton_dict)
agent.solve()

# %%

aMin = 0   # Minimum ratio of assets to income to plot
aMax = 1e5  # Maximum ratio of assets to income to plot
aPts = 1000 # Number of points to plot 

# Campbell-Viceira (2002) approximation to optimal portfolio share in Merton-Samuelson (1969) model
# input a function that *draws* from the distribution in drawRiskyFunc
#
# Other assumptions: 
#   * distributions are time constant
#   * probability of being allowed to reoptimize is time constant
#      * If p < 1, you must specify the PortfolioSet discretely
#       

# %% {"code_folding": []}
# Set up the model
# Parameters from Mehra and Prescott (1985):
Avg = 1.08 # equity premium 
Std = 0.20 # standard deviation of rate-of-return shocks 

RiskyDstnFunc = cpm.RiskyDstnFactory(RiskyAvg=Avg, RiskyStd=Std)       # Generates nodes for integration
RiskyDrawFunc = cpm.LogNormalRiskyDstnDraw(RiskyAvg=Avg, RiskyStd=Std) # Generates draws from a lognormal distribution

init_portfolio = copy.copy(param.init_idiosyncratic_shocks) # Default parameter values for inf horiz model
init_portfolio['approxRiskyDstn'] = RiskyDstnFunc
init_portfolio['drawRiskyFunc']   = RiskyDrawFunc
init_portfolio['RiskyCount']      = 2   # Number of points in the approximation; 2 points is minimum
init_portfolio['RiskyShareCount'] = 25  # How many discrete points to allow in the share approximation
init_portfolio['Rfree']           = 1.0 # Riskfree return factor is 1 (interest rate is zero)
init_portfolio['CRRA']            = 6.0 # Relative risk aversion

# Uninteresting technical parameters:
init_portfolio['aXtraMax']        = 100 
init_portfolio['aXtraCount']      = 50
init_portfolio['BoroCnstArt']     = 0.0 # important for theoretical reasons
# init_portfolio['vFuncBool'] = True # We do not need value function for purposes here