[ Search |  Up Level |  Project home |  Index |  Class hierarchy ]

 Data.ox

Handling data, simulation, likelihood, predictions, moments.  ⇩ 

Overview

The Data class and its derivatives are used to simulate DDP data, compute predictions, read external data sets, and interface with Five-O to evaluate the likelihood or GMM objective.

Data objects store realizations along the path of the program. Unlike other spaces (e.g. the group space \(\Gamma\) and the state space \(\Theta\)), multiple instances of different types of data can be stored simultaneously. That is, there can be more than one data space.

There two parallel kinds of data:
Data
 
The basis of simulation, prediction, and data.
 
Outcome
 
Data generated from following a realized DP and estimation based on maximum likelihood.
 
Prediction
 
Data based on average or expected results over multiple DP realizations and estimation based on GMM.

However, users of niqlow will typically not interact directly with these base classes. Instead, you will work with panels of data, both external data read in for estimation and data generated from the model through simulation and prediction. If Outcome and Prediction are the lowest level classes, the corresponding highest ones are OutcomeDataSet and PredictionDataSet.

Contents

  1. Outcomes
  2. Simulation
    Likelihood
  3. Prediction
  4. Tracking Objects to Predict
    Moments
    GMM

Data

  1. Outcomes
    1. Overview
    2. Outcomes are used for simulating the model and for storing external data interpreted as realizations of the DDP. An outcome is generically denoted \(Y\). \(Y\) contains the realized state vectors, action vectors, auxiliary values, etc. It is described in more detail below.

      As discussed elsewhere, the user codes MyModel as a class derived from one of the pre-defined Bellman classes. In contrast, Outcome is designed to be generic so that it can be used for whatever model or data the program uses. A user does not define their own derived class to store outcomes. Only one model can be active in DDP because static data members are used, but multiple data sets can be stored at once. This can be useful when comparing two solution methods applied to one model or two estimation methods applied to two different data sets.

      Outcomes are related to points in the state space \(\Theta\), but they are treated distinctly in niqlow. The state space is coded to minimize storage and calculations while solving a model. On the other hand, outcomes are designed to track everything relevant to results of the DDP, and memory would be exhausted if outcomes were defined and stored for each possible state. It would be inefficient to store all potential outcomes when only one can be realized at each point in a single DP process.

      A single point in the state space \(\theta\) can have multiple states that could come before it or come after it hypothetically. In contrast, outcomes have a well-defined predecessor and successor. These are tracked as part of the outcome, so that niqlow represents a sequence of outcomes as a doubly-linked list of objects of class Outcome.

      An Outcome \(Y\) is a basic unit of data. However, a user will typically not interact with an individual outcome. Data structures are defined to keep track of ordered and unordered groups of outcomes. It is these objects that a user will typically create and use directly. The structure of outcomes is illustrated here:
       
       
      Outcome
       
      A single realization of a discrete DP, denoted \(Y\).
       
       
       
      Path
       
      A derived Outcome that points to a sequence of outcomes along a single realized DP path. As an outcome itself, the path is also the first outcome along itself:
      PATH::Y0 ⇆ Y1 ⇆   …  YT  ⇥
      The outcomes on a path are ordered and they "point" to both their predecessor and successor. (In computer speak, a Path is a doubly-linked list.) This is because some processing of paths go forward (such as simulating outcomes) and some backwards (computing likelihood when accounting for unobserved states).
       
       
       
       
      FPanel
       
      A Path that can point to more paths that all share the same fixed effect value, \(\gamma_f\). As a Path itself, the FPanel is the first path in the panel.
      FPANEL::PATH0 ↦ PATH1 ↦   …  PATHN  ⇥
      The different paths in a FPANEL point to their successor only, because it is typically not necessary to process them in both directions.
       
       
         
       
      Panel
       
      A heterogenous panel which contains one or more fixed panel. As an object derived from FPanel it also points to more FPanels. The Panel is the first fixed panel in the list.
      PANEL::FPANEL0 ↦ FPANEL1 ↦   …  FPANELM  ⇥
      Different FPANELs in a PANEL point to their successor only, because it is typically not necessary to process them in both directions.
       
       
         
       
      OutcomeDataSet
       
      A Panel with data-handling tools. Unlike the other derived classes, an OutcomeDataSet does not point to other panels (but the user's code could create more than one data set.)
      OUTCOMEDATASET::PANEL

    3. Examples
    4. To create a data set from external data:
      	data = new OutcomeDataSet("DPdata");
      	data->ObservedWithLabel(x,d);
      	data->IDColumn("id");
      	data->Read("data.dta");	
      
      This says that there are two variables from the DP model observed in the data set, say a state variable x and an action variable d. The external data uses the same labels for those variables as the DP model, so the correct columns can be found using them. Each empirical path has to be associated with the value of variable in the data set, so the IDColumn must be specified before reading the data. The data must be sorted within each path starting at \(t=0\). Since no columns in the data were associated with fixed effect variables this must be a homogeneous model. (There can be random effects but niqlow always assumes those are unobserved and will integrate over them.) So the data set will end up having one Panel which contains one FPanel which contains as many paths as Read() finds in the Stata data set.

      To create a simulated data set from a solved DP model and save to a Stata data set:

          SimulateOutcomes(400,10,"sim.dta");
      
      This will create a Panel object, which in turn will automatically create a FPanel object for each value of the fixed effects, i.e. each point in the fixed part of \(\Gamma\). It will produce 400 paths, each 10 periods long, for each fixed group. Then it will save the data to the Stata dta file using the labels set for all the DP variables to label the columns. This could then be read back into a OutcomeDataSet during a Monte Carlo exercise. This function is equivalent to these lower-level commands:
          sim = new Panel("DPdata");
          sim -> Simulate(400,10);
      	sim -> Print("sim.dta");		
          delete sim;
      
      The reason to create the Panel object instead of using SimulateOutcomes is to keep the simulated data around and to be able to control other aspects of the data produced using methods defined for panels.

    5. The Full Outcome
    6. DDP is designed to handle programs for which not everything observed by the agent is observed by the econometrician. In addition, DDP is designed to handle observables that are functions of the underlying outcomes but are not necessarily of any (direct) interest of the agent. To provide these capabilities, first consider the case of the fully observed realization of the DP.

      Let the YF denote the vector of all actions and all realized states in the model. Generically,

      YF ≡ (α ζ ε η θ γ χ YFp YFn )
          α = (a0 … )
          ζ = (z0 … )
          ε = (e0 … )
          η = (h0 … )
          θ = (q0 … )
          γ = (g0 … )
          χ = (x0 … )
      
      For simplicity the length of each of the vectors is not specified and the right-most elements of each of the vectors is not included. Instead, each vector is shown as the leftmost variable with subscript 0 followed by ….

      YF is referred to as the full outcome because it includes all information that is knowable and relevant about a single period in a realized DDP. YF adds a new vector denoted χ with generic elements x. See below. YF also includes pointers to the preceding and next outcomes on the path. These pointers can be undefined for various reasons. Obviously the value of YFn is not realized until the end of the current period. And the initial period of decision making obviously has no preceding outcome. However, in the middle of a panel of observation both pointers would be defined.

      The full outcome may not be observed in data. The observed outcome, Y, will have the same structure as YF but one or more elements of the member vectors will include missing (.NaN) values. Observability is discussed below. Its purpose is to account for gaps between theoretical outcomes and observed results from a DP.

    7. Paths
    8. The base Outcome class captures a single period, and it points to the previous outcome and the next outcome along a realized path (if the predecessor and successor exist). A Path is derive from Outcome, so the first outcome on the path is stored directly by the path (since it is an outcome itself). But Path also has a last data member which points to the last outcome on the path. Because both the previous and next outcomes are defined a Path can be processed both forwards and backwards. That is, a path is a doubly-linked list.

      A Path is a derived class from Outcome. The difference is that a path tracks a sequence of outcomes generated by realizations of a single DP problem. The outcomes in a path are a linked list. Since a path is itself an outcome the first outcome is the path itself. Outcome tracks both the next and previous outcome in the realized path. Further, the path stores the last outcome in the path, which makes it possible to work either forwards or backwards in the sequence.

    9. Panels
    10. In turn, a fixed panel (FPanel) is a list of Paths that share the same fixed effects. FPanel tracks the following path so a panel can be processed sequentially as a linked list. (Because paths in a panel are not ordered the previous path is not stored.) In turn a Panel is a list of fixed panels.

      Finally, OutcomeDataSet is a class derived from Panel that includes methods to read in outcomes from data accounting for partial or complete unobservability of actions and states. This organization can be seen by clicking on hierarchy in the upper right corner of any page of DDP documentation.

    11. Simulation
    12. Simulation is a method of each level of Outcome up to and including a Panel. A simulation uses the specified initial conditions, the endogenous conditional choice probabilities, and the transitions of all states to produce simulated realizations of the DP. The simulate panel could then be loaded as data set to conduct a Monte Carlo estimation procedure.

      Initial Conditions
      Fixed states, γ
      Endogenous states, θ
      Sampling from the stationary distribution

    13. Observed and Partially Observed Outcomes
    14. Recall that YF is the full realized outcome of the DP model is a single period. It includes all states, actions and auxiliary variables. In practice the full outcome is not directly observed. The limited information can be variables whose realized values are simply missing, or they only affect an auxiliary variable which combines other elements of the outcome. We can express the observable outcome as

      Y = ≡ (x0 … xχ.N  - - … ao0 - … - ao1 - … - zo0 - … - eo0 - … - ho0 - … - qo0 … - go0 - … )
      
      Here - indicates censoring of elements of YF, and ao0 is the first observed action variable. So if o0 = 3 it means a3 is the first element of α that is in the observed outcome. Between ao0 and ao1 are any action variables not observed and indicated by - … -. The same is true of the state vectors.

      This is not necessarily a template that all observations must follow. It is possible that some elements of YF are observed in some cases but not others. The auxiliary variables provide great flexibility. Suppose the value of an action variable ad is unobserved, but it is known the realized value is with some sub-range of the potential values. Then x0 and x1 could be the min and max values of ad, respectively. A derived likelihood function would add up the conditional probabilities of actions between those two values.

    15. Data Sets
    16. The OutcomeDataSet class is derived from Panel. It adds to the notion of a (heterogeneous) panel methods to read in external data and to account for observability and unobservability of aspects of the DP.

      Observability

      Getting Data

      Data are read in from outside formats such as Stata using Ox's built-in capabilities in Ox's Database class. If the same labels are used for model variables as in the external data set, the methods can seamlessly relate the data to the corresponding element of the model.

      A key issue with estimating DDPs is unobservability of actions and states. Outcome handles this two ways. First it treats missing (.NaN) in the data as unobserved. It will then integrate (sum over) values of missing states and actions when computing, say, the likelihood of the data. Second, auxiliary data (sometimes called payoff relevant variables) can be included in the data and then coded so that they indicate which variables and values should be integrated over.

    17. Likelihood

  2. Prediction
    1. Overview
    2. The Outcome class is designed to work with realized results from a DP model. That is, at one point in time there is a single realization. For this reason, simulation, individual-level data and likelihood functions are related to Outcomes. On the other hand, the Prediction class is designed to handle the distribution of outcomes at a given time. It is designed to handle integrating out uncertainty. For this reason, prediction and generalized method of moments (GMM) are related to Predictions.

      The base class Prediction tracks a list of possible state indices and their associated probabilities of occurring. It also tracks choice probabilities. Starting from some initial conditions a PathPrediction is a list of predictions, each providing the distribution across states and choices at that point in time. A PanelPrediction is a set of PathPredictions across fixed effect groups. Data can be read in to match up with predictions using the PredictionDataSet class derived from PanelPrediction.

       
       
      Prediction
       
      The expected outcome from a single realization. This expectation will typically integrate over the choice-specific additive shock \(\zeta\) and permanent unobserved heterogeneity \(\gamma_f\). Further, based on information from the user's code the prediction will integrate over missing elements of the current full outcome YF. It would also integrate over the distribution of previous states that could have potentially be the realized previous state.
       
       
       
      PathPrediction
       
      A derived Prediction that points to a sequence of predictions along a single realized DP path. As a prediction, the path itself is the first prediction along the path. Since random effects \(\gamma_r\) are assumed to be unobserved, the path prediction integrates over any random effect groups that are in the model. There is only one prediction for a given fixed effect group \(\gamma_F\), so there is no prediction corresponds to the FPanel class derived from Outcomes. Each PathPrediction is in effect a FixedPathPrediction
       
       
       
       
      PanelPrediction
       
      A list heterogenous path predictions. It is a PathPrediction which can also point to more PathPredictions. As a PathPrediction itself, the PanelPrediction is the first path in the panel.
       
       
         
       
      PredictionDataSet
       
      A panel prediction with data-handling tools. Unlike the other derived classes, empirical moments do not point to other panel predictions.

    3. Moments
    4. GMM

Author:
© 2011-2023 Christopher Ferrall

Documentation of Items Defined in Data.ox  ⇧ 

 Global functions

Functions
 ComputePredictions Simple Prediction .
 SimulateOutcomes Simple Panel Simulation.

 DataColumn : Zauxiliary

Holds information about a column in the data.
Public fields
 force0 const
 incol
 ind
 label
 obj const
 obsv
 type const

 ErgodicOutcomeDataSet : OutcomeDataSet : Panel : FPanel : Path : Outcome : Data : Task : DP

An outcome data set for Ergodic DP models with semi-closed form gradients.
Public methods
 ErgodicOutcomeDataSet
 SemiClosedForm
Inherited methods from OutcomeDataSet:
EconometricObjective, freqColumn, IDColumn, MatchToColumn, ObservedWithLabel, OutcomeDataSet, Read, Simulate, Summary, tColumn, UnObserved
Inherited methods from Panel:
Collapse, Deep, Flat, LogLikelihood, Panel, Print, SetMethod
Inherited methods from FPanel:
FPanel, GetCur
Inherited methods from Path:
FullLikelihood, Likelihood, PartialObservedLikelihood, Path, PathObjective, ReadObs
Inherited methods from Outcome:
AuxLikelihood, CCLikelihood, FromSim, IIDLikelihood, Outcome
Inherited methods from Data:
SetLog
Inherited methods from Task:
SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from OutcomeDataSet:
dlabels, freqcol, HasFrequencies, ids, label, list, low, LTypes, masked, source
Inherited fields from Panel:
first, flat, Fmtflat, FN, FNT, fparray, LFlat, M, r
Inherited fields from FPanel:
f, FPL, method, N, NT, SD, summand, upddens
Inherited fields from Path:
freq, i, L, LType, rcur, T
Inherited fields from Outcome:
act, Ainds, arows, aux, flnlike, mask, onext, OnlyTransitions, prev, snext, t, viinds, vilikes
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, userState, XUT

 ExogAuxOut : ExTask : Task : DP

Public fields
 auxlike static
 outcm static
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Task:
caller, d, done, inner, itask, iter, L, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, logf, lognm, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, tom, userState, Volume, XUT

 FPanel : Path : Outcome : Data : Task : DP

A list of Paths sharing the same fixed effect. A singly-linked list of Paths.
Public fields
 f const index of Fpanel in a panel.
 FPL fixed panel likelihood vector.
 method method to call for nested solution.
 N Number of paths in the panel.
 NT Total Number of Outcomes in the panel.
 SD const
 summand static
 upddens const
Public methods
 Collapse virtual
 Deep virtual .
 Flat virtual Return the fixed panel as a flat matrix.
 FPanel Store a panel of realized paths with common fixed group.
 GetCur
 LogLikelihood Compute the vector log-likelihood for paths in the fixed (homogeneous) panel.
 Simulate virtual Simulate a homogenous panel (fpanel) of paths.
Inherited methods from Path:
FullLikelihood, Likelihood, PartialObservedLikelihood, Path, PathObjective, ReadObs
Inherited methods from Outcome:
AuxLikelihood, CCLikelihood, FromSim, IIDLikelihood, Outcome
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Path:
flat, freq, i, L, LType, rcur, T
Inherited fields from Outcome:
act, Ainds, arows, aux, flnlike, mask, onext, OnlyTransitions, prev, snext, t, viinds, vilikes
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, userState, XUT

 Outcome : Data : Task : DP

A single realization of a discrete DP.
Public fields
 act \(\alpha\)
 Ainds list of feasible sets consistent w/ data.
 arows static current likelihood A rows .
 aux auxiliary values.
 flnlike static current log-likelihood when collapsed
 mask static
 onext pointer to next outcome on the path
 OnlyTransitions static do not include choice prob for fully observed likelihood, for first stage estimation of transitions.
 prev const previous outcome.
 snext index of next simulated state
 t const order on the path .
 viinds static consistent states now & tom
 vilikes static contigent likelihood now & tom.
Public methods
 AuxLikelihood
 CCLikelihood Compute likelihood of choices and transitions this period assuming full state and action observability.
 Deep virtual Print the outcome as record.
 Flat virtual Return the outcome as a (flat) row vector.
 FromSim
 IIDLikelihood Compute likelihood of an outcome given observablity of θ and η but integrating over ε
$$L(\theta) = $$
 Likelihood Compute likelihood based on the Type.
 Outcome Record everything about a single realization of the DP.
 PartialObservedLikelihood Compute conditional forward likelihood of an outcome.
 Simulate virtual Simulate the IID stochastic elements of a realization.
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, L, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, userState, XUT

 OutcomeDataSet : Panel : FPanel : Path : Outcome : Data : Task : DP

A panel with data-handling tools. A data set is designed to hold data for estimation purposes.
Example:
d = new OutcomeDataSet("d");

See DataObjective.

Public fields
 dlabels labels
 freqcol
 HasFrequencies
 ids
 label const Label for the data set.
 list
 low const
 LTypes
 masked
 source
Public methods
 EconometricObjective virtual The default econometric objective: log-likelihood.
 freqColumn set the column label or index of a frequency (weighted data) variable.
 IDColumn set the column label or index of the observation ID.
 MatchToColumn Identify a variable with a data column.
 ObservedWithLabel Mark actions and state variables as observed in data, matched with their internal label.
 OutcomeDataSet Store a Panel as a data set.
 Read Load outcomes into the data set from a (long format) file or an Ox database.
 Simulate Simulate a data .
 Summary Produce a Stata-like summary statistics table.
 tColumn set the column label or index of the time value.
 UnObserved UnMark action and states variables as observed.
Inherited methods from Panel:
Collapse, Deep, Flat, LogLikelihood, Panel, Print, SetMethod
Inherited methods from FPanel:
FPanel, GetCur
Inherited methods from Path:
FullLikelihood, Likelihood, PartialObservedLikelihood, Path, PathObjective, ReadObs
Inherited methods from Outcome:
AuxLikelihood, CCLikelihood, FromSim, IIDLikelihood, Outcome
Inherited methods from Data:
SetLog
Inherited methods from Task:
SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Panel:
first, flat, Fmtflat, FN, FNT, fparray, LFlat, M, r
Inherited fields from FPanel:
f, FPL, method, N, NT, SD, summand, upddens
Inherited fields from Path:
freq, i, L, LType, rcur, T
Inherited fields from Outcome:
act, Ainds, arows, aux, flnlike, mask, onext, OnlyTransitions, prev, snext, t, viinds, vilikes
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, userState, XUT

 Panel : FPanel : Path : Outcome : Data : Task : DP

A heterogenous panel. A Panel is a list of FPanels which share a value of the fixed effect variables.
Public fields
 first .
 flat matrix representation of panel.
 Fmtflat static .
 FN total paths.
 FNT total outcomes in the panel.
 fparray
 LFlat static column labels in flat.
 M panel likelihood vector.
 r const tag for the panel.
Public methods
 Collapse virtual
 Deep Print the deep view of the panel.
 Flat Store the panel as long flat matrix.
 LogLikelihood Compute the vector of log-likelihoods.
 Panel Store a list of heterogenous fixed panels.
 Print Produce a matrix of the panel.
 SetMethod Set the nested DP solution method to use when evaluating the panel's econometric objective.
 Simulate Simulate a (heterogeneous) panel.
Inherited methods from FPanel:
FPanel, GetCur
Inherited methods from Path:
FullLikelihood, Likelihood, PartialObservedLikelihood, Path, PathObjective, ReadObs
Inherited methods from Outcome:
AuxLikelihood, CCLikelihood, FromSim, IIDLikelihood, Outcome
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from FPanel:
f, FPL, method, N, NT, SD, summand, upddens
Inherited fields from Path:
freq, i, L, LType, rcur, T
Inherited fields from Outcome:
act, Ainds, arows, aux, flnlike, mask, onext, OnlyTransitions, prev, snext, t, viinds, vilikes
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, userState, XUT

 PanelPrediction : PathPrediction : Prediction : Data : Task : DP

Store and process path predictions for all fixed effect groups. Individual paths are stored in a F x 1 array of `PathPrediction's. An aggregate path that averages over the the indidivual paths is stored in this.
Public fields
 aflat flat matrix version of predictions.
 cols columns in data .
 delt difference between pred.
 EverPredicted Predict() called before.
 first const either fparray[0] or this.
 FN total number of predictions..
 fparray const array pointing to (fixed) path predictions.
 M array of GMM vector.
 mask indicator vector for observed moments.
 pcount # of predictions made and saved so far .
 PredMomFile static file name of the last Panel Prediction Data Set saved.
 summand const object to integrate over \(\gamma_r\).
 tlabels labels of flat print.
 tlist list of objects to track.
 TrackingCalled Has Tracking() been called.
 upddens const object to update distribution over r.
Public methods
 InitializePath
 PanelPrediction Create a panel of predictions.
 Predict Predict outcomes in the panel.
 SetColumns Set up data columns for tracked variables.
 Tracking Add objects to track mean values over the path.
Inherited methods from PathPrediction:
AppendSimulated, Empirical, GetFlat, PathPrediction, Qcols, SetFlat, SimulateOutcomePaths, tprefix
Inherited methods from Prediction:
GetAcc, Histogram, IncAcc, Prediction, Reset, SetMoms
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from PathPrediction:
aggexists, cur, dlabels, f, Fcols, firstprediction, flat, fnext, fvals, HasObservations, iDist, inT, L, MakeFlat, method, mother, myshare, pathW, plabels, prtlevel, pstate, rcur, T, vdelt, wght
Inherited fields from Prediction:
accmom, ch, chq, empmom, haz, p, pnext, pq, predmom, q, readmom, sind, t, W
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, tom, userState, XUT

 Path : Outcome : Data : Task : DP

A sequence of outcomes along a single realized DP path. The path is a doubly-linked list of Outcomes.
Public fields
 flat .
 freq frequency of outcomes represented by this.
 i index of path in a panel.
 L likelihood of the path.
 LType type of likelihood calculation.
 rcur current index of random effects.
 T lenth of the path.
Public methods
 Collapse virtual
 Deep virtual Produce a two dimensional view of the path;
 Flat virtual Produce a matrix representation of the path.
 FullLikelihood
 Likelihood Compute likelihood of a realized path.
 PartialObservedLikelihood Compute conditional forward likelihood of an outcome.
 Path Create a new series of Outcomes along a realized path.
 PathObjective
 ReadObs
 Simulate virtual Simulate a list of realized states and actions from an initial state.
Inherited methods from Outcome:
AuxLikelihood, CCLikelihood, FromSim, IIDLikelihood, Outcome
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Outcome:
act, Ainds, arows, aux, flnlike, mask, onext, OnlyTransitions, prev, snext, t, viinds, vilikes
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, userState, XUT

 PathPrediction : Prediction : Data : Task : DP

Predicted outcomes along a path.
Public fields
 aggexists static
 cur the current prediction
 dlabels labels for vdelt.
 f const fixed index.
 Fcols const
 firstprediction first prediction.
 flat flat prediction matrix.
 fnext the next PathPrediction
 fvals const for tracking.
 HasObservations Empirical moments read in.
 iDist const initial distribution.
 inT Path length sent it.
 L Distance between predictions and emp.mom.
 MakeFlat Create flat prediction always .
 method method to call for nested solution.
 mother const panel I belong to.
 myshare const My share of population.
 pathW Weighting matrix for GMM for full path.
 plabels labels for simulated path.
 prtlevel .
 pstate const pstate .
 rcur current index of random effects.
 T length of the path.
 vdelt wide delta vector.
 wght const Weight Moments for GMM if empirical moments include.
Public methods
 AppendSimulated
 Empirical Add empirical values to a path of predicted values.
 GetFlat Get selected elements of the flat path prediction after it is made.
 PathPrediction Create a path of predictions - should only be called by PanelPrediction.
 Predict Create or update a path of predicted distributions.
 Qcols
 SetFlat
 SimulateOutcomePaths Compute and store path weighting matrix for fixed effect group.
 tprefix static
Inherited methods from Prediction:
GetAcc, Histogram, IncAcc, Prediction, Reset, SetMoms
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Prediction:
accmom, ch, chq, empmom, haz, p, pnext, pq, predmom, q, readmom, sind, t, W
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, tom, userState, XUT

 Prediction : Data : Task : DP

Predicted distribution across states.
Public fields
 accmom accumulated predicted moments across r
 ch Expanded ch.
 chq current ch.
 empmom used (masked) empiricalmoments.
 haz mass hazard at t.
 p
 pnext next prediction on the path
 pq current p.
 predmom (unmasked) predicted moment vector
 q index into sind.
 readmom (unmasked) empirical moments.
 sind state index
 t const rank in a pathprediction.
 W masked weight to put on distance.
Public methods
 GetAcc
 Histogram Compute the histogram of tracked object at the prediction.
 IncAcc
 Predict Compute the predicted distribution of actions and states.
 Prediction Create a new prediction.
 Reset
 SetMoms Initialize and if necessary set moms vectors.
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Initialize, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, L, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, tom, userState, XUT

 PredictionDataSet : PanelPrediction : PathPrediction : Prediction : Data : Task : DP

Stores data read in as moments and associate them with a panel of predictions.
Public fields
 flist
 FMethod
 Nplace observations column (index or label).
 Tplace time column (index or label).
 UorCorL matrix of indices or array of labels or UseLabel
Public methods
 EconometricObjective virtual The default econometric objective for a panel prediction: the overall GMM objective.
 Observations Define columns where observations and time values appear.
 Observed
 PredictionDataSet Create a panel prediction that is matched with external data.
 Read Read in external moments of tracked objects.
 SimulateMomentVariances Simulate sample of outcomes compute path Variance matrix and save inverse.
 TrackingMatchToColumn Track an object that is matched to column in the data.
 TrackingWithLabel Track one or more objects that are matched to columns using the object's label.
Inherited methods from PanelPrediction:
InitializePath, PanelPrediction, Predict, SetColumns, Tracking
Inherited methods from PathPrediction:
AppendSimulated, Empirical, GetFlat, PathPrediction, Qcols, SetFlat, SimulateOutcomePaths, tprefix
Inherited methods from Prediction:
GetAcc, Histogram, IncAcc, Prediction, Reset, SetMoms
Inherited methods from Data:
SetLog
Inherited methods from Task:
list, SyncStates, ~Task
Inherited methods from DP:
Actions, AuxiliaryOutcomes, CreateSpaces, DrawFsamp, DrawGroup, DrawOneExogenous, EndogenousStates, ExogenousStates, GetAind, GetPinf, GetPstar, GetTrackTrans, GetUseEps, GroupVariables, Indicators, Interactions, KLaggedAction, KLaggedState, MakeGroups, MultiInteractions, onlyDryRun, RecomputeTrans, SemiExogenousStates, SetClock, SetDelta, Settheta, SetUpdateTime, SetVersion, StorePalpha, SubSampleStates, SyncAct, UpdateDistribution, ValuesCounters
Inherited fields from PanelPrediction:
aflat, cols, delt, EverPredicted, first, FN, fparray, M, mask, pcount, PredMomFile, summand, tlabels, tlist, TrackingCalled, upddens
Inherited fields from PathPrediction:
aggexists, cur, dlabels, f, Fcols, firstprediction, flat, fnext, fvals, HasObservations, iDist, inT, L, MakeFlat, method, mother, myshare, pathW, plabels, prtlevel, pstate, rcur, T, vdelt, wght
Inherited fields from Prediction:
accmom, ch, chq, empmom, haz, p, pnext, pq, predmom, q, readmom, sind, t, W
Inherited fields from Data:
logf, lognm, Volume
Inherited fields from Task:
caller, d, done, inner, itask, iter, left, MaxTrips, right, state, subspace, trace, trips
Inherited fields from DP:
Blocks, Chi, ClockType, counter, curREdensity, delta, EOoE, EStoS, ETT, gdist, IOE, MyVersion, NKptrans, NKvindex, NxtExog, parents, S, SS, States, SubVectors, tod, tom, userState, XUT

 TrackObj

Public methods
 print Print mean and histogram of tracked object.

 Global

 ComputePredictions

ComputePredictions ( T , prtlevel )
Simple Prediction .
Parameters:
T integer, length of panel
UseDefault [default], length of lifecycle or 10 probabilities
Two print predictions
prtlevel Two [default] print predictions
One print state and choice probabilities
Zero do not print, instead save to prediction moment file

This creates a PanelPrediction object, creates the prediction tracking all varaibles and prints out. Object is then deleted

Returns:
flat prediction

 SimulateOutcomes

SimulateOutcomes ( Nsim , T , outopt , ErgOrStateMat , DropTerminal )
Simple Panel Simulation.
Parameters:
Nsim integer, number of paths to simulate per fixed group
[default] UseDefault, whic is 1
T integer, length of panel
[default], length of lifecycle or 10
outopt integer [default] print to screen or
string name of file to save to
ErgOrStateMat 0 [default]: find lowest reachable indexed state to start from
1: draw from stationary distribution (must be ergodic)
matrix of initial states to draw from (each column is a different starting value)
DropTerminal TRUE: eliminate termainl states from the data set
FALSE: [default] include terminal states.

This routine simplifies simulating a solved DP model. Simply call it instead of creating an Panel object.

 DataColumn

 force0

const decl force0 [public]

 incol

decl incol [public]

 ind

decl ind [public]

 label

decl label [public]

 obj

const decl obj [public]

 obsv

decl obsv [public]

 type

const decl type [public]

 ErgodicOutcomeDataSet

 ErgodicOutcomeDataSet

ErgodicOutcomeDataSet :: ErgodicOutcomeDataSet ( label , method )

 SemiClosedForm

ErgodicOutcomeDataSet :: SemiClosedForm ( subp )

 ExogAuxOut

 auxlike

static decl auxlike [public]

 outcm

static decl outcm [public]

 FPanel

 Collapse


 Deep

virtual FPanel :: Deep ( )
.

 f

const decl f [public]
index of Fpanel in a panel.

 Flat

virtual FPanel :: Flat ( Orientation )
Return the fixed panel as a flat matrix. index of panel
Returns:
long matrix of panels

 FPanel

FPanel :: FPanel ( f , method )
Store a panel of realized paths with common fixed group.
Parameters:
f integer tag for the panel (such as replication index) [default=0]
method Method to call to solve
0 [default] do nothing, something else handles solution

 FPL

decl FPL [public]
fixed panel likelihood vector.

 GetCur

FPanel :: GetCur ( )

 LogLikelihood

FPanel :: LogLikelihood ( )
Compute the vector log-likelihood for paths in the fixed (homogeneous) panel. The vector of path log-likelihoods is stored in FPL.
If the method is a class
Solve() is called first.
If done equals IterationFailed the likelihood is not computed. FPL is set to a vector of .NaN.

 method

decl method [public]
method to call for nested solution.

 N

decl N [public]
Number of paths in the panel.

 NT

decl NT [public]
Total Number of Outcomes in the panel.

 SD

const decl SD [public]

 Simulate

virtual FPanel :: Simulate ( Nsim , T , ErgOrStateMat , DropTerminal , pathpred )
Simulate a homogenous panel (fpanel) of paths.
Parameters:
Nsim > 0, number of paths to simulate
Tmax maximum path length
0 no maximum length.
ErgOrStateMat 0 [default]: find lowest reachable indexed state to start from
1: draw from stationary distribution (must be ergodic)
matrix of initial states to draw from (each column is a different starting value)
DropTerminal TRUE: eliminate termainl states from the data set
FALSE: [default] include terminal states.
pathpred 0 [default] or PathPrediction object to filter simulated values
Comments:
γ region of state is masked out.

 summand

static decl summand [public]

 upddens

const decl upddens [public]

 Outcome

 act

decl act [public]
\(\alpha\)

 Ainds

decl Ainds [public]
list of feasible sets consistent w/ data.

 arows

static decl arows [public]
current likelihood A rows .

 aux

decl aux [public]
auxiliary values.

 AuxLikelihood

Outcome :: AuxLikelihood ( howmany )

 CCLikelihood

Outcome :: CCLikelihood ( )
Compute likelihood of choices and transitions this period assuming full state and action observability.

 Deep

virtual Outcome :: Deep ( const depth )
Print the outcome as record.

 Flat

virtual Outcome :: Flat ( Orientation )
Return the outcome as a (flat) row vector.

Used to print or save a series or panel as a matrix.

Columns:
t ~ State_Ind ~ Type ~ Aind ~ ε ~ eta; ~ θ ~ γ ~ α

 flnlike

static decl flnlike [public]
current log-likelihood when collapsed

 FromSim


 IIDLikelihood

Outcome :: IIDLikelihood ( )
Compute likelihood of an outcome given observablity of θ and η but integrating over ε
$$L(\theta) = $$

 Likelihood

Outcome :: Likelihood ( Type )
Compute likelihood based on the Type.

 mask

static decl mask [public]

 onext

decl onext [public]
pointer to next outcome on the path

 OnlyTransitions

static decl OnlyTransitions [public]
do not include choice prob for fully observed likelihood, for first stage estimation of transitions.

 Outcome

Outcome :: Outcome ( prior )
Record everything about a single realization of the DP. This is not usually called by the user code. Outcomes are created along paths.
Parameters:
prior Outcome object, the previous realization along the path
integer, this is first realization on the path. state uninitialized.
vector, initial value of state

 PartialObservedLikelihood

Outcome :: PartialObservedLikelihood ( )
Compute conditional forward likelihood of an outcome.
$$L(\theta) = \sum_{\eta} \sum_{\alpha} P*() P()$$

 prev

const decl prev [public]
previous outcome.

 Simulate

virtual Outcome :: Simulate ( )
Simulate the IID stochastic elements of a realization. This is usually called along a path not by the user's code

θ and γ vectors already set. ε and η elements are simulated from their transitions. Then Simulate called to simulate &apha;, and Υ.

Returns:
TRUE if path is ended, FALSE otherwise
See also:
DrawOneExogenous, Simulate

 snext

decl snext [public]
index of next simulated state

 t

const decl t [public]
order on the path .

 viinds

static decl viinds [public]
consistent states now & tom

 vilikes

static decl vilikes [public]
contigent likelihood now & tom.

 OutcomeDataSet

 dlabels

decl dlabels [public]
labels

 EconometricObjective

virtual OutcomeDataSet :: EconometricObjective ( subp )
The default econometric objective: log-likelihood.
Parameters:
subp DoAll (default), solve all subproblems and return likelihood vector
Non-negative integer, solve only subproblem, return contribution to overall L
Returns:
M, lnL = (lnL1 lnL2 …)
See also:
LogLikelihood

 freqcol

decl freqcol [public]

 freqColumn

OutcomeDataSet :: freqColumn ( lORind )
set the column label or index of a frequency (weighted data) variable.
Parameters:
lORind string, column label
integer≥0 column index;

Likelihoods are multiplied by this value. If no column is specified the default is 1.


 HasFrequencies

decl HasFrequencies [public]

 IDColumn

OutcomeDataSet :: IDColumn ( lORind )
set the column label or index of the observation ID.
Parameters:
lORind string, column label
integer≥0 column index;

 ids

decl ids [public]

 label

const decl label [public]
Label for the data set.

 list

decl list [public]

 low

const decl low [public]

 LTypes

decl LTypes [public]

 masked

decl masked [public]

 MatchToColumn

OutcomeDataSet :: MatchToColumn ( aORs , LorC )
Identify a variable with a data column.
Parameters:
aORs Either an ActionVariable, element of \(\alpha\), or a StateVariable, element of one of the state vectors, or a AuxiliaryValue, element of \(\chi\)
OR
LorC UseLabel, variable's label to denote column of data with observations
integer ≥ 0, column of data matrix that contains observations
string, label of column with observations.

 ObservedWithLabel

OutcomeDataSet :: ObservedWithLabel ( ... )
Mark actions and state variables as observed in data, matched with their internal label.
Parameters:
aORs Either an ActionVariable, element of \(\alpha\), or a StateVariable, element of one of the state vectors, or a AuxiliaryValue, element of \(\chi\)
OR
array of the form {v1,v2,…}. In this case all other arguments are ignored.
... continues with object2, LoC2, object3, LorC3, etc.

 OutcomeDataSet

OutcomeDataSet :: OutcomeDataSet ( id , method )
Store a Panel as a data set.
Parameters:
label string, tag for the data set
UseDefault [default] user classname
method, solution method to be used as data set is processed.
0 [default], no solution

 Read

OutcomeDataSet :: Read ( FNorDB , SearchLabels )
Load outcomes into the data set from a (long format) file or an Ox database.
Parameters:
FNorDB string, file name with extension that can be read by OX::Database::Load
Database object
SearchLabels TRUE: search data set labels and use any matches as observed.

Example:
  d = new OutcomeDataSet();
  d -> Read("data.dta");

 Simulate

OutcomeDataSet :: Simulate ( N , T , ErgOrStateMat , DropTerminal , pathpred )
Simulate a data . Each value of fixed \(\gamma\) is simulated N times, drawing the random effects in \(\gamma_r\) from their density.
Parameters:
N integer number of paths to simulate in each FPanel.
T Integer, max length of each path
vector, max length for each FPanel.
ErgOrStateMat 0: find lowest reachable indexed state to start from
1: draw from stationary distribution (must be ergodic)
matrix: initial states to draw from (each column is a different starting value)
DropTerminal TRUE: eliminate termainl states from the data set
pathpred Integer [default] or PathPrediction object that is simulating (used when computing efficient GMM weights)

 source

decl source [public]

 Summary

OutcomeDataSet :: Summary ( data , rlabels )
Produce a Stata-like summary statistics table.
Parameters:
data matrix, data to summarize
integer, summarize flat
rlabels [default=0], array of labels

 tColumn

OutcomeDataSet :: tColumn ( lORind )
set the column label or index of the time value.
Parameters:
lORind string, column label
integer≥0 column index;

 UnObserved

OutcomeDataSet :: UnObserved ( ... )
UnMark action and states variables as observed.
Parameters:
as1 Discrete object, either an ActionVariable, element of \(\alpha\), or a StateVariable, element of one of the state vectors
StateBlock: each variable in the block will be marked unobserved.
... as2, etc.

Comments:
Does nothing unless variable was already sent to ObservedWithLabel();

 Panel

 Collapse


 Deep

Panel :: Deep ( )
Print the deep view of the panel.

 first

decl first [public]
.

 Flat

Panel :: Flat ( Orientation )
Store the panel as long flat matrix.

 flat

decl flat [public]
matrix representation of panel.
See also:
Flat

 Fmtflat

static decl Fmtflat [public]
.

 FN

decl FN [public]
total paths.

 FNT

decl FNT [public]
total outcomes in the panel.

 fparray

decl fparray [public]

 LFlat

static decl LFlat [public]
column labels in flat.

 LogLikelihood

Panel :: LogLikelihood ( )
Compute the vector of log-likelihoods. The vector of path log-likelihoods is stored in M, it is constructed by appending each FPL. If method is an object, then method->Solve() is called.
See also:
EconometricObjective

 M

decl M [public]
panel likelihood vector.

 Panel

Panel :: Panel ( r , method )
Store a list of heterogenous fixed panels.
Parameters:
r integer tag for the panel (such as replication index)
method Method object, the DP solution to call to solve FPanel problem.
(default) 0 do nothing, something else handles solution

 Print

Panel :: Print ( fn , Orientation )
Produce a matrix of the panel. If flatis an uninitialized then Flat() is called first. Flat version of the data set is stored in flat.
Parameters:
fn 0: do not print or save, just return
1 print to data log file
2 print to screen
string: save to a file
Orientation LONG or WIDE
Returns:
long matrix of panels

 r

const decl r [public]
tag for the panel.

 SetMethod

Panel :: SetMethod ( method )
Set the nested DP solution method to use when evaluating the panel's econometric objective.
Parameters:
method Method

 Simulate

Panel :: Simulate ( N , T , ErgOrStateMat , DropTerminal , pathpred )
Simulate a (heterogeneous) panel. Each value of fixed γ is simulated N times, drawing the random effects in γ from their density.
Parameters:
N integer number of paths to simulate in each FPanel.
T Integer, max length of each path
vector, max length for each FPanel.
ErgOrStateMat 0: find lowest reachable indexed state to start from
1: draw from stationary distribution (must be ergodic)
matrix of initial states to draw from (each column is a different starting value)
DropTerminal TRUE: eliminate termainl states from the data set
pathpred Integer [default] or PathPrediction object that is simulating

 PanelPrediction

 aflat

decl aflat [public]
flat matrix version of predictions.

 cols

decl cols [public]
columns in data .

 delt

decl delt [public]
difference between pred. & data.

 EverPredicted

decl EverPredicted [public]
Predict() called before.

 first

const decl first [public]
either fparray[0] or this.

 FN

decl FN [public]
total number of predictions..

 fparray

const decl fparray [public]
array pointing to (fixed) path predictions.

 InitializePath

PanelPrediction :: InitializePath ( pstate )

 M

decl M [public]
array of GMM vector.

 mask

decl mask [public]
indicator vector for observed moments.

 PanelPrediction

PanelPrediction :: PanelPrediction ( label , method , iDist , wght , aggshares )
Create a panel of predictions.
Parameters:
label name for the data
UseDefault [default] use classname of model class.
method Method to be called before predictions.
iDist initial conditions for PathPredictions
ErgodicDist : use computed stationary distribution in ergodic dist.
0 [default]: start the prediction at the lowest-indexed reachable state in Θ.
non-negative integer: start at iDist and increment until a reachable state index is found.
matrix: a list of states to start the prediction from, uniform distribution
array: a list of state INDICES and a list of probabilities, can be the output of a IID Transit()
object of Prediction class: use sind as the initial state for this prediction.
wght [default=UNCORRELATED]
aggshares 0 [default] equal shares of averaged moments over fixed groups
-1 [UnInitialized] do not compute averaged moments
Fx1 vector, share of population

 pcount

decl pcount [public]
# of predictions made and saved so far .

 Predict

PanelPrediction :: Predict ( inT , prtlevel , outmat )
Predict outcomes in the panel.
Parameters:
T : positive integer or matrix of lengths of paths to predict (same length as number of paths in then panel)
prtlevel : Zero [default] do not print
One print state and choice probabilities
Two print predictions
outmat matrix, predictions already made, just process contributions
Returns:
succ TRUE no problems
FALSE prediction or solution failed.

 PredMomFile

static decl PredMomFile [public]
file name of the last Panel Prediction Data Set saved.

 SetColumns

PanelPrediction :: SetColumns ( dlabels , Nplace , Tplace )
Set up data columns for tracked variables.
Parameters:
dlabels array of column labels in the data.
Nplace number of observations (row weight) column
UnInitialized no row weights
tplace model t column
UnInitialized

 summand

const decl summand [public]
object to integrate over \(\gamma_r\).

 tlabels

decl tlabels [public]
labels of flat print.

 tlist

decl tlist [public]
list of objects to track.

 Tracking

PanelPrediction :: Tracking ( LorC , ... )
Add objects to track mean values over the path.
Parameters:
LorC UseLabel: use object label to match to column.
NotInData unmatched to data.
integer: column in data set
string: column label
TrackAll : track all actions, endogenous states and auxiliaries
... Discrete objects and/or arrays or objects to track

Returns:
a row vector of the positions of the added objects that can be sent to GetFlat Thus if different sets of outcomes should be extracted together as vectors call Tracking() for each set and store the return value.
Comments:
This routine can be called more than once, but once Predict() has been called no more objects can be added to the list.

 TrackingCalled

decl TrackingCalled [public]
Has Tracking() been called.

 upddens

const decl upddens [public]
object to update distribution over r.

 Path

 Collapse


 Deep

virtual Path :: Deep ( )
Produce a two dimensional view of the path;

 Flat

virtual Path :: Flat ( Orientation )
Produce a matrix representation of the path. Path id (i) is appended as the first column. Each row is an Outcome.
Returns:
TxM matrix

 flat

decl flat [public]
.

 freq

decl freq [public]
frequency of outcomes represented by this.

 FullLikelihood


 i

decl i [public]
index of path in a panel.

 L

decl L [public]
likelihood of the path.

 Likelihood

Path :: Likelihood ( )
Compute likelihood of a realized path.

 LType

decl LType [public]
type of likelihood calculation.

 PartialObservedLikelihood

Compute conditional forward likelihood of an outcome.
$$L(\theta) = \sum_{\eta} \sum_{\alpha} P*() P()$$

 Path

Path :: Path ( i , state0 , infreq )
Create a new series of Outcomes along a realized path.
Parameters:
id integer, id or tag for the path.
state0 UnInitialized (-1), set state to uninitalized
non-negative fixed effect index to use, draw and random effect from current distribution
vector, initial state vector

 PathObjective


 rcur

decl rcur [public]
current index of random effects.

 ReadObs


 Simulate

virtual Path :: Simulate ( newstate , T , DropTerminal )
Simulate a list of realized states and actions from an initial state.

Checks to see if transition is Ρ is tracking. If not, process span the state space with EndogTrans.

Parameters:
newstate UnInitialized (default) state already set
state to add to group state
T integer, max. length of the panel
0, no maximum lenth; simulation goes on until a Terminawl State is reached.
DropTerminal drop states that are terminal

Example:

 T

decl T [public]
lenth of the path.

 PathPrediction

 aggexists

static decl aggexists [public]

 AppendSimulated

PathPrediction :: AppendSimulated ( Y )

 cur

decl cur [public]
the current prediction

 dlabels

decl dlabels [public]
labels for vdelt.

 Empirical

PathPrediction :: Empirical ( inNandMom , hasN , hasT , MaxT )
Add empirical values to a path of predicted values.
Parameters:
inmom Txm matrix of values.
hasN FALSE: no row observation column
TRUE: second-to-last column that contains observation count used for weighting of distances.
hasT FALSE: no model t column
TRUE: last column contains observation count
MaxT path length will equal max{MaxT,maxc{inNandMom[][C]}}
Comments:
If T is greater than the current length of the path additional predictions are concatenated to the path

 f

const decl f [public]
fixed index.

 Fcols

const decl Fcols [public]

 firstprediction

decl firstprediction [public]
first prediction.

 flat

decl flat [public]
flat prediction matrix.

 fnext

decl fnext [public]
the next PathPrediction

 fvals

const decl fvals [public]
for tracking.

 GetFlat

PathPrediction :: GetFlat ( tvals , mvals )
Get selected elements of the flat path prediction after it is made.
Parameters:
tvals DoAll (default) return all time periods(rows)
integer or vector of t indices to report
mvals DoAll (default) return all moments (columns)
integer or vector of moments to report
Returns:
flat[tvals][mvals]

 HasObservations

decl HasObservations [public]
Empirical moments read in.

 iDist

const decl iDist [public]
initial distribution.

 inT

decl inT [public]
Path length sent it.

 L

decl L [public]
Distance between predictions and emp.mom.

 MakeFlat

decl MakeFlat [public]
Create flat prediction always . Usually flat prediction matrix only created for data output. The flat prediction is used by classes such as Equilibrium. Then in this case set this to TRUE.

 method

decl method [public]
method to call for nested solution.

 mother

const decl mother [public]
panel I belong to.

 myshare

const decl myshare [public]
My share of population.

 PathPrediction

PathPrediction :: PathPrediction ( mother , f , method , iDist , wght , myshare )
Create a path of predictions - should only be called by PanelPrediction.
Parameters:
mother object of PanelPrediction that is the mother to this path.
f integer: fixed group index [default=0]
AlLFixed (-1): this aggregates (averages) predictions over NotInData (-2): no prediction stored here.
method 0: do not call a nested solution [default]
a solution Method object to be called before making predictions
iDist initial distribution.
ErgodicDist : use computed stationary distribution in ergodic dist.
non-negative integer: start at iDist and increment until a reachable state index is found. So PathPrediction(0) [default] will start the prediction at the lowest-indexed reachable state in Θ.
matrix: a list of states to start the prediction from
object of Prediction class: use sind as the initial state for this prediction.
wght Code for weighting scheme for distance between empirical and predicted paths.
myshare either 0 or a fraction of the population if an aggregate (overall) prediction is being stored.

The prediction is not made until Predict() is called.


 pathW

decl pathW [public]
Weighting matrix for GMM for full path.

 plabels

decl plabels [public]
labels for simulated path.

 Predict

PathPrediction :: Predict ( inT , prtlevel )
Create or update a path of predicted distributions.
Parameters:
inT integer length of the path
0 (default) : predict only for existing predictions on the Path.
If existing path is longer than inT (and inT > 0) then extra predictions are deleted.
prtlevel Zero [default] do not print
One print state and choice probabilities
Two print predictions
Returns:
TRUE if everything succeeds
FALSE if either the solution method or the prediction fails

Predictions are averaged over random effect groups.

Example:
  p = new PanelPrediction();
  p->Predict(10);

 prtlevel

decl prtlevel [public]
.

 pstate

const decl pstate [public]
pstate .

 Qcols


 rcur

decl rcur [public]
current index of random effects.

 SetFlat

PathPrediction :: SetFlat ( inflat , SetorInc , Cols )

 SimulateOutcomePaths

PathPrediction :: SimulateOutcomePaths ( curfpanel , N , ErgOrStateMat )
Compute and store path weighting matrix for fixed effect group.
Parameters:
curfpanel FPanel object to simulate
N sample size
ErogOrStateMat simulation initial conditions. Let SM be the matrix of simulated outcomes (concatenation over time) pathW = generalized inverse of Var(SM). Save simulated data to logs/flat_??.dta Save weight matrix in pathW_??.mat

 T

decl T [public]
length of the path.

 tprefix

static PathPrediction :: tprefix ( t )

 vdelt

decl vdelt [public]
wide delta vector.

 wght

const decl wght [public]
Weight Moments for GMM if empirical moments include.
See also:
GMMWeightOptions

 Prediction

 accmom

decl accmom [public]
accumulated predicted moments across r

 ch

decl ch [public]
Expanded ch. prob.

 chq

decl chq [public]
current ch. prob.

 empmom

decl empmom [public]
used (masked) empiricalmoments.

 GetAcc

Prediction :: GetAcc ( )

 haz

decl haz [public]
mass hazard at t.

 Histogram

Prediction :: Histogram ( printit )
Compute the histogram of tracked object at the prediction.
Parameters:
printit TRUE=output; FALSE=quiet
Comments:
output will also be produced for any objects in tlist with Volume > SILENT

 IncAcc

Prediction :: IncAcc ( inf , addmom )

 p

decl p [public]

 pnext

decl pnext [public]
next prediction on the path

 pq

decl pq [public]
current p.

 Predict

Prediction :: Predict ( )
Compute the predicted distribution of actions and states. Average values of tracked objects are stored in predmom Transitions to unreachable states is tracked and logged in the Data logfile.
Returns:
TRUE if all current states are termimal or last states.
See also:
Distribution

 Prediction

Prediction :: Prediction ( t )
Create a new prediction.

Typically a user would create a PathPrediction or further derived classes which in turn creates predictions.

Parameters:
t integer, position in the path.

 predmom

decl predmom [public]
(unmasked) predicted moment vector

 q

decl q [public]
index into sind.

 readmom

decl readmom [public]
(unmasked) empirical moments.

 Reset

Prediction :: Reset ( )

 SetMoms

Prediction :: SetMoms ( sz , firsttype )
Initialize and if necessary set moms vectors.
Parameters:
sz length of current ctlist.
firsttype first or only pass integrating over gamma_r

This was added to reduce vector creation/destruction


 sind

decl sind [public]
state index

 t

const decl t [public]
rank in a pathprediction.

 W

decl W [public]
masked weight to put on distance.

 PredictionDataSet

 EconometricObjective

virtual PredictionDataSet :: EconometricObjective ( subp )
The default econometric objective for a panel prediction: the overall GMM objective.
Parameters:
subp DoAll (default), solve all subproblems and return likelihood vector
Non-negative integer, solve only subproblem, return contribution to overall GMM
Returns:
M

 flist

decl flist [public]

 FMethod

decl FMethod [public]

 Nplace

decl Nplace [public]
observations column (index or label).

 Observations

PredictionDataSet :: Observations ( NLabelOrColumn , TLabelOrColumn )
Define columns where observations and time values appear.
Parameters:
NLabelOrColumn integer or string for column of data containing observation counts. This is used to adjust weight of rows in moments.
TLabelOrColumn integer or string for column of data containing model t value.
Data must still be sorted in time! However, this allows missing time periods to be skipped. Further, it allows for a special row containing moment influence/importance adjustments.

 Observed


 PredictionDataSet

PredictionDataSet :: PredictionDataSet ( UorCorL , label , method , iDist , wght , aggshares )
Create a panel prediction that is matched with external data.
Parameters:
UorCorL where to get fixed-effect values
matrix of indices or array of labels
UseLabel [default]
NotInData only allowed if F=1, then no column contains fixed variables
label name for the data
UseDefault [default] use classname of model class.
method solution method to call before predict
UnInitialized [default] no method (warning if there is heterogeneity)
iDist initial conditions set to PathPredictions
wght see GMMWeightOptions
aggshares FALSE [default] or a Fx1 vector of population shares for groups to be used when creating an aggregate prediction.

 Read

PredictionDataSet :: Read ( FNorDB , MaxT )
Read in external moments of tracked objects.
Parameters:
FNorDB string, name of file that contains the data.
A Ox database object.
MaxT TRUE: set length of prediction equal to the max{T} for all Paths, otherwise use individual lengths

 SimulateMomentVariances

PredictionDataSet :: SimulateMomentVariances ( N , ErgOrStateMat , fvals )
Simulate sample of outcomes compute path Variance matrix and save inverse.
Parameters:
N size of simulated sample for each PathPrediction.
ErogOrStateMat initial condition from simulated outcome paths
@fvals either DoALL or a a vector of fixed effect indices to compute.

 Tplace

decl Tplace [public]
time column (index or label).

 TrackingMatchToColumn

PredictionDataSet :: TrackingMatchToColumn ( LorC , mom )
Track an object that is matched to column in the data.
Parameters:
LorC label or column index in the data to associate with this moment.
mom Discrete object to track

 TrackingWithLabel

PredictionDataSet :: TrackingWithLabel ( InDataOrNot , ... )
Track one or more objects that are matched to columns using the object's label.
Parameters:
InDataOrNot TRUE: the UseLabel tag will be passed to PathPrediction::Tracking()
FALSE: the NotInData tag will be sent.
... objects or array of objects to track

 UorCorL

decl UorCorL [public]
matrix of indices or array of labels or UseLabel

 TrackObj

 print

TrackObj :: print ( obj )
Print mean and histogram of tracked object.