Repository: econ-ark/hark
Issue: ConsPortfolioModel does not work with AdjustProb < 1

@pkofod:

@MridulS and I spent the morning going over the ConsPortfolioModel and making sure it all worked.  We've made a [DemARK](https://github.com/econ-ark/DemARK) called ConsPortfolioModelDoc.ipynb mostly based on the demo file you had provided.

But we could not get one thing to work:  You had an example of the version that allows the probability of adjustment to be less than one, but it was calibrated with the probability equal to one.  When we tried to run it with AdjustProb < 1, it crashed with an error that looked like it was trying to evaluate utility at consumption of zero.  

Am guessing this will be an easy one for you to fix, but it wasn't so easy for Mridul and me to track down the problem, so I've assigned it to you.


Changed files:
HARK/ConsumptionSaving/ConsPortfolioModel.py

diff --git a/HARK/ConsumptionSaving/ConsPortfolioModel.py b/HARK/ConsumptionSaving/ConsPortfolioModel.py
index ef3e80d5..13b21d63 100644
--- a/HARK/ConsumptionSaving/ConsPortfolioModel.py
+++ b/HARK/ConsumptionSaving/ConsPortfolioModel.py
@@ -226,8 +226,6 @@ def _calcwFunc(AdjustPrb, AdjustCount, ShareNowCount, vFunc_adj, CRRA):
     integrand : function (lambda)
         Can be used to evaluate the integrand and the sent to a quadrature procedure.
     '''
-    if AdjustPrb < 1:
-        raise Exception('The code allowing probabilities of adjustment less than 1 is not working yet; release notes will indicate when we have a release where it work')
 
     # AdjustCount could in principle just be inferred from AdjustPrb instead of
     # cartying it arround FIXME / TODO
@@ -244,9 +242,6 @@ def _calcwFunc(AdjustPrb, AdjustCount, ShareNowCount, vFunc_adj, CRRA):
             evVals = AdjustPrb*vFunc_adj[0][ShareIndex](evalgrid) + (1-AdjustPrb)*vFunc_adj[1][ShareIndex](evalgrid)
             with np.errstate(divide='ignore', over='ignore', under='ignore', invalid='ignore'):
                 evValsNvrs = utility_inv(evVals,gam=CRRA)
-            evVals = np.insert(evVals, 0, 0.0)
-            evValsNvrs = np.insert(evVals, 0, 0.0)
-
             wFunc.append(ValueFunc(LinearInterp(evVals, evValsNvrs), CRRA))
 
     return wFunc
@@ -290,23 +285,23 @@ class PortfolioSolution(Solution):
                        vPfunc=None, RiskyShareFunc=None, vPPfunc=None,
                        mNrmMin=None, hNrm=None, MPCmin=None, MPCmax=None):
         """We implement three different ways to allow portfolio choice.
-           The agent can choose 
+           The agent can choose
               * any portfolio share ('continuous choice')
               * only a specified set of portfolio shares ('discrete choice')
                 * With probability 1 (agent always gets to choose)
                 * With probability 0 < p < 1 (stochastic chance to choose)
-        
-           We allow two choices for the description of the 
+
+           We allow two choices for the description of the
            distribution of the stochastic variable:
            1. A generic discrete probability distribution
               * Nodes and their probabilities are specified
            2. A true lognormal distribution
               * The mean return and the standard deviation are specified
-        
+
            In the discrete portfolio shares case, the user also must
            input a function that *draws* from the distribution in drawRiskyFunc
 
-           Other assumptions: 
+           Other assumptions:
               * distributions are time constant
               * probability of being allowed to reoptimize is time constant
                  * If p < 1, you must specify the PortfolioSet discretely