Skip to content

Commit a6843e2

Browse files
authored
Merge pull request #64 from OpenSourceEconomics/ex1
changes to estimation
2 parents 883bc59 + 2bfce38 commit a6843e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2603
-3424
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ruspy.rst
2222
modules.rst
2323
_generated
2424
*.db
25+
*.DS_Store
2526
results_ipopt.txt
2627
get_iskhakov_results
2728

docs/source/api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ API
44

55
Here the API of ruspy is documented.
66

7-
87
.. autosummary::
98
:toctree: _generated
109
:template: custom-module-template.rst

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"sphinx.ext.todo",
5353
"sphinx.ext.viewcode",
5454
"numpydoc",
55+
"nbsphinx",
5556
]
5657

5758
autosummary_mock_imports = [

docs/source/credits.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ Contributors
2121
------------
2222

2323
`Sebastian Becker <https://github.com/sebecker>`_, `Pascal Heid <https://github
24-
.com/Pascalheid>`_
24+
.com/Pascalheid>`_, `Viktoria Kleinschmidt <https://github.com/viktoriakleinschmidt>`_
25+
2526

2627

2728
Master Theses

docs/source/economics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ looking like the following:
233233
234234
\begin{equation}
235235
\max_{(\theta, EV)} \; log \; l^f_{aug}(a_1, ..., a_T, x_1, ...., x_T | a_0, x_0, \theta, EV) \\
236-
\text{subject to } \; EV = T(EV, \theta).
236+
\text{ subject to } \; EV = T(EV, \theta).
237237
\end{equation}
238238
239239
The constraints are generally nonlinear functions which restricts the use of

docs/source/estimation.rst

Lines changed: 151 additions & 223 deletions
Large diffs are not rendered by default.

docs/source/index.rst

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,10 @@ ruspy can be installed via conda with:
4040
4141
4242
After installing ruspy, you can familiarize yourself with ruspy's tools and
43-
interface by exploring multiple tutorial notebooks. Note that for a full
43+
interface by exploring multiple tutorial notebooks, which can be found
44+
`here <tutorials.html>`_. Note that for a full
4445
comprehension, you should read the papers above or study at least the economics
45-
section of this documentation. We provide a `simulation <https://github
46-
.com/OpenSourceEconomics/ruspy/blob/master/promotion
47-
/simulation/simulation_convergence.ipynb>`_ and `replication <https://
48-
github.com/OpenSourceEconomics/ruspy/blob/master/promotion
49-
/replication/replication.ipynb>`_. The first one puts more focus on the simulation
50-
function of ruspy while the latter has a closer look at the estimation function.
51-
Lastly, for a combination of both you can further dive into the `replication of
52-
Iskhakov et al. (2016) <https://github
53-
.com/OpenSourceEconomics/ruspy/blob/master/promotion/replication
54-
/replication_iskhakov_et_al_2016.ipynb>`_ notebook which allows to replicate this paper
55-
using ruspy.
56-
46+
section of this documentation.
5747

5848

5949
.. toctree::
@@ -64,6 +54,7 @@ using ruspy.
6454
model_code
6555
estimation
6656
simulation
57+
tutorials
6758
references
6859
credits
6960
api

docs/source/model_code.rst

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ hyperbolic cost function
105105
---------------
106106
Cost parameters
107107
---------------
108-
The second in put are the cost parameters, which are stored as a one dimensional
108+
The second input are the cost parameters, which are stored as a one dimensional
109109
*numpy.array*. At the first position always the replacement cost :math:`RC` is stored.
110110
The next positions are subsequently filled with :math:`\theta_{11}, \theta_{12}, ...`.
111111
The exact number depends on the functional form.
@@ -181,17 +181,18 @@ allow to specify, when the algorithm switches from contraction to Newton-Kantoro
181181
iterations and general parameters, which let the algorithm stop. So far, there is no
182182
switching back implemented.
183183

184-
**max_cont_steps :** *(int)* The maximum number of contraction iterations before
185-
switching to Newton-Kantorovich iterations. Default is 20.
184+
- **max_cont_steps :** *(int)* The maximum number of contraction iterations before
185+
switching to Newton-Kantorovich iterations. Default is 20.
186186

187-
**switch_tol :** *(float)* If this threshold is reached by contraction iterations, then
188-
the algorithm switches to Newton-Kantorovich iterations. Default is :math:`10^{-3}`.
187+
- **switch_tol :** *(float)* If this threshold is reached by contraction iterations,
188+
then the algorithm switches to Newton-Kantorovich iterations. Default is
189+
:math:`10^{-3}`.
189190

190-
**max_newt_kant_steps :** *(int)* The maximum number of Newton-Kantorovich iterations
191-
before the algorithm stops. Default is 20.
191+
- **max_newt_kant_steps :** *(int)* The maximum number of Newton-Kantorovich iterations
192+
before the algorithm stops. Default is 20.
192193

193-
**threshold :** *(float)* If this threshold is reached by Newton-Kantorovich iterations,
194-
then the algorithm stops. Default is :math:`10^{-12}`.
194+
- **threshold :** *(float)* If this threshold is reached by Newton-Kantorovich
195+
iterations, then the algorithm stops. Default is :math:`10^{-12}`.
195196

196197
.. _ev:
197198

@@ -276,8 +277,9 @@ the following inputs:
276277
Initialization Dictionairy
277278
---------------------------
278279

279-
This is the :ref:`init_dict` needed for the ``estimate`` function. The ``get_demand``
280-
function draws the model specifications needed to calculate demand from this.
280+
This is the :ref:`init_dict` needed for the function ``get_criterion_function``.
281+
The ``get_demand`` function draws the model specifications needed to calculate
282+
demand from this.
281283

282284

283285
.. _demand_dict:
@@ -291,23 +293,22 @@ This dictionairy provides all the necessary information about how the demand
291293
function is supposed to look like and how precisely it is supposed to be calculated.
292294
It has to hold the following keys:
293295

294-
**RC_lower_bound :** *(float)* The lowest replacement cost for which the demand
295-
is supposed to be calculated.
296+
- **RC_lower_bound :** *(float)* The lowest replacement cost for which the demand is
297+
supposed to be calculated.
296298

297-
**RC_upper_bound :** *(float)* The highest replacement cost for which the demand
298-
is supposed to be calculated.
299+
- **RC_upper_bound :** *(float)* The highest replacement cost for which the demand is
300+
supposed to be calculated.
299301

300-
**demand_evaluations :** *(int)* The grid size of the replacement cost between
301-
RC_lower_bound and RC_upper_bound for which the demand level shall be calculated.
302+
- **demand_evaluations :** *(int)* The grid size of the replacement cost between
303+
RC_lower_bound and RC_upper_bound for which the demand level shall be calculated.
302304

303-
**tolerance :** *(float)* The stopping tolerance for the fixed point calculation
304-
needed to obtain each demand level.
305+
- **tolerance :** *(float)* The stopping tolerance for the fixed point calculation
306+
needed to obtain each demand level.
305307

306-
**num_periods :** *(int)* Number of months :math:`T` for which the expected demand
307-
is derived. Consequently, set it to 12 if you want to get the annual expected demand.
308+
- **num_periods :** *(int)* Number of months :math:`T` for which the expected demand
309+
is derived. Consequently, set it to 12 if you want to get the annual expected demand.
308310

309-
**num_buses :** *(int)* Number of buses :math:`M` for which the demand is
310-
calculated.
311+
- **num_buses :** *(int)* Number of buses :math:`M` for which the demand is calculated.
311312

312313

313314
.. _demand_params:
@@ -339,6 +340,6 @@ and for the amount of buses in the fleet. It also contains a column *success*
339340
which indicates whether the fixed point algorithm converged successfully.
340341

341342

343+
342344
The use of the ``get_demand`` function is shown in the following `replication
343-
<https://github.com/OpenSourceEconomics/ruspy/blob/kantevorich/promotion
344-
/replication/replication.ipynb>`_ notebook.
345+
<tutorials/replication/replication.ipynb>`_ notebook.

docs/source/references.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Iskhakov, F., Lee, J., Rust, J., Schjerning, B., & Seo, K. (2016). `Comment on
1111
Kantorovich, L. (1948). On Newton’s method for functional equations. *Doklady Akademii
1212
Nauk SSSR, 71* (1), 1237– 1240.
1313

14-
Kraft, D. (1994). `Algorithm 733: TOMP–Fortran modules for optimal control calculations <https://doi.org/10.1145/192115.192124>`_
14+
Kraft, D. (1994). `Algorithm 733: TOMP–Fortran modules for optimal control calculations
15+
<https://doi.org/10.1145/192115.192124>`_
1516
*ACM Transactions on Mathematical Software, vol. 20*, no. 3, pp. 262-281.
1617

1718
McFadden, D. (1973). `Conditional logit analysis of qualitative choice behavior

docs/source/simulation.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ Simulation initialization dictionary
2929

3030
The initialization dictionary contains the following keys:
3131

32-
**seed :** *(int)* A positive integer setting the random seed for drawing random
33-
numbers. If none given, some random seed is drawn.
32+
- **seed :** *(int)* A positive integer setting the random seed for drawing random
33+
numbers. If none given, some random seed is drawn.
3434

35-
**discount_factor :** *(float)* See :ref:`disc_fac` for more details.
35+
- **discount_factor :** *(float)* See :ref:`disc_fac` for more details.
3636

37-
**buses :** *(int)* The number of buses to be simulated.
37+
- **buses :** *(int)* The number of buses to be simulated.
38+
39+
- **periods :** *(int)* The number of periods to be simulated.
3840

39-
**periods :** *(int)* The number of periods to be simulated.
4041

4142

4243
The simulation process
@@ -76,14 +77,13 @@ The simulation
7677
--------------
7778
After the simulation process the observed states, decisions and mileage uses are
7879
returned. Additionally the agent's utility. They are all stored in pandas.DataFrame with
79-
column names **states**, **decisions**, **utilities** and **usage**.Hence, the observed
80+
column names **states**, **decisions**, **utilities** and **usage**. Hence, the observed
8081
data is a subset of the returned Dataframe.
8182

8283
Demonstration
8384
-------------
8485

85-
In the promotion folder of the repository are two demonstration jupyter notebooks. The
86-
`simulation <https://github.com/OpenSourceEconomics/ruspy/blob/master/promotion
87-
/simulation/simulation_convergence.ipynb>`_ notebook allows to easily
88-
experiment with the estimation methods described here. If you have have everything
89-
setup, then it should be easy to run it.
86+
The `simulation notebook <tutorials/simulation/simulation_convergence.ipynb>`_ allows to
87+
easily experiment with the estimation methods described here. The notebook can be
88+
downloaded from the `simulation folder <tutorials/simulation>`_ in the tutorials of
89+
ruspy. If you have have everything setup, then it should be easy to run it.

0 commit comments

Comments
 (0)