def perturbParameterToGetcPlotList(base_dictionary, param_name, param_min, param_max, N=20, time_vary=False): param_vec = np.linspace( param_min, param_max, num=N, endpoint=True ) # vector of alternative values of the parameter to examine thisConsumer = IndShockConsumerType( **my_dictionary) # create an instance of the consumer type thisConsumer.cycles = 0 # Make this type have an infinite horizon x = np.linspace( mMinVal, mMaxVal, xPoints, endpoint=True ) # Define a vector of x values that span the range from the minimum to the maximum values of m for j in range( N): # loop from the first to the last values of the parameter if time_vary: # Some parameters are time-varying; others are not setattr(thisConsumer, param_name, [param_vec[j]]) else: setattr(thisConsumer, param_name, param_vec[j]) thisConsumer.update( ) # set up the preliminaries required to solve the problem thisConsumer.solve() # solve the problem y = thisConsumer.solution[0].cFunc( x ) # Get the values of the consumption function at the points in the vector of x points pylab.plot( x, y, label=str(round(param_vec[j], 3)) ) # plot it and generate a label indicating the rounded value of the parameter pylab.legend(loc='upper right') # put the legend in the upper right return pylab # return the figure
def update(self): ''' Updates the assets grid, income process, terminal period solution, and preference shock process. A very slight extension of IndShockConsumerType.update() for the preference shock model. Parameters ---------- None Returns ------- None ''' IndShockConsumerType.update(self) # Update assets grid, income process, terminal solution self.updatePrefShockProcess() # Update the discrete preference shock process