Once your code has called CreateSpaces()
your DP model is set up and ready to be solved. To do this, apply a solution method to the model, which is an object derived from the Method class. You can apply more than one method to your problem, although some methods only work with some kinds of models.
Every Method has a Solve()
function that applies the method to the DP problem. Solution methods work at the highest level of the DP environment. That is, if your DP environment involves multiple problems (because it includes fixed and random effects), the solution method will call methods to handle each specific DP problem. (It is possible to specify that only one problem be solved, and this is used to efficiently parallelize the solution of many DP problems over a cluster.)
The most flexible way to use a solution method is to create a new object of the method and then call its Solve
routine in any place of the code. This approach is necessary when using a nested algorithm in which the DP solution is embedded inside some other iteration (such as estimating parameters of the model). Some solution methods have a simpler version in which the code calls a function that creates the method for the user, applies it solve routine and then deletes the method. Both possibilities are shown here:
MyModel
with brute force value function iteration:⋮ CreateSpaces(); vmax = new ValueIteration(); vmax.Volume = LOUD; //V(θ) printed when computed vmax -> Solve(); ⋮
⋮ CreateSpaces(); VISolve(); ⋮
Solve()
|
Loop over fixed effect variables in γ, solve each problem by calling the RandomSolve() task. Reuse the solution storage space for each fixed effect to conserve on memory. |
||||||||||
|
For the current fixed group, loop over random effect variables in γ. Solve each problem by calling GSolve(). Reuse value iteration space but store choice probabilities for all random effect groups. | ||||||||||
|
Given the fully specified fixed vector γ (a group), which defines an element of the group space, solve the DP problem. This is where the state space \(\Theta\) is traversed applying Bellman's equation at each point. | ||||||||||
|
1. Run loop over bellman iterations (or other task) 2. Update check convergence/work backwards (return to 1 until finished.) |
Method ValueIteration HotzMiller SolveAsSystem ReservationValues
brute forceBellman Equation iteration.
CreateSpaces(); ⋮ decl vmax = new ValueIteration(); vmax -> Solve();
CreateSpaces(); ⋮ SubSampleStates(0.4); decl kw = new KeaneWolpin(); kw -> Solve();
CreateSpaces(); ⋮ HM = new HotzMiller(data);
a
can take on any number of values. To enforce this, MyModel
must be derived from the OneDimensionalChoice class.T=10
) to search over job offersz*
at each t
.policyiteration not
value functioniteration.
z*
Uz(z)
. It returns a column vector with U(0,z*)|U(1,z*)|….
. (More generally when there are more N
choices and N-1
cut-off values it should return a N × N-1
matrix.a=0
given z*: \(E[U(0,z)|z\le z*]\). a=1
given z*: \(E[U(1,z)|z>z*]\).EUtility()
which returns an array. The first element is a vector of expected utility differences. The second
is a vector of probabilities.
Source: examples/misc/WStarA.h
Source: examples/misc/WStarA.ox
Source: examples/output/Reservation_Wage_Test.txt
Source: examples/misc/WStarA.pdf
Functions | ||
RVSolve | Simplified Reservation Value Iteration model solution. | |
VISolve | All-in-one Value Iteration. | |
Enumerations | ||
KWstages | stages of Keane-Wolpin approximation | |
SystemAlgorithms | Tags for Nonlinear System Solver Algorithms. |
Public methods | ||
AguirregabiriaMira | ||
Solve | Carry out a solution method. |
Public methods | ||
AMGSolve | ||
Run | Apply the method (default is Bellman equation) at a point \(\theta\). | |
Solve | Interate over the state space apply the solution method. |
Public fields | ||
bandwidth | static | |
cnt | static | |
data | static | Panel containing data. |
Kernel | static | |
Kstates | static | |
NotFirstTime | static | |
ObsPstar | static | |
Public methods | ||
CCP | Collect observed choice frequencies from a dataset. | |
Run |
Public fields | ||
dsrc | ||
Public methods | ||
CCPspace |
Public methods | ||
DynamicRsystem | Solve a dynamic reservation system. |
Public methods | ||
EVSystem | Initialize EV() as a system of non-linear equations. |
Public fields | ||
AuxRun | Flag set if extra loop after converging, e.g. | |
MaxTrips | Fixed limit on number of iterations. | |
RunSafe | TRUE (default): exit if NaNs encountered during iteration FALSE: exit with IterationFailed |
|
succeed | TRUE if all tasks suceed. | |
Volume | Amount of ouptut to produce | |
vtoler | Tolerance on value function convergence in stationary environments. | |
Public methods | ||
AuxiliaryRun | virtual | |
Run | virtual | Apply the method (default is Bellman equation) at a point \(\theta\). |
Solve | virtual | Interate over the state space apply the solution method. |
Public fields | ||
Q | static | F×1 array of CCPs. |
tmpP | static | |
Public methods | ||
HMGSolve | ||
Run | Apply the method (default is Bellman equation) at a point \(\theta\). | |
Solve | Interate over the state space apply the solution method. |
Public fields | ||
AMstep | static | |
data | ||
pdelt | static | |
Public methods | ||
AMiter | ||
EmpiricalCCP | ||
HotzMiller | Create a Hotz-Miller solution method. | |
Solve | Carry out a solution method. |
t
.2
value is the median
and will be used for the extrapolation.I::t
.Emax(θ) ≡ ∑ ε Ρε V(ε,θ)which is the expected value of the maximum
V(ε,θ) = max α∈θ.A v(α;ε,θ)When ε and θ both include many states, visiting every value of ε for every value of θ can be expensive.
Emax
for a randomly selected subset of states at a given t:ΘKW(t) ⊂ Θ(t).where Θ(t) is the subset of Θ with states at time t.
Emax
with a function (such as a linear regression) of the values of v(α;ε,θ)
at a
single exogenous vector, ε, including the non-linear transformation:
maxE(θ) ≡ max α∈A(θ) v(α;ε,θ)
When ε = E(ε) then this is indeed the max at the expected exogenous shock.
maxE(θ) and v(α;ε,θ).
max()
operations avoided is
(ε.D-1)(Θ.D-ΘKW.D) / Θ.D
Public methods | ||
KeaneWolpin | Create a Keane-Wolpin Approximation method. |
Public fields | ||
Bhat | N::T array of OLS coefficients | |
curlabels | ||
EMax | Computed EV vector | |
firstpass | ||
maxE | maxE vector | |
onlypass | ||
Xmat | X matrix | |
Public methods | ||
InSample | virtual | |
OutSample | virtual | |
Specification | virtual | The default specification of the KW regression. |
Public fields | ||
DefTolerance | static const | Default convergence tolerance on Bellman Iteration for stationary environments = DIFF_EPS = 10^{-8}. |
DoNotIterate | FALSE(default): iterate on V(θ) TRUE: only compute transitions. |
|
Rgroups | Either r or AllRan to solve for all random effects. | |
Volume | Output from the solution method. | |
vtoler | ||
Public methods | ||
Method | Base of all DP solution methods | |
Solve | virtual | Carry out a solution method. |
ToggleIterate | Toggle whether to Iterate on Bellman's Equation. | |
ToggleRunSafe | Toggle whether to check for NaNs in value iteration. | |
Tune | virtual | Set basic parameters of a solution method. |
SetP=TRUE
and SetPtrans=TRUE
to compute the state-to-state transition on each iteration.Public methods | ||
NewtonKantorovich | Creates object that starts as ValueIteration then switches to N-K iteration. | |
Solve | virtual | Solve Bellman's Equation switching to N-K when a tolerance is reached. |
Tune | Set min NK trips and NK tolerance. |
Public fields | ||
myt | ||
Nstat | ||
onlyactive | ||
visit |
Public fields | ||
MinNKtrips | Minimum trips before N-K. | |
NKlist | ||
NKstep0 | setting up Newton-Kantorovich iteration. | |
NKtoler | tolerance for switching to NK, |
Public fields | ||
retval |
MyModel
to be derived from OneDimensionalChoice.
d
:α = (d)
z
:ζ = (z)
z*0 < z*1 < … < z*d.N‾-1which are cutoff or reservation values for the values of z, the one-dimensional continuous state variable.
d* = j ⇔ z ∈ (z*j-1,z*j)Note that z*-1 ≡ -∞ and z*d.N ≡ +∞
a* = a iff za-1 < ω ≤ za. z-1 ≡ -∞ za.N ≡ +∞
Continuous()
method. If so, create storage for \(z^\star\) at \(\th.\)EUtility()
that provides \(F(z^\star)\) and \(E[U|A(\th),z^\star]\) to compute \(V(\th)\) based on \eqref{EVz}.Public fields | ||
CheckDominatedOptions | static | check that options are dominated at the lower bound and should not be solved for. |
Public methods | ||
ReservationValues | The method to find reservation values. | |
Solve | Solve reservation values for some or all groups. |
Public fields | ||
c | . | |
curth | current θ . | |
dV | \(\delta EV\) vector. | |
lbv | lower bound of cut-off parameters. | |
meth | const | non-linear system solver |
Ncuts | const | number of reservation values (#options-1) |
ru | ||
zstar | const | Increasing parameter block for z* |
Public methods | ||
Rsystem | Create a system of nonlinear equations to solve for reservation values. | |
RVSolve | Solve for reservation values at \(\theta\) given \(\delta EV\). |
Public fields | ||
RValSys | Objectives for each Α | |
Public methods | ||
RVGSolve | ||
Solve | Span \(\Theta\) solving at each point. |
Public methods | ||
Run | Apply the method (default is Bellman equation) at a point \(\theta\). | |
SaSGSolve | ||
Solve | Interate over the state space apply the solution method. |
EV(θ) - EV'(θ) = 0.Rather than iterating on Bellman's equation from some initial EV'(θ), this approach uses Newton-Raphson root solving to find the solution. This can be much faster, but less certain of success, than Bellman iteration, especially when δ is near 1.
Public fields | ||
system | const | |
SystemSolutionMethod | ||
VI | const | |
Public methods | ||
Solve | Carry out a solution method. | |
SolveAsSystem |
Public methods | ||
Solve | virtual | Solve Bellman's Equation using brute force iteration over the state space. |
ValueIteration | Create a new "brute force" Bellman iteration method. |
ToScreen | TRUE [default] means output is displayed . |
aM | address to return matrix 0, do not save [default] VISolve() works. |
VISolve()
VISolve()
works.Solve()
routine and then deletes the object.ToScreen | TRUE [default] means output is displayed to output. |
aM | address to return matrix of values and choice probabilities0, do not save [default] |
MaxChoiceIndex | FALSE: print choice probability vector [default] TRUE: only print index of choice with max probability. Useful when the full action matrix is very large. |
TrimTerminals | FALSE [default] TRUE: states marked Type>=TERMINAL are deleted from the output |
TrimZeroChoice | FALSE [default] TRUE: states with no choice are deleted |
Fgroups | either AllFixed or a specific fixed group \(\gamma_f\) to solve |
Rgroups | if AllFixed then must be AllRand. Otherwise, specific \(\gamma_r\) |
IterationFailed
Fgroups | either AllFixed or a specific fixed group \(\gamma_f\) to solve |
Rgroups | if AllFixed then must be AllRand. Otherwise, specific \(\gamma_r\) |
myGSolve | [user code should not provide this]. Default is KWGSolve |
kwstep | which step of KW approximation to perform |
maxEV | |
Vdelta | (V-vv)' The default is to run the regression: $$\hat{V}-V_0 = X\beta_t.\nonumber$$ The default specification of the row of state-specific values is $$X =\l(\matrix{\l(V_0-v_0\r) & \sqrt{V_0-v_0}}\r).\nonumber$$ That is, the difference between Emax and maxE is a non-linear function of the differences in action values at the median shock. |
myGSolve | a method that does the iteration over \(|Theta\) (user code does not set this) |
Fgroups | either AllFixed or a specific fixed group \(\gamma_f\) to solve |
Rgroups | if AllFixed then must be AllRand. Otherwise, specific \(\gamma_r\) |
ToggleOnlyTrans | TRUE [default] also toggle OnlyTransitions so choice probabilities do not apply in likelihood calculation. This is used by DataObjectives that are maximized using "2 Stage" iteration. |
Volume | UseCurrent (-2) do not change Volume level for output, vtoler UseCurrent (-2) do not change convergence criteria for stationary problems (fixed points) MaxTrips UseCurrent (-2) do not change integer: set the total number of iterations to perform (stationary problems) 0 : unlimited trips (stopping determined by tolerance and convergence) NormType set the norm() itype argument for Ox's norm(v,itype) function only applies to stationary phases of clocks. UseCurrent(-2) do not change (default=2,Euclidean) 0: infinity norm, maximum absolute value, 1: sum of absolute values, 2: square root of sum of squares, p: p-th root of sum of absolute elements raised to the power p. -1: minimum absolute value, |
myGSolve | 0 (default), built in task will be used. GSolve-derived object to use for iterating over endogenous states |
Fgroups | DoAll, loop over fixed groups non-negative integer, solve only that fixed group index |
Rgroups | |
MaxTrips | 0, iterate until convergence positive integer, max number of iterations -1 (ResetValue), reset to 0. |
MinNKtrips | if not -1 (UseDefault) then minimum trips before switching to N-K |
NKtoler | if not UseDefault then tolerance to switch to N-K |
LB | AV compatible lower bound on the value of the first reservation value. Optional: Default =-.Inf. |
METHOD | Integer SystemAlgorithms code for non-linear system algorithm to use. Optional: UseDefault (Broyden). |
Fgroups | DoAll, loop over fixed groups non-negative integer, solve only that fixed group index |
Rgroups |
LB | AV compatible lower bound on the value of the first reservation value |
Ncuts | number of reservation values |
METHOD | USENEWTONRAPHSON (default) or USEBROYDEN |
Fgroups | either AllFixed or a specific fixed group \(\gamma_f\) to solve |
Rgroups | if AllFixed then must be AllRand. Otherwise, specific \(\gamma_r\) |
Fgroups | DoAll, loop over fixed groups non-negative integer, solve only that fixed group index |
Rgroups | |
MaxTrips | 0, iterate until convergence positive integer, max number of iterations -1 (ResetValue), reset to 0. |
If UpdateTime[OnlyOnce] is TRUE (see UpdateTimes), then transitions and variables are updated here. EV stores the result for each reachable endogenous state.
myGSolve | 0 (default), built in task will be used. GSolve-derived object to use for iterating over endogenous states. User-code does not provide this. Derived methods may send a replacement for GSolve. Ordinary users would only send an argument if they had developed their own solution method. |