Repository: statsmodels/statsmodels

Issue:
BUG: Simulation smoothing with FILTER_COLLAPSED
@ChadFulton A run of the statespace tests using valgrind produced the following output.  This suggests that some data is being read that was not initialized.  I don't know enough about valgrind to tell if this is a bug in openblas or if this is a bug in statsmodels. You can see the calls that are made by from `SimulationSmoother simulate`.  It is possible that some of blocks passes to daxpy are not allocated correctly. 

Maybe @rgommers knows how to decode this output? (Or knows someone who could help?)

```
==13382== Invalid read of size 32
==13382==    at 0xF257B60: ??? (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xF257D9A: daxpy_k_SANDYBRIDGE (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xE255E3F: daxpy_ (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0x17CACA41: __pyx_f_5scipy_6linalg_11cython_blas_daxpy (cython_blas.c:4456)
==13382==    by 0x2AC782AA: __pyx_f_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_simulate (_simulation_smoother.c:16421)
==13382==    by 0x2AC78E0F: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_16simulate (_simulation_smoother.c:16637)
==13382==    by 0x2AC78D4F: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_17simulate (_simulation_smoother.c:16621)
==13382==    by 0x1F2979: _PyCFunction_FastCallDict (methodobject.c:231)
==13382==    by 0x1F2B79: _PyCFunction_FastCallKeywords (methodobject.c:294)
==13382==    by 0x2B2565: call_function (ceval.c:4830)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2AC1: fast_function (ceval.c:4971)
==13382==    by 0x2B2699: call_function (ceval.c:4851)
==13382==    by 0x2AC873: _PyEval_EvalFrameDefault (ceval.c:3344)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B286D: _PyFunction_FastCall (ceval.c:4912)
==13382==    by 0x2B2BD4: _PyFunction_FastCallDict (ceval.c:5014)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==    by 0x2ACCEA: _PyEval_EvalFrameDefault (ceval.c:3397)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B04F7: PyEval_EvalCodeEx (ceval.c:4180)
==13382==    by 0x1CB0E1: function_call (funcobject.c:604)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==  Address 0x38f39d90 is 0 bytes after a block of size 3,232 alloc'd
==13382==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13382==    by 0xDD1C413: PyDataMem_NEW_ZEROED (alloc.c:223)
==13382==    by 0xDD1C229: npy_alloc_cache_zero (alloc.c:111)
==13382==    by 0xDD88F96: PyArray_NewFromDescr_int (ctors.c:1059)
==13382==    by 0xDD8E253: PyArray_Zeros (ctors.c:2873)
==13382==    by 0x29E08EBD: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_allocate_arrays (_kalman_smoother.c:11623)
==13382==    by 0x29E19DF7: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset_filter_method (_kalman_smoother.c:13483)
==13382==    by 0x29E1CC63: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset (_kalman_smoother.c:14237)
==13382==    by 0x29E1AAB3: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_set_smoother_output (_kalman_smoother.c:13671)
==13382==    by 0x29E075B6: __pyx_pf_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother___init__ (_kalman_smoother.c:11389)
==13382==    by 0x29E07166: __pyx_pw_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_1__init__ (_kalman_smoother.c:11231)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x2ACE202D: __Pyx_PyObject_Call (_simulation_smoother.c:50826)
==13382==    by 0x2AC6102C: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother___init__ (_simulation_smoother.c:12354)
==13382==    by 0x2AC5F41A: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_1__init__ (_simulation_smoother.c:11905)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x193AE5: _PyObject_FastCallDict (abstract.c:2331)
==13382==    by 0x194075: _PyObject_FastCallKeywords (abstract.c:2496)
==13382==    by 0x2B26BA: call_function (ceval.c:4854)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2E36: _PyFunction_FastCallDict (ceval.c:5063)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==    by 0x2ACCEA: _PyEval_EvalFrameDefault (ceval.c:3397)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382== 
==13382== Invalid read of size 32
==13382==    at 0xF257B66: ??? (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xF257D9A: daxpy_k_SANDYBRIDGE (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xE255E3F: daxpy_ (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0x17CACA41: __pyx_f_5scipy_6linalg_11cython_blas_daxpy (cython_blas.c:4456)
==13382==    by 0x2AC782AA: __pyx_f_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_simulate (_simulation_smoother.c:16421)
==13382==    by 0x2AC78E0F: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_16simulate (_simulation_smoother.c:16637)
==13382==    by 0x2AC78D4F: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_17simulate (_simulation_smoother.c:16621)
==13382==    by 0x1F2979: _PyCFunction_FastCallDict (methodobject.c:231)
==13382==    by 0x1F2B79: _PyCFunction_FastCallKeywords (methodobject.c:294)
==13382==    by 0x2B2565: call_function (ceval.c:4830)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2AC1: fast_function (ceval.c:4971)
==13382==    by 0x2B2699: call_function (ceval.c:4851)
==13382==    by 0x2AC873: _PyEval_EvalFrameDefault (ceval.c:3344)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B286D: _PyFunction_FastCall (ceval.c:4912)
==13382==    by 0x2B2BD4: _PyFunction_FastCallDict (ceval.c:5014)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==    by 0x2ACCEA: _PyEval_EvalFrameDefault (ceval.c:3397)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B04F7: PyEval_EvalCodeEx (ceval.c:4180)
==13382==    by 0x1CB0E1: function_call (funcobject.c:604)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==  Address 0x38f39db0 is 32 bytes before a block of size 32 in arena "client"
==13382== 
==13382== Invalid read of size 32
==13382==    at 0xF257B5B: ??? (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xF257D9A: daxpy_k_SANDYBRIDGE (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xE255E3F: daxpy_ (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0x17CACA41: __pyx_f_5scipy_6linalg_11cython_blas_daxpy (cython_blas.c:4456)
==13382==    by 0x2AC782AA: __pyx_f_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_simulate (_simulation_smoother.c:16421)
==13382==    by 0x2AC78E0F: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_16simulate (_simulation_smoother.c:16637)
==13382==    by 0x2AC78D4F: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_17simulate (_simulation_smoother.c:16621)
==13382==    by 0x1F2979: _PyCFunction_FastCallDict (methodobject.c:231)
==13382==    by 0x1F2B79: _PyCFunction_FastCallKeywords (methodobject.c:294)
==13382==    by 0x2B2565: call_function (ceval.c:4830)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2AC1: fast_function (ceval.c:4971)
==13382==    by 0x2B2699: call_function (ceval.c:4851)
==13382==    by 0x2AC873: _PyEval_EvalFrameDefault (ceval.c:3344)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B286D: _PyFunction_FastCall (ceval.c:4912)
==13382==    by 0x2B2BD4: _PyFunction_FastCallDict (ceval.c:5014)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==    by 0x2ACCEA: _PyEval_EvalFrameDefault (ceval.c:3397)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B04F7: PyEval_EvalCodeEx (ceval.c:4180)
==13382==    by 0x1CB0E1: function_call (funcobject.c:604)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==  Address 0x38f39df0 is 0 bytes after a block of size 32 alloc'd
==13382==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13382==    by 0x15C3A9: _PyMem_RawMalloc (obmalloc.c:73)
==13382==    by 0x15C98A: PyMem_RawMalloc (obmalloc.c:386)
==13382==    by 0x179842: PyThread_allocate_lock (thread_pthread.h:287)
==13382==    by 0x29E6C5EB: __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__ (_kalman_smoother.c:36126)
==13382==    by 0x29E6C3EB: __pyx_memoryview___cinit__ (_kalman_smoother.c:35959)
==13382==    by 0x29E845D1: __pyx_tp_new_memoryview (_kalman_smoother.c:47973)
==13382==    by 0x209A3A: type_call (typeobject.c:895)
==13382==    by 0x29E8CF50: __Pyx_PyObject_Call (_kalman_smoother.c:50300)
==13382==    by 0x29E75683: __pyx_memoryview_new (_kalman_smoother.c:39896)
==13382==    by 0x29E947D7: __Pyx_ValidateAndInit_memviewslice (_kalman_smoother.c:54116)
==13382==    by 0x29E95527: __Pyx_PyObject_to_MemoryviewSlice_dcd__nn___pyx_t_5numpy_float64_t (_kalman_smoother.c:54223)
==13382==    by 0x29E093AC: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_allocate_arrays (_kalman_smoother.c:11654)
==13382==    by 0x29E19DF7: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset_filter_method (_kalman_smoother.c:13483)
==13382==    by 0x29E1CC63: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset (_kalman_smoother.c:14237)
==13382==    by 0x29E1AAB3: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_set_smoother_output (_kalman_smoother.c:13671)
==13382==    by 0x29E075B6: __pyx_pf_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother___init__ (_kalman_smoother.c:11389)
==13382==    by 0x29E07166: __pyx_pw_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_1__init__ (_kalman_smoother.c:11231)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x2ACE202D: __Pyx_PyObject_Call (_simulation_smoother.c:50826)
==13382==    by 0x2AC629C2: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother___init__ (_simulation_smoother.c:12630)
==13382==    by 0x2AC5F41A: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_1__init__ (_simulation_smoother.c:11905)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x193AE5: _PyObject_FastCallDict (abstract.c:2331)
==13382==    by 0x194075: _PyObject_FastCallKeywords (abstract.c:2496)
==13382==    by 0x2B26BA: call_function (ceval.c:4854)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2E36: _PyFunction_FastCallDict (ceval.c:5063)
==13382== 
==13382== Invalid read of size 32
==13382==    at 0xF257B6C: ??? (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xF257D9A: daxpy_k_SANDYBRIDGE (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xE255E3F: daxpy_ (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0x17CACA41: __pyx_f_5scipy_6linalg_11cython_blas_daxpy (cython_blas.c:4456)
==13382==    by 0x2AC782AA: __pyx_f_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_simulate (_simulation_smoother.c:16421)
==13382==    by 0x2AC78E0F: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_16simulate (_simulation_smoother.c:16637)
==13382==    by 0x2AC78D4F: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_17simulate (_simulation_smoother.c:16621)
==13382==    by 0x1F2979: _PyCFunction_FastCallDict (methodobject.c:231)
==13382==    by 0x1F2B79: _PyCFunction_FastCallKeywords (methodobject.c:294)
==13382==    by 0x2B2565: call_function (ceval.c:4830)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2AC1: fast_function (ceval.c:4971)
==13382==    by 0x2B2699: call_function (ceval.c:4851)
==13382==    by 0x2AC873: _PyEval_EvalFrameDefault (ceval.c:3344)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B286D: _PyFunction_FastCall (ceval.c:4912)
==13382==    by 0x2B2BD4: _PyFunction_FastCallDict (ceval.c:5014)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==    by 0x2ACCEA: _PyEval_EvalFrameDefault (ceval.c:3397)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B04F7: PyEval_EvalCodeEx (ceval.c:4180)
==13382==    by 0x1CB0E1: function_call (funcobject.c:604)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==  Address 0x38f39e50 is 32 bytes inside a block of size 48 alloc'd
==13382==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13382==    by 0x15C3A9: _PyMem_RawMalloc (obmalloc.c:73)
==13382==    by 0x15C98A: PyMem_RawMalloc (obmalloc.c:386)
==13382==    by 0xDD1C0E4: _npy_alloc_cache (alloc.c:66)
==13382==    by 0xDD1C2C6: npy_alloc_cache_dim (alloc.c:136)
==13382==    by 0xDD88E0F: PyArray_NewFromDescr_int (ctors.c:1020)
==13382==    by 0xDD8E253: PyArray_Zeros (ctors.c:2873)
==13382==    by 0x29E0AF3A: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_allocate_arrays (_kalman_smoother.c:11844)
==13382==    by 0x29E19DF7: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset_filter_method (_kalman_smoother.c:13483)
==13382==    by 0x29E1CC63: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset (_kalman_smoother.c:14237)
==13382==    by 0x29E1AAB3: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_set_smoother_output (_kalman_smoother.c:13671)
==13382==    by 0x29E075B6: __pyx_pf_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother___init__ (_kalman_smoother.c:11389)
==13382==    by 0x29E07166: __pyx_pw_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_1__init__ (_kalman_smoother.c:11231)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x2ACE202D: __Pyx_PyObject_Call (_simulation_smoother.c:50826)
==13382==    by 0x2AC629C2: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother___init__ (_simulation_smoother.c:12630)
==13382==    by 0x2AC5F41A: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_1__init__ (_simulation_smoother.c:11905)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x193AE5: _PyObject_FastCallDict (abstract.c:2331)
==13382==    by 0x194075: _PyObject_FastCallKeywords (abstract.c:2496)
==13382==    by 0x2B26BA: call_function (ceval.c:4854)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2E36: _PyFunction_FastCallDict (ceval.c:5063)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382== 
==13382== Invalid read of size 8
==13382==    at 0xF257C28: daxpy_k_SANDYBRIDGE (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0xE255E3F: daxpy_ (in /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so)
==13382==    by 0x17CACA41: __pyx_f_5scipy_6linalg_11cython_blas_daxpy (cython_blas.c:4456)
==13382==    by 0x2AC782AA: __pyx_f_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_simulate (_simulation_smoother.c:16421)
==13382==    by 0x2AC78E0F: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_16simulate (_simulation_smoother.c:16637)
==13382==    by 0x2AC78D4F: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_17simulate (_simulation_smoother.c:16621)
==13382==    by 0x1F2979: _PyCFunction_FastCallDict (methodobject.c:231)
==13382==    by 0x1F2B79: _PyCFunction_FastCallKeywords (methodobject.c:294)
==13382==    by 0x2B2565: call_function (ceval.c:4830)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2AC1: fast_function (ceval.c:4971)
==13382==    by 0x2B2699: call_function (ceval.c:4851)
==13382==    by 0x2AC873: _PyEval_EvalFrameDefault (ceval.c:3344)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B286D: _PyFunction_FastCall (ceval.c:4912)
==13382==    by 0x2B2BD4: _PyFunction_FastCallDict (ceval.c:5014)
==13382==    by 0x193A2E: _PyObject_FastCallDict (abstract.c:2310)
==13382==    by 0x193CAA: _PyObject_Call_Prepend (abstract.c:2373)
==13382==    by 0x1AE10C: method_call (classobject.c:317)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==    by 0x2ACCEA: _PyEval_EvalFrameDefault (ceval.c:3397)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B04F7: PyEval_EvalCodeEx (ceval.c:4180)
==13382==    by 0x1CB0E1: function_call (funcobject.c:604)
==13382==    by 0x193858: PyObject_Call (abstract.c:2261)
==13382==    by 0x2B307E: do_call_core (ceval.c:5099)
==13382==  Address 0x38f3a370 is 16 bytes before a block of size 192 alloc'd
==13382==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13382==    by 0x15C3A9: _PyMem_RawMalloc (obmalloc.c:73)
==13382==    by 0x15CC24: PyObject_Malloc (obmalloc.c:479)
==13382==    by 0x180014: _PyObject_GC_Alloc (gcmodule.c:1717)
==13382==    by 0x1800DE: _PyObject_GC_Malloc (gcmodule.c:1739)
==13382==    by 0x209BE3: PyType_GenericAlloc (typeobject.c:936)
==13382==    by 0x29E844DB: __pyx_tp_new_memoryview (_kalman_smoother.c:47962)
==13382==    by 0x209A3A: type_call (typeobject.c:895)
==13382==    by 0x29E8CF50: __Pyx_PyObject_Call (_kalman_smoother.c:50300)
==13382==    by 0x29E75683: __pyx_memoryview_new (_kalman_smoother.c:39896)
==13382==    by 0x29E947D7: __Pyx_ValidateAndInit_memviewslice (_kalman_smoother.c:54116)
==13382==    by 0x29E95989: __Pyx_PyObject_to_MemoryviewSlice_dcd_d__nn___pyx_t_5numpy_float64_t (_kalman_smoother.c:54246)
==13382==    by 0x29E0B398: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_allocate_arrays (_kalman_smoother.c:11863)
==13382==    by 0x29E19DF7: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset_filter_method (_kalman_smoother.c:13483)
==13382==    by 0x29E1CC63: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_reset (_kalman_smoother.c:14237)
==13382==    by 0x29E1AAB3: __pyx_f_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_set_smoother_output (_kalman_smoother.c:13671)
==13382==    by 0x29E075B6: __pyx_pf_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother___init__ (_kalman_smoother.c:11389)
==13382==    by 0x29E07166: __pyx_pw_11statsmodels_3tsa_10statespace_16_kalman_smoother_15dKalmanSmoother_1__init__ (_kalman_smoother.c:11231)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x2ACE202D: __Pyx_PyObject_Call (_simulation_smoother.c:50826)
==13382==    by 0x2AC629C2: __pyx_pf_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother___init__ (_simulation_smoother.c:12630)
==13382==    by 0x2AC5F41A: __pyx_pw_11statsmodels_3tsa_10statespace_20_simulation_smoother_19dSimulationSmoother_1__init__ (_simulation_smoother.c:11905)
==13382==    by 0x209B35: type_call (typeobject.c:915)
==13382==    by 0x193AE5: _PyObject_FastCallDict (abstract.c:2331)
==13382==    by 0x194075: _PyObject_FastCallKeywords (abstract.c:2496)
==13382==    by 0x2B26BA: call_function (ceval.c:4854)
==13382==    by 0x2AC726: _PyEval_EvalFrameDefault (ceval.c:3328)
==13382==    by 0x29E76E: PyEval_EvalFrameEx (ceval.c:754)
==13382==    by 0x2B03D9: _PyEval_EvalCodeWithName (ceval.c:4159)
==13382==    by 0x2B2E36: _PyFunction_FastCallDict (ceval.c:5063)
```


