econ-ark / DistributionOfWealthMPC

The Distribution of Wealth and the Marginal Propensity to Consume
2 stars 8 forks source link

do_mid.py not working #27

Open alanlujan91 opened 11 months ago

alanlujan91 commented 11 months ago
Beginning an estimation with the specification name PYUnifbetaPointAggNetWorth...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~\GitHub\alanlujan91\DistributionOfWealthMPC\do_mid.py:18
     15 point_options = basic_options.copy()
     16 point_options.update(all_options["MainSpecPoint"])
---> 18 estimate(point_options, parameters)
     20 # Run beta-dist model
     22 dist_options = basic_options.copy()

File ~\GitHub\alanlujan91\DistributionOfWealthMPC\code\estimation.py:520, in estimate(options, params)
    516 else:
    517     # Run the param-point estimation only
    519     t_start = time()
--> 520     center_estimate = root_scalar(
    521         get_ky_ratio_difference,
    522         args=(
    523             0.0,
    524             economy,
    525             options["param_name"],
    526             param_count,
    527             options["dist_type"],
    528         ),
    529         method="brenth",
    530         bracket=param_range,
    531         xtol=1e-6,
    532     ).root
    533     spread_estimate = 0.0
    534     t_end = time()

File ~\mambaforge\envs\cstwmpc\lib\site-packages\scipy\optimize\_root_scalar.py:279, in root_scalar(f, args, method, bracket, fprime, fprime2, x0, x1, xtol, rtol, maxiter, options)
    277 a, b = bracket[:2]
    278 try:
--> 279     r, sol = methodc(f, a, b, args=args, **kwargs)
    280 except ValueError as e:
    281     # gh-17622 fixed some bugs in low-level solvers by raising an error
    282     # (rather than returning incorrect results) when the callable
    283     # returns a NaN. It did so by wrapping the callable rather than
    284     # modifying compiled code, so the iteration count is not available.
    285     if hasattr(e, "_x"):

File ~\mambaforge\envs\cstwmpc\lib\site-packages\scipy\optimize\_zeros_py.py:913, in brenth(f, a, b, args, xtol, rtol, maxiter, full_output, disp)
    911     raise ValueError(f"rtol too small ({rtol:g} < {_rtol:g})")
    912 f = _wrap_nan_raise(f)
--> 913 r = _zeros._brenth(f, a, b, xtol, rtol, maxiter, args, full_output, disp)
    914 return results_c(full_output, r)

File ~\mambaforge\envs\cstwmpc\lib\site-packages\scipy\optimize\_zeros_py.py:90, in _wrap_nan_raise.<locals>.f_raise(x, *args)
     89 def f_raise(x, *args):
---> 90     fx = f(x, *args)
     91     f_raise._function_calls += 1
     92     if np.isnan(fx):

File ~\GitHub\alanlujan91\DistributionOfWealthMPC\code\estimation.py:82, in get_ky_ratio_difference(center, spread, economy, param_name, param_count, dist_type)
     80 # Distribute parameters
     81 economy.distribute_params(param_name, param_count, center, spread, dist_type)
---> 82 economy.solve()
     83 diff = economy.calc_KY_ratio_difference()
     84 print(f"get_KY_ratio_difference tried center = {center} and got {diff}")

File ~\GitHub\alanlujan91\DistributionOfWealthMPC\code\agents.py:228, in CstwMPCMarket.solve(self)
    226     for agent in self.agents:
    227         agent.get_economy_data(self)
--> 228     Market.solve(self)
    229 else:
    230     self.solve_agents()

File ~\mambaforge\envs\cstwmpc\lib\site-packages\HARK\core.py:1433, in Market.solve(self)
   1431 while go:  # Loop until the dynamic process converges or we hit the loop cap
   1432     self.solve_agents()  # Solve each AgentType's micro problem
-> 1433     self.make_history()  # "Run" the model while tracking aggregate variables
   1434     new_dynamics = self.update_dynamics()  # Find a new aggregate dynamic rule
   1436     # Check to see if the dynamic rule has converged (if this is not the first loop)

File ~\mambaforge\envs\cstwmpc\lib\site-packages\HARK\core.py:1604, in Market.make_history(self)
   1602 self.cultivate()  # Agents take action
   1603 self.reap()  # Collect individual data from agents
-> 1604 self.mill()  # Process individual data into aggregate data
   1605 self.store()

File ~\mambaforge\envs\cstwmpc\lib\site-packages\HARK\core.py:1513, in Market.mill(self)
   1510 mill_dict.update(self.const_vars)
   1512 # Run the mill_rule and store its output in self
-> 1513 product = self.mill_rule(**mill_dict)
   1515 for i, sow_var in enumerate(self.sow_state):
   1516     self.sow_state[sow_var] = product[i]

File ~\GitHub\alanlujan91\DistributionOfWealthMPC\code\agents.py:276, in CstwMPCMarket.mill_rule(self, aLvl, pLvl, MPCnow, TranShk, EmpNow, WeightFac, t_age)
    272 def mill_rule(self, aLvl, pLvl, MPCnow, TranShk, EmpNow, WeightFac, t_age):
    273     """
    274     The mill_rule for this class simply calls the method calc_stats.
    275     """
--> 276     self.calc_stats(
    277         aLvl,
    278         pLvl,
    279         MPCnow,
    280         TranShk,
    281         EmpNow,
    282         WeightFac,
    283         t_age,
    284         self.parameters["LorenzBool"],
    285         self.parameters["ManyStatsBool"],
    286     )
    288     if self.AggShockBool:
    289         return self.calc_R_and_W(aLvl, pLvl)

File ~\GitHub\alanlujan91\DistributionOfWealthMPC\code\agents.py:339, in CstwMPCMarket.calc_stats(self, aLvlNow, pLvlNow, MPCnow, TranShkNow, EmpNow, WeightFac, t_age, LorenzBool, ManyStatsBool)
    337 aLvl = np.hstack(aLvlNow)
    338 pLvl = np.hstack(pLvlNow)
--> 339 CohortWeight = np.hstack(WeightFac)
    340 age = np.hstack(t_age)
    341 TranShk = np.hstack(TranShkNow)

File ~\mambaforge\envs\cstwmpc\lib\site-packages\numpy\core\shape_base.py:359, in hstack(tup, dtype, casting)
    357     return _nx.concatenate(arrs, 0, dtype=dtype, casting=casting)
    358 else:
--> 359     return _nx.concatenate(arrs, 1, dtype=dtype, casting=casting)

ValueError: need at least one array to concatenate