Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 3ff5ec9

Browse files
authored
Merge pull request #180 from OpenSourceEconomics/develop_segsell
develop_segsell
2 parents 24c62b2 + 138c230 commit 3ff5ec9

19 files changed

Lines changed: 1372 additions & 417 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: 19.3b0
44
hooks:
55
- id: black
6-
language_version: python3.6
6+
language_version: python3.7
77
exclude: ^docs/
88
- repo: https://github.com/pre-commit/pre-commit-hooks
99
rev: v1.2.3

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: python
22

33
python:
4-
- "3.6"
4+
- "3.7"
55

66
install:
77
- sudo apt-get update

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,44 @@ $ git clone https://github.com/OpenSourceEconomics/grmpy.git
1616
$ pip install -e .
1717
```
1818

19+
---
20+
## Quick Start
21+
> Initialization File
22+
23+
```grmpy``` relies on an ```"initialization.yml"``` file (referred to as ``ìnit_file`` below)
24+
to perform both simulation and estimation.
25+
For example, check out these two ``init_files`` for
26+
[simulation and parametric estimation](https://github.com/OpenSourceEconomics/grmpy/blob/master/promotion/grmpy_tutorial_notebook/files/tutorial.grmpy.yml) as well as
27+
a [semiparametric estimation](https://github.com/OpenSourceEconomics/grmpy/blob/master/promotion/grmpy_tutorial_notebook/files/tutorial_semipar.yml) setup.
28+
29+
Below you'll find some example code you can copy to jump-start your project.
30+
31+
> Simulation
32+
```
33+
import grmpy
34+
35+
# Specify the initilaization file you want to use, e.g.:
36+
init_file = "ProjectFiles/simulation.yml"
37+
38+
data = grmpy.simulate(init_file)
39+
```
40+
> Estimation
41+
42+
```
43+
import grmpy
44+
45+
# Specify the initilaization file you want to use, e.g.:
46+
init_file = "ProjectFiles/estimation.yml"
47+
48+
# Parametric Normal Model
49+
rslt = grmpy.fit(init_file, semipar=False)
50+
grmpy.plot_mte(rslt, init_file, color="blue", semipar=False, save_plot="MTE_par.png")
51+
52+
# Local Instrumental Variables (Semiparametric Model)
53+
rslt = grmpy.fit(init_file, semipar=True)
54+
grmpy.plot_mte(rslt, init_file, color="orange", semipar=True, nboot= 250, save_plot="MTE_semipar.png")
55+
```
56+
1957
Please visit our [online documentation](http://grmpy.readthedocs.io/) for tutorials and more.
2058

2159
-----

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: grmpy
22

33
dependencies:
4-
- python=3.6
4+
- python=3.7
55
- numpy
66
- pandas
77
- statsmodels

grmpy/KernReg/locpoly.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
This module provides a function for the estimation of a local polynomial
33
kernel regression.
44
"""
5+
from grmpy.KernReg.locpoly_auxiliary import (
6+
combine_bincounts_kernelweights,
7+
get_curve_estimator,
8+
get_kernelweights,
9+
is_sorted,
10+
)
511
from grmpy.KernReg.locpoly_linbin import linear_binning
612

7-
from grmpy.KernReg.locpoly_auxiliary import combine_bincounts_kernelweights
8-
from grmpy.KernReg.locpoly_auxiliary import get_curve_estimator
9-
from grmpy.KernReg.locpoly_auxiliary import get_kernelweights
10-
from grmpy.KernReg.locpoly_auxiliary import is_sorted
11-
1213

1314
def locpoly(
1415
x,
@@ -87,10 +88,7 @@ def locpoly(
8788
8889
Returns
8990
-------
90-
gridpoints: np.ndarry
91-
Array of sorted x values, i.e. grid points, at which the estimate
92-
of E[Y|X] (or its derivative) is computed.
93-
curvest: np.ndarry
91+
curvest: np.ndarray
9492
Array of M local estimators.
9593
"""
9694
# The input arrays x (predictor) and y (response variable)

grmpy/estimate/estimate.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
"""The module provides an estimation process given the simulated data set and the
22
initialization file.
33
"""
4-
from grmpy.check.check import check_presence_estimation_dataset
5-
from grmpy.check.check import check_presence_init
6-
from grmpy.check.check import check_est_init_dict
7-
from grmpy.check.check import check_par_init_file
84
from grmpy.check.auxiliary import read_data
9-
10-
from grmpy.read.read import read, check_append_constant
11-
12-
from grmpy.estimate.estimate_semipar import semipar_fit
5+
from grmpy.check.check import (
6+
check_est_init_dict,
7+
check_par_init_file,
8+
check_presence_estimation_dataset,
9+
)
1310
from grmpy.estimate.estimate_par import par_fit
11+
from grmpy.estimate.estimate_semipar import semipar_fit
12+
from grmpy.read.read import check_append_constant, read
1413

1514

1615
def fit(init_file, semipar=False):
1716
"""This function estimates the MTE based on a parametric normal model
1817
or, alternatively, via the semiparametric method of
1918
local instrumental variables (LIV).
19+
20+
Parameters
21+
----------
22+
init_file: yaml
23+
Initialization file containing parameters for the estimation
24+
process.
25+
26+
Returns
27+
------
28+
rslt: dict
29+
Result dictionary containing
30+
- quantiles
31+
- mte
32+
- mte_x
33+
- mte_u
34+
- mte_min
35+
- mte_max
36+
- X
37+
- b1
38+
- b0
2039
"""
2140

2241
# Load the estimation file
23-
check_presence_init(init_file)
2442
dict_ = read(init_file, semipar)
2543

2644
# Perform some consistency checks given the user's request

0 commit comments

Comments
 (0)