Discussion:
FWIW, 16421 is

```
    /* "statsmodels/tsa/statespace/_simulation_smoother.pyx":1054
 *             # \tilde eps_t = \hat eps_t^* + eps_t^+
 *             blas.dcopy(&nobs_endog, &self.disturbance_variates[0], &inc, &self.simulated_measurement_disturbance[0,0], &inc)
 *             blas.daxpy(&nobs_endog, &alpha, &self.simulated_smoother.smoothed_measurement_disturbance[0,0], &inc,             # <<<<<<<<<<<<<<
 *                                                      &self.simulated_measurement_disturbance[0,0], &inc)
 * 
 */
    __pyx_f_5scipy_6linalg_11cython_blas_daxpy((&__pyx_v_nobs_endog), (&__pyx_v_alpha), (&(*((__pyx_t_5numpy_float64_t *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_5numpy_float64_t *) __pyx_v_self->simulated_smoother->smoothed_measurement_disturbance.data) + __pyx_t_90)) ) + __pyx_t_91 * __pyx_v_self->simulated_smoother->smoothed_measurement_disturbance.strides[1]) )))), (&__pyx_v_inc), (&(*((__pyx_t_5numpy_float64_t *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_5numpy_float64_t *) __pyx_v_self->simulated_measurement_disturbance.data) + __pyx_t_92)) ) + __pyx_t_93 * __pyx_v_self->simulated_measurement_disturbance.strides[1]) )))), (&__pyx_v_inc));
```


Thanks very much! You're right, this is a bug when the FILTER_COLLAPSED option is used with simulation smoothing.

Resolving patch:
diff --git a/statsmodels/tsa/statespace/simulation_smoother.py b/statsmodels/tsa/statespace/simulation_smoother.py
--- a/statsmodels/tsa/statespace/simulation_smoother.py
+++ b/statsmodels/tsa/statespace/simulation_smoother.py
@@ -522,7 +522,7 @@ def simulated_state_disturbance(self):
         return self._simulated_state_disturbance
 
     def simulate(self, simulation_output=-1, disturbance_variates=None,
-                 initial_state_variates=None):
+                 initial_state_variates=None, pretransformed_variates=False):
         r"""
         Perform simulation smoothing
 
@@ -564,7 +564,8 @@ def simulate(self, simulation_output=-1, disturbance_variates=None,
         # simulation
         if disturbance_variates is not None:
             self._simulation_smoother.set_disturbance_variates(
-                np.array(disturbance_variates, dtype=self.dtype)
+                np.array(disturbance_variates, dtype=self.dtype),
+                pretransformed=pretransformed_variates
             )
         else:
             self._simulation_smoother.draw_disturbance_variates()
@@ -573,7 +574,8 @@ def simulate(self, simulation_output=-1, disturbance_variates=None,
         # simulation
         if initial_state_variates is not None:
             self._simulation_smoother.set_initial_state_variates(
-                np.array(initial_state_variates, dtype=self.dtype)
+                np.array(initial_state_variates, dtype=self.dtype),
+                pretransformed=pretransformed_variates
             )
         else:
             self._simulation_smoother.draw_initial_state_variates()


Test patch:
diff --git a/statsmodels/tsa/statespace/tests/test_collapsed.py b/statsmodels/tsa/statespace/tests/test_collapsed.py
--- a/statsmodels/tsa/statespace/tests/test_collapsed.py
+++ b/statsmodels/tsa/statespace/tests/test_collapsed.py
@@ -418,6 +418,35 @@ def test_using_alterate(self):
 
 
 class TestDFM(object):
+    @classmethod
+    def create_model(cls, obs, **kwargs):
+        # Create the model with typical state space
+        mod = MLEModel(obs, k_states=2, k_posdef=2, **kwargs)
+        mod['design'] = np.array([[-32.47143586, 17.33779024],
+                                  [-7.40264169, 1.69279859],
+                                  [-209.04702853, 125.2879374]])
+        mod['obs_cov'] = np.diag(
+            np.array([0.0622668, 1.95666886, 58.37473642]))
+        mod['transition'] = np.array([[0.29935707, 0.33289005],
+                                      [-0.7639868, 1.2844237]])
+        mod['selection'] = np.eye(2)
+        mod['state_cov'] = np.array([[1.2, -0.25],
+                                     [-0.25, 1.1]])
+        mod.initialize_approximate_diffuse(1e6)
+        return mod
+
+    @classmethod
+    def collapse(cls, obs, **kwargs):
+        mod = cls.create_model(obs, **kwargs)
+        mod.smooth([], return_ssm=True)
+
+        _ss = mod.ssm._statespace
+        out = np.zeros((mod.nobs, mod.k_states))
+        for t in range(mod.nobs):
+            _ss.seek(t, mod.ssm.filter_univariate, 1)
+            out[t] = np.array(_ss.collapse_obs)
+        return out
+
     @classmethod
     def setup_class(cls, which='mixed', *args, **kwargs):
         # Data
@@ -438,40 +467,27 @@ def setup_class(cls, which='mixed', *args, **kwargs):
             obs.iloc[119:130, 0] = np.nan
             obs.iloc[119:130, 2] = np.nan
 
-        # Create the model with typical state space
-        mod = MLEModel(obs, k_states=2, k_posdef=2, **kwargs)
-        mod['design'] = np.array([[-32.47143586, 17.33779024],
-                                  [-7.40264169, 1.69279859],
-                                  [-209.04702853, 125.2879374]])
-        mod['obs_cov'] = np.diag(
-            np.array([0.0622668, 1.95666886, 58.37473642]))
-        mod['transition'] = np.array([[0.29935707, 0.33289005],
-                                      [-0.7639868, 1.2844237]])
-        mod['selection'] = np.eye(2)
-        mod['state_cov'] = np.array([[1.2, -0.25],
-                                     [-0.25, 1.1]])
-        mod.initialize_approximate_diffuse(1e6)
+        mod = cls.create_model(obs, **kwargs)
         cls.model = mod.ssm
 
         n_disturbance_variates = (
             (cls.model.k_endog + cls.model.k_posdef) * cls.model.nobs
         )
+        np.random.seed(1234)
+        dv = np.random.normal(size=n_disturbance_variates)
+        isv = np.random.normal(size=cls.model.k_states)
 
         # Collapsed filtering, smoothing, and simulation smoothing
         cls.model.filter_collapsed = True
         cls.results_b = cls.model.smooth()
-        cls.sim_b = cls.model.simulation_smoother(
-            disturbance_variates=np.zeros(n_disturbance_variates),
-            initial_state_variates=np.zeros(cls.model.k_states)
-        )
+        cls.sim_b = cls.model.simulation_smoother()
+        cls.sim_b.simulate(disturbance_variates=dv, initial_state_variates=isv)
 
         # Conventional filtering, smoothing, and simulation smoothing
         cls.model.filter_collapsed = False
         cls.results_a = cls.model.smooth()
-        cls.sim_a = cls.model.simulation_smoother(
-            disturbance_variates=np.zeros(n_disturbance_variates),
-            initial_state_variates=np.zeros(cls.model.k_states)
-        )
+        cls.sim_a = cls.model.simulation_smoother()
+        cls.sim_a.simulate(disturbance_variates=dv, initial_state_variates=isv)
 
         # Create the model with augmented state space
         kwargs.pop('filter_collapsed', None)
@@ -618,19 +634,22 @@ def test_smoothed_state_disturbance_cov(self):
     def test_simulation_smoothed_state(self):
         assert_allclose(
             self.sim_a.simulated_state,
-            self.sim_a.simulated_state
+            self.sim_b.simulated_state
         )
 
+    # Skipped because "measurement" refers to different things; even different
+    # dimensions
+    @skip
     def test_simulation_smoothed_measurement_disturbance(self):
         assert_allclose(
             self.sim_a.simulated_measurement_disturbance,
-            self.sim_a.simulated_measurement_disturbance
+            self.sim_b.simulated_measurement_disturbance
         )
 
     def test_simulation_smoothed_state_disturbance(self):
         assert_allclose(
             self.sim_a.simulated_state_disturbance,
-            self.sim_a.simulated_state_disturbance
+            self.sim_b.simulated_state_disturbance
         )
 
 
@@ -675,15 +694,28 @@ def test_smooth_method(self):
                      SMOOTH_ALTERNATIVE)
 
 
-class TestDFMClassicalSmoothing(TestDFM):
+class TestDFMMeasurementDisturbance(TestDFM):
     @classmethod
     def setup_class(cls, *args, **kwargs):
-        super(TestDFMClassicalSmoothing, cls).setup_class(
-            smooth_method=SMOOTH_CLASSICAL, **kwargs)
+        super(TestDFMMeasurementDisturbance, cls).setup_class(
+            smooth_method=SMOOTH_CLASSICAL, which='none', **kwargs)
 
-    def test_smooth_method(self):
-        assert_equal(self.model.smooth_method, SMOOTH_CLASSICAL)
-        assert_equal(self.model._kalman_smoother.smooth_method,
-                     SMOOTH_CLASSICAL)
-        assert_equal(self.model._kalman_smoother._smooth_method,
-                     SMOOTH_CLASSICAL)
+    def test_smoothed_state_disturbance(self):
+        assert_allclose(
+            self.results_a.smoothed_state_disturbance,
+            self.results_b.smoothed_state_disturbance, atol=1e-7)
+
+    def test_smoothed_measurement_disturbance(self):
+        assert_allclose(
+            self.collapse(self.results_a.smoothed_measurement_disturbance.T).T,
+            self.results_b.smoothed_measurement_disturbance, atol=1e-7)
+
+    def test_simulation_smoothed_measurement_disturbance(self):
+        assert_allclose(
+            self.collapse(self.sim_a.simulated_measurement_disturbance.T),
+            self.sim_b.simulated_measurement_disturbance.T, atol=1e-7)
+
+    def test_simulation_smoothed_state_disturbance(self):
+        assert_allclose(
+            self.sim_a.simulated_state_disturbance,
+            self.sim_b.simulated_state_disturbance, atol=1e-7)