-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More general grids for decision rules #188
Comments
@sbenthall is right about the same variable being a state vs a control during different stages. For example, we solve the joint saving-and-portfolio-share model by constructing a grid of possible values of assets with which you might end the period, calculating the optimal portfolio share for a person ending the period with that At present in HARK we solve this problem with hand-crafted tools. In the portfolio share tool, So, your proposal is to find all of the variables that are either states or controls at any stage of the problem and make a grid that incorporates all of them. I'm trying to understand what you mean by a "locator" variable by thinking of an example. So, if one of the exogenous variables was your employment state, we might want to retrieve an object that would tell us the range of values of consumption that are feasible for unemployed people, and a different range for employed people? This would be an intermediate product in the multistage problem, and could be fed back to an earlier stage that would conduct its search within the appropriate range of values contingent on state? On the last point, about using endo_grid and exo_grid (I'd really prefer exog_grid so they are the same length) everywhere, do you mean that we would allow for a different endo_grid and exog_grid at each "stage" of the solution? Otherwise I don't see how this deals with the problem that at some stages a variable might be a state and at other stages a control. |
I think there is a slight misunderstanding about the meaning of endo_grid
and exo_grid here. in dolo the difference is that one is exogenously
determined before the solution even begins. The second corresponds to
states that are attained as a function of (exo and endo) states.
Essentially, the latter are the one you need to interpolate on.
This is different from the state, post-state distinction which comes from
the time succession of choices within a period.
There is a connection though : a more general concept of a "state" could be
used for such a purpose.
…On Mon, Mar 9, 2020, 5:47 PM Christopher Llorracc Carroll < ***@***.***> wrote:
@sbenthall <https://github.com/sbenthall> is right about the same
variable being a state vs a control during different stages. For example,
we solve the joint saving-and-portfolio-share model by constructing a grid
of possible values of assets with which you might end the period,
calculating the optimal portfolio share for a person ending the period with
that $a$, and then constructing marginal utility conditional on optimal
portfolio choice, which yields optimized marginal value for ending the
period with that $a$. From the perspective of the beginning of the period,
however, the consumer's problem can be written as choosing the optimal $a$.
So, it's a control at the first stage of the problem within the period, and
a state at the next stage.
At present in HARK we solve this problem with hand-crafted tools. In the
portfolio share tool, $a$ is hard-wired as a state; but the consumption
problem (which knows nothing about the portfolio choice tool except its
output, $v'(a)$).
So, your proposal is to find all of the variables that are either states
or controls at any stage of the problem and make a grid that incorporates
all of them.
I'm trying to understand what you mean by a "locator" variable by thinking
of an example. So, if one of the exogenous variables was your employment
state, we might want to retrieve an object that would tell us the range of
values of consumption that are feasible for unemployed people, and a
different range for employed people? This would be an intermediate product
in the multistage problem, and could be fed back to an earlier stage that
would conduct its search within the appropriate range of values contingent
on state?
On the last point, about using endo_grid and exo_grid (I'd really prefer
exog_grid so they are the same length) everywhere, do you mean that we
would allow for a different endo_grid and exog_grid at each "stage" of the
solution? Otherwise I don't see how this deals with the problem that at
some stages a variable might be a state and at other stages a control.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#188>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDSKOUV3GZIEWLKDQZH6TRGUMTFANCNFSM4LAUWLKQ>
.
|
The way I think about it is this:
|
I don't think the programming interface can be separated from careful thinking about implementation, because it is not useful to have a programming interface that you later realize is impossible (or unnecessarily difficult) to implement, but "if only we had thought about implementation, we could have achieved the goal just as well with a different syntax but one that can be implemented straightforwardly.) But "careful thinking" about implementation is not the same as implementation itself. These discussions seem to me to be at exactly the right level: We are thinking about fundamental questions about how the models will be represented, and then thinking about the grammar to efficiently capture that. My idea is that, as we work on a grammar for these kinds of models, we should be doing "mock implementations" of various models in HARK that cannot run yet, but where writing the models in the grammar tests whether the grammar is actually capable of expressing all the things we need it to. |
A perhaps complementary approach would be to create some examples of ideal input/output pairs for the system you are trying to build, bracketing off the question of implementation. This would allow you to express concrete, difficult requirements you might have for the software. |
Just to clarify what I mean by the implicit DAG structure in the dependency relations between the model variables, I've added graphical representations to this notebook where I'm representing consumption problems in MDP form: https://github.com/sbenthall/sketches/blob/master/economics/PortfolioConsumptionMath.ipynb Squares are control variables. Diamond is 'reward' for each period. I'm using 'prime' not subscripting 't+1'. I believe that:
For example, note the section in that notebook on Portfolio Choice. In it, there is an exogenous shock An important question for the model, which may not be obvious in a different representation, is whether the consumer knows |
I'm afraid this thread has drifted a bit away from the semi-simple idea I was trying to describe. There are two conceptually distinct problems:
|
I see. What I am saying is that the interface to a concretely solved decision rule could be more general even than its implementation, which uses grids. That interface could be selected based on what traffics well between well-defined use cases. In any case, I believe: At this level of abstraction, I am not seeing any constraint specifying that the decision rule needs to be implemented as a set of grids, cartesian or not. But maybe I'm missing something. |
Sticking to the decision rule / grid question, I've got two more comments:
|
What you are describing:
sounds like a good way to implement a mathematical function that is an interpolation over multiple dimensions of grid points. I think it would make the most sense to implement that functionality in the most general possible way, without complicating it with the specific semantics of being "a decision rule", or having its inputs be either endogenous or exogenous. This implementation of a function could then be used to implement a "decision rule", which is an object with additional semantics: it is connected to a control variable in a model; its inputs are some subset of the other variables in the model; it can be a variable in the model which other variables depend on; it is the output of a solver. |
Oh, I completely agree with the comment that |
I wonder if this interpolated-function object would ever be used in a situation where it is not a control variable. For example, supposed one wanted to fit an exogenous distribution over an irregular empirical data set. |
Well by definition, a decision rule, is a policy function, is a function (is a rose is a rose) so I"m not going to argue. Renaming it |
!!!! This reads like a mistake to me. Maybe I should make an issue for it.
That does sound very nice. I think there's a subtle question about when and how Python names and the names of model variables are used. I imagine R and Julia have good solutions to this? One thing I do not like about HARK is that all model variables are hard-coded into the objects. It is one thing that is going to make integration with Dolo difficult. I am trying to figure out a way to gracefully move HARK away from that. |
Actually, after reflecting about it for a while, I'm 65% of sold on the medium run usefulness of a separate "function" library (unless it is exactly the same as the interpolation library). At any rate there are significant design issues to be solved so I don't want to address it right now. (Even ignoring the fact that economist will probably want to keep special jargon like states/controls instead of input/input.) |
I don't get the subtle question about variable naming. Nothing would be hardcoded. |
I'm very glad that we're converging on design ideas! I'm lukewarm on "Function" as the name of a class, because...well, it's so overloaded in programming anyway. I see what you mean about having a 'names' section--yes, that's sensible. I spent the afternoon coding this up as a mockup 'design' that sketches out a bit what I've been thinking. Maybe it will clarify some of what I've been getting at? https://github.com/sbenthall/sketches/blob/master/economics/MDP%20Interfaces.ipynb |
I'm not really sure how you see the connection with the design you propose.
It seems a bit like an agent based design with each variable an agent .
This works for simulation but how does it help solving a system of forward
looking equations ?
…On Tue, Mar 10, 2020, 10:14 PM Sebastian Benthall ***@***.***> wrote:
I'm very glad that we're converging on design ideas!
I'm lukewarm on "Function" as the name of a class, because...well, it's so
overloaded in programming anyway.
I see what you mean about having a 'names' section--yes, that's sensible.
I spent the afternoon coding this up as a mockup 'design' that sketches
out a bit what I've been thinking. Maybe it will clarify some of what I've
been getting at?
https://github.com/sbenthall/sketches/blob/master/economics/MDP%20Interfaces.ipynb
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#188>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDSKO2OZGAPKWTWDCXMMDRG2UTJANCNFSM4LAUWLKQ>
.
|
Pablo is saying the same thing I am.
What's missing from the MDP framework is the Bellman apparatus which
embodies the agent's understanding of the future. That is the hard part.
The MDP framework is basically accounting. (Defining the structure of the
problem). The Bellman framework adds the ingredients necessary to define a
_solution_ to the problem when agents can understand the consequences of
their actions.
The reinforcement learning, machine learning, and many other methods
(q-learning) are methods that may or may not eventually identify a decision
rule that is optimal. But we always want to be able to compare any
alternative (like reinforcement learning) to the optimal solution, and for
that we need the Bellman framework.
On Wed, Mar 11, 2020 at 12:00 AM Pablo Winant <[email protected]>
wrote:
… I'm not really sure how you see the connection with the design you propose.
It seems a bit like an agent based design with each variable an agent .
This works for simulation but how does it help solving a system of forward
looking equations ?
On Tue, Mar 10, 2020, 10:14 PM Sebastian Benthall <
***@***.***>
wrote:
> I'm very glad that we're converging on design ideas!
>
> I'm lukewarm on "Function" as the name of a class, because...well, it's
so
> overloaded in programming anyway.
>
> I see what you mean about having a 'names' section--yes, that's sensible.
>
> I spent the afternoon coding this up as a mockup 'design' that sketches
> out a bit what I've been thinking. Maybe it will clarify some of what
I've
> been getting at?
>
>
>
https://github.com/sbenthall/sketches/blob/master/economics/MDP%20Interfaces.ipynb
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <
#188
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AACDSKO2OZGAPKWTWDCXMMDRG2UTJANCNFSM4LAUWLKQ
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#188>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKCK72ALFLTLCYTFXQHCLDRG3BBZANCNFSM4LAUWLKQ>
.
--
- Chris Carroll
|
I'm afraid we may be speaking past each other. For the purpose of this discussion, I was trying to demonstrate that the representation of a mathematical function (done simply with lambdas, in that case) can be done separately from the representation of the semantics of the function's relationship to a variable (i.e., as a transition function for a state, as a decision rule as applied to a choice variable, as a value function, etc.) |
One more thought on this topic.... A discussion came up the other day in HARK about the representation of exogenous shock distributions. I see now that this was the conversation that was cut short by networking issues... While considering class structures and interoperability of different implementations, I wonder if it's worth considering if exogenous distributions might be represented in ways besides a grid. If this is all quite peripheral or a distraction, I apologize; of course, I'm not as embedded in the core roadmap of the Dolo project. |
This is actually part of the design. When you put an AR1 in a model, |
This issue stems from two discussions:
It is also related to the new implementation of d.r. in dolark which I just moved to dolo.
Long term proposal would be to define a d.r. object as a function of a single grid with an exogenous and an endogenous component. The basic case would be a Cartesian product of two grids and would correspond to what we currently do but it could then be extended to non Cartesian products ( for instance ranges of endogenous vars as a function of exogenous values) or other products. This is non problematic I think.
To accomodate the discrete vs continuous variable the idea would be to introduce a 'locator' function that would be defined by the grid and that we would treat in the same way whether it's discrete it not. That part is problematic and needs to be thought of in conjunction with potential discrete choices to be dealt with I the future.
This is a long term issue. In the short term my proposal would be to make sure we use endo_grid and exo_grid everywhe instead of grid which will eventually denote the product of them. One question is what to do with the grid option in the yaml file : it refers to the endogenous grid. It's not a big deal since it's not an actual section, like domain.
The text was updated successfully, but these errors were encountered: