Skip to content

BUG: Sequential simulation in models with state_intercept - #5257

Merged
ChadFulton merged 2 commits into
statsmodels:masterfrom
ChadFulton:fix-multiple-simulate
Sep 26, 2018
Merged

ChadFulton merged 2 commits into
statsmodels:masterfrom
ChadFulton:fix-multiple-simulate

Conversation

@ChadFulton

Copy link
Copy Markdown
Member

SimulationSmoother objects store a Cython _{{prefix}}SimulationSmoother object that is reused each time simulate is called.

Unfortunately, simulate wasn't properly updating the Cython objects' state_intercept in the case of multiple simulate calls, so for example the following:

mod = sm.tsa.SARIMAX([1], order=(0, 0, 0), trend='c')
print(mod.simulate([1, 0], 5))
print(mod.simulate([10, 0], 5))

was giving:

[1. 1. 1. 1. 1.]
[10. 1. 1. 1. 1.]

instead of

[1. 1. 1. 1. 1.]
[10. 10. 10. 10. 10.]

This PR adds a unit test and corrects the issue.

@ChadFulton ChadFulton added comp-tsa type-bug type-bug-wrong serious bugs that silently return incorrect numbers labels Sep 25, 2018
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.03%) to 84.183% when pulling 4c7bff1 on ChadFulton:fix-multiple-simulate into 8515b22 on statsmodels:master.

@codecov

codecov Bot commented Sep 25, 2018

Copy link
Copy Markdown

Codecov Report

Merging #5257 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5257      +/-   ##
==========================================
+ Coverage    81.7%   81.72%   +0.01%     
==========================================
  Files         569      569              
  Lines       89695    89699       +4     
  Branches    10029    10028       -1     
==========================================
+ Hits        73288    73303      +15     
+ Misses      14133    14126       -7     
+ Partials     2274     2270       -4
Impacted Files Coverage Δ
statsmodels/tsa/statespace/tests/test_simulate.py 100% <100%> (ø) ⬆️
statsmodels/tsa/statespace/simulation_smoother.py 90.44% <100%> (+0.44%) ⬆️
statsmodels/tsa/statespace/representation.py 91.66% <0%> (-0.35%) ⬇️
statsmodels/regression/mixed_linear_model.py 89.77% <0%> (+0.79%) ⬆️
statsmodels/tsa/statespace/kalman_smoother.py 88.95% <0%> (+1.1%) ⬆️

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 8515b22...4c7bff1. Read the comment docs.

@ChadFulton
ChadFulton merged commit e1d1156 into statsmodels:master Sep 26, 2018
@ChadFulton
ChadFulton deleted the fix-multiple-simulate branch September 26, 2018 02:51
@josef-pkt josef-pkt added this to the 0.10 milestone Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-tsa type-bug type-bug-wrong serious bugs that silently return incorrect numbers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants