Exemple #1
0
    def postSolve(self):
        '''
        This method adds consumption at m=0 to the list of stable arm points,
        then constructs the consumption function as a cubic interpolation over
        those points.  Should be run after the backshooting routine is complete.

        Parameters
        ----------
        none

        Returns
        -------
        none
        '''
        # Add bottom point to the stable arm points
        self.solution[0].mNrm_list.insert(0, 0.0)
        self.solution[0].cNrm_list.insert(0, 0.0)
        self.solution[0].MPC_list.insert(0, self.MPCmax)

        # Construct an interpolation of the consumption function from the stable arm points
        self.solution[0].cFunc = CubicInterp(self.solution[0].mNrm_list,
                                             self.solution[0].cNrm_list,
                                             self.solution[0].MPC_list,
                                             self.PFMPC * (self.h - 1.0),
                                             self.PFMPC)
        self.solution[0].cFunc_U = lambda m: self.PFMPC * m
Exemple #2
0
    def makevFunc(self, solution):
        '''
        Make the beginning-of-period value function (unconditional on the shock).
        
        Parameters
        ----------
        solution : ConsumerSolution
            The solution to this single period problem, which must include the
            consumption function.
            
        Returns
        -------
        vFuncNow : ValueFunc
            A representation of the value function for this period, defined over
            normalized market resources m: v = vFuncNow(m).
        '''
        # Compute expected value and marginal value on a grid of market resources,
        # accounting for all of the discrete preference shocks
        PrefShkCount = self.PrefShkVals.size
        mNrm_temp = self.mNrmMinNow + self.aXtraGrid
        vNrmNow = np.zeros_like(mNrm_temp)
        vPnow = np.zeros_like(mNrm_temp)
        for j in range(PrefShkCount):
            this_shock = self.PrefShkVals[j]
            this_prob = self.PrefShkPrbs[j]
            cNrmNow = solution.cFunc(mNrm_temp,
                                     this_shock * np.ones_like(mNrm_temp))
            aNrmNow = mNrm_temp - cNrmNow
            vNrmNow += this_prob * (this_shock * self.u(cNrmNow) +
                                    self.EndOfPrdvFunc(aNrmNow))
            vPnow += this_prob * this_shock * self.uP(cNrmNow)

        # Construct the beginning-of-period value function
        vNvrs = self.uinv(vNrmNow)  # value transformed through inverse utility
        vNvrsP = vPnow * self.uinvP(vNrmNow)
        mNrm_temp = np.insert(mNrm_temp, 0, self.mNrmMinNow)
        vNvrs = np.insert(vNvrs, 0, 0.0)
        vNvrsP = np.insert(vNvrsP, 0,
                           self.MPCmaxEff**(-self.CRRA / (1.0 - self.CRRA)))
        MPCminNvrs = self.MPCminNow**(-self.CRRA / (1.0 - self.CRRA))
        vNvrsFuncNow = CubicInterp(mNrm_temp, vNvrs, vNvrsP,
                                   MPCminNvrs * self.hNrmNow, MPCminNvrs)
        vFuncNow = ValueFunc(vNvrsFuncNow, self.CRRA)
        return vFuncNow