linearmodels icon indicating copy to clipboard operation
linearmodels copied to clipboard

[WIP] Arellano bond panel data

Open jaimeoliver1 opened this issue 2 years ago • 10 comments

Hi,

we have implemented the Arellano Bond estimator based on this previous implementation: https://gist.github.com/toobaz/6d01be09bbd56de7038fe8ff26780138. We have two comments:

  • The AB estimator is a panel data model, but it builds on top of an IV model. Therefore, we have thought that importing IVGMM from the linearmodels.iv.model sub-module was the easiest option, but we are open to other options.
  • We have not implemented any further tests, given that the model builds on top of already tested models. Any insight on what would the testing strategy be here?

This PR closes https://github.com/bashtage/linearmodels/issues/95

jaimeoliver1 avatar Mar 23 '22 17:03 jaimeoliver1

Hello @jaimeoliver1! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 3142:57: W605 invalid escape sequence '\e' Line 3222:100: E501 line too long (122 > 99 characters) Line 3264:100: E501 line too long (121 > 99 characters) Line 3292:100: E501 line too long (103 > 99 characters)

Comment last updated at 2022-07-15 10:05:55 UTC

pep8speaks avatar Mar 23 '22 17:03 pep8speaks

Can you run black and isort?

bashtage avatar Mar 23 '22 17:03 bashtage

Codecov Report

Merging #421 (0e9a902) into main (21d0591) will decrease coverage by 0.47%. The diff coverage is 18.48%.

@@            Coverage Diff             @@
##             main     #421      +/-   ##
==========================================
- Coverage   99.58%   99.11%   -0.48%     
==========================================
  Files          98       98              
  Lines       16899    20117    +3218     
  Branches     1987     2968     +981     
==========================================
+ Hits        16829    19938    +3109     
- Misses         30      142     +112     
+ Partials       40       37       -3     
Impacted Files Coverage Δ
linearmodels/panel/model.py 93.74% <18.48%> (-5.59%) :arrow_down:
linearmodels/__init__.py 83.33% <0.00%> (-14.23%) :arrow_down:
linearmodels/shared/hypotheses.py 98.55% <0.00%> (-1.45%) :arrow_down:
linearmodels/shared/utility.py 98.68% <0.00%> (-1.32%) :arrow_down:
linearmodels/panel/data.py 99.38% <0.00%> (-0.62%) :arrow_down:
linearmodels/panel/covariance.py 99.23% <0.00%> (-0.35%) :arrow_down:
linearmodels/tests/panel/test_utility.py 99.49% <0.00%> (-0.01%) :arrow_down:
linearmodels/iv/gmm.py 100.00% <0.00%> (ø)
linearmodels/iv/common.py 100.00% <0.00%> (ø)
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 21d0591...0e9a902. Read the comment docs.

codecov[bot] avatar Mar 23 '22 17:03 codecov[bot]

@bashtage I committed the file with the correct formatting

jaimeoliver1 avatar Mar 24 '22 08:03 jaimeoliver1

I think the best way to test would be to take the Stata code as a reference and test the various outputs and options.

bashtage avatar Mar 24 '22 17:03 bashtage

Overall looks very good.

  1. Need to add it to the docs.
  2. Can you break these long comments that are making PEP unhappy.
  3. Can you use a raw string r"Code with escape like \epsilon" to silence the other.

bashtage avatar Mar 24 '22 17:03 bashtage

Hi @bashtage,

I've tried adding the stata tests, however I've no access to stata, so I would need a bit of help here. I think the way to go would be starting by:

  1. Add the examples in the documentation here. The dataset used in the docs can be found here
  • xtabondnl(0/1).wl(0/2).(kys) yr1980-yr1984year, lags(2)
  1. Generate the model results and add them to the results_file

Once the results are in the stata-panel-simulated-results.txt, I'll be able to implement some tests here

jaimeoliver1 avatar Jul 15 '22 09:07 jaimeoliver1

Also, we fixed the linting error and silence the "\epsilon" issues. We also added documentation in the docstring. However, doc build is failing (even in master...)

jaimeoliver1 avatar Jul 15 '22 09:07 jaimeoliver1

Thanks for following up. I can run Stata and generate results.

bashtage avatar Jul 15 '22 10:07 bashtage

Going to close and reopen to trigger a rebuild.

bashtage avatar Jul 15 '22 10:07 bashtage