
    'YHhh                        d Z ddlZddlZddlmZmZ ddlZddl	Z	ddl
mZ ddlmZ ddlmZ ddlmZ ej$                  j'                  ej$                  j)                  e            Z G d d	      Z G d
 de      Z G d d      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d      Zd Zy)ai  
Tests for univariate treatment of multivariate models

TODO skips the tests for measurement disturbance and measurement disturbance
covariance, which do not pass. The univariate smoother *appears* to be
correctly implemented against Durbin and Koopman (2012) chapter 6, yet still
gives a different answer from the conventional smoother. It's not clear if
this is intended (i.e. it has to be at least slightly different, since the
conventional smoother can return a non-diagonal covariance matrix whereas the
univariate smoother must return a diagonal covariance matrix).

Author: Chad Fulton
License: Simplified-BSD
    N)assert_almost_equalassert_allclose)datasets)MLEModel)results_kalman_filter)SARIMAXc                       e Zd ZdZeedfd       Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestClark1989aj  
    Clark's (1989) bivariate unobserved components model of real GDP (as
    presented in Kim and Nelson, 1999)

    Tests two-dimensional observation data.

    Test data produced using GAUSS code described in Kim and Nelson (1999) and
    found at http://econ.korea.ac.kr/~cjkim/SSMARKOV.htm

    See `results.results_kalman_filter` for more information.
    Fc           
         t         j                  | _        t        j                  | j                  d         | _        t        j                  | j                  d   t        j                  ddd      ddg	      d
d  }t        j                  |d         |d<   |d   dz  |d<   d}t        |fd|i|| _
        | j                  j                  | _        g dg dg| j                  j                  d d d d df<   g d| j                  j                  g dg dg df<   t        j                  | j                  j                         | j                  _        t        j$                  | j                  d         \
  }}}}	}
}}}}}|||g| j                  j                  g dg dg df<   ||g| j                  j                  ddgddgddgf<   |
dz  | j                  j&                  d<   |dz  |dz  dd|dz  |	dz  g| j                  j(                  t        j*                  |      t        j,                  |t.              fz   <   t        j,                  |f      }t        j                  |      dz  }|sqt        j0                  t        j0                  | j                  j                  d d d d df   |      | j                  j                  d d d d df   j2                        }nd| j                  _        | j                  j7                  ||       d| j                  _        | j                  j;                         | _        | j                  j>                  | j                  j@                  z   | j                  jB                  z  }| j                  jE                  t        j,                  |      t        j,                  | j                  j                               | _#        d| j                  _$        | j                  j;                         | _%        | j                  jE                  t        j,                  |      t        j,                  | j                  j                               | _&        y )Nstatesdataz
1947-01-01z
1995-07-01QS)freqGDPUNEMP)indexcolumns   d      k_states)   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r         r      )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   
parameters)r   r   r   )r   r   r   )r   r   r   r   r   r   r   r   )dtypeTdisturbance_variatesinitial_state_variates)'r   uc_bitruepd	DataFrametrue_states
date_rangenplogr   mlemodelssmmodeldesign
transitioneyer   	selectionarrayobs_cov	state_covdiag_indiceszerosintdotTtiming_init_filteredinitialize_knownfilter_conventionalsmoothconventional_resultsk_endogk_posdefnobssimulation_smootherconventional_simfilter_univariateunivariate_resultsunivariate_sim)clsr   alternate_timingkwargsr   r   sigma_vsigma_esigma_wsigma_vlsigma_ecphi_1phi_2alpha_1alpha_2alpha_3initial_stateinitial_state_covn_disturbance_variatess                      i/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/tsa/statespace/tests/test_univariate.pysetup_classzTestClark1989.setup_class*   s    )..,,sxx'9: ||HHV--lFG$
 "	
 ffT%[)Ugs*WBxB6BLL$$	 &89K$L		Aq!
 %	 			%%%'	

 !ffSYY%7%78		 57HHHH\"5
	2'7Hh	w Wg?
		)Y	:; ;@		q!fq!fq!f56%-q[		'" QJ
Aq'1*hkK
 			OOH%rxx'D&FF	H (-FF8,S0   "syy++Aq!G46GH		$$Q1W-//!
 .2CII*		""=2CD )-		%#&99#3#3#5 YY!3!33syy~~E 	  #yy<<!#*@!A#%88CII,>,>#?  =  
 '+		#!$!1!1!3 YY::!#*@!A#%88CII,>,>#? ; 
    c                     | j                   j                  rJ | j                  j                  sJ t        | j                   j                  d   d       t        | j                  j                  d   d       y )Nr   g+1a@gEKК_*^@r=   rC   rD   r   forecasts_error_covselfs    rV   test_using_univariatez#TestClark1989.test_using_univariatev   sn    
 ,,>>>>&&8888%%99'B	
 	##77@	
rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y Nr   	   r   r=   	forecastsrD   r\   s    rV   test_forecastszTestClark1989.test_forecasts   <    %%//15##--ad3Q	
rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r`   r   r=   forecasts_errorrD   r\   s    rV   test_forecasts_errorz"TestClark1989.test_forecasts_error   <    %%55ad;##33AqD91	
rX   c                     t        | j                  j                  ddd d f   | j                  j                  ddd d f   d       y r`   r   r=   r[   rD   r\   s    rV   test_forecasts_error_covz&TestClark1989.test_forecasts_error_cov   @    %%99!Q'B##771a@!	
rX   c                 n    t        | j                  j                  | j                  j                  d       y N   r   r=   filtered_staterD   r\   s    rV   test_filtered_statez!TestClark1989.test_filtered_state   *    %%44##22A	
rX   c                 n    t        | j                  j                  | j                  j                  d       y Nra   r   r=   filtered_state_covrD   r\   s    rV   test_filtered_state_covz%TestClark1989.test_filtered_state_cov   *    %%88##66	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rp   r   r=   predicted_staterD   r\   s    rV   test_predicted_statez"TestClark1989.test_predicted_state   *    %%55##33Q	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r=   predicted_state_covrD   r\   s    rV   test_predicted_state_covz&TestClark1989.test_predicted_state_cov   *    %%99##77	
rX   c                 l    t        | j                  j                  | j                  j                         y Nr   r=   llf_obsrD   r\   s    rV   test_loglikezTestClark1989.test_loglike   (    %%--##++	
rX   c                 n    t        | j                  j                  | j                  j                  d       y N   r   r=   smoothed_staterD   r\   s    rV   test_smoothed_statesz"TestClark1989.test_smoothed_states   ru   rX   c                 n    t        | j                  j                  | j                  j                  d       y Nr   r   r=   smoothed_state_covrD   r\   s    rV   test_smoothed_states_covz&TestClark1989.test_smoothed_states_cov   r{   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r=    smoothed_measurement_disturbancerD   r\   s    rV   %test_smoothed_measurement_disturbancez3TestClark1989.test_smoothed_measurement_disturbance   s*    %%FF##DDa	
rX   c                     | j                   }| j                  }t        |j                  j	                         |j                  j	                         d       y rw   r=   rD   r   $smoothed_measurement_disturbance_covdiagonalr]   convunivs      rV   )test_smoothed_measurement_disturbance_covz7TestClark1989.test_smoothed_measurement_disturbance_cov   sF    ((&&55>>@55>>@!	
rX   c                 p    t        | j                  j                  | j                  j                  d       y NgHz>atolr   r=   smoothed_state_disturbancerD   r\   s    rV   test_smoothed_state_disturbancez-TestClark1989.test_smoothed_state_disturbance   +    %%@@##>>	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r=   smoothed_state_disturbance_covrD   r\   s    rV   #test_smoothed_state_disturbance_covz1TestClark1989.test_smoothed_state_disturbance_cov   *    %%DD##BBA	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   rB   simulated_staterE   r\   s    rV   test_simulation_smoothed_statez,TestClark1989.test_simulation_smoothed_state   *    !!11//	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   rB   !simulated_measurement_disturbancerE   r\   s    rV   0test_simulation_smoothed_measurement_disturbancez>TestClark1989.test_simulation_smoothed_measurement_disturbance   s*    !!CCAA1	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   rB   simulated_state_disturbancerE   r\   s    rV   *test_simulation_smoothed_state_disturbancez8TestClark1989.test_simulation_smoothed_state_disturbance   *    !!==;;Q	
rX   N)__name__
__module____qualname____doc__classmethodfloatrW   r^   rd   ri   rm   rt   rz   r   r   r   r   r   r   r   r   r   r   r   r    rX   rV   r
   r
      s}    
 $u I
 I
V
"
















rX   r
   c                   .     e Zd Ze fd       Zd Z xZS )TestClark1989Alternatec                 (    t        |   |ddi| y )NrG   TsuperrW   rF   argsrH   	__class__s      rV   rW   z"TestClark1989Alternate.setup_class   s    DCTCFCrX   c                 N    | j                   j                  j                  dk(  sJ y )Nr   )r,   _kalman_filterfilter_timingr\   s    rV   test_using_alteratez*TestClark1989Alternate.test_using_alterate   s     zz((66!;;;rX   )r   r   r   r   rW   r   __classcell__r   s   @rV   r   r      s    D D<rX   r   c                   $   e Zd Zeedfd       Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zej$                  j&                  d        Zej$                  j&                  d        Zd Zd Zd Zej$                  j&                  d        Zd Zy) MultivariateMissingGeneralObsCovFc                 @   t         j                  j                  t        dd      }t	        j
                  |      | _        t        j                  j                         j                  }t	        j                  ddd      |_        |g d   j                         j                  dd  }|d	k(  rGt        j                   |j                  d d
d d f<   t        j                   |j                  ddd d f<   n|dk(  rCt        j                   |j                  dd
df<   t        j                   |j                  dddf<   n|dk(  rt        j                   |j                  dd
df<   t        j                   |j                  dddf<   t        j                   |j                  dddf<   t        j                   |j                  dddf<   t        j                   |j                  dddf<   t#        |fddd|}t        j$                  d      |d<   t        j&                  d      dz   j)                  d      dz  }	t        j*                  |	|	j,                        |d<   t        j$                  d      |d<   t        j$                  d      |d<   t        j$                  d      |d<   |j/                  d       |j0                  | _        d | j2                  _        | j2                  j7                         | _        | j2                  j:                  | j2                  j<                  z   | j2                  j>                  z  }
| j2                  jA                  t        jB                  |
      t        jB                  | j2                  jD                        !      | _#        d | j2                  _$        | j2                  j7                         | _%        | j2                  jA                  t        jB                  |
      t        jB                  | j2                  jD                        !      | _&        y )"Nresults%results_smoothing_generalobscov_R.csv
1959-01-01	2009-7-01r   startendr   realgdprealconsrealinvr   all2   w      partialr   mixed   F   '   Z   r   r   r   r?   r-   ra   )r   r   g      $@r2   r.   r0   r3       .ATr   )'ospathjoincurrent_pathr$   read_csvdesiredr   	macrodataload_pandasr   r'   r   diffilocr(   nanr   r/   arangereshaper7   r8   initialize_approximate_diffuser+   r,   r;   r<   r=   r>   r?   r@   rA   r5   r   rB   rC   rD   rE   )rF   whichr   rG   rH   r   dtaobsmodXrU   s              rV   rW   z,MultivariateMissingGeneralObsCov.setup_class   s(    ww||L)CEkk$'   ,,.33MM&1>	45::<AA!"EE>!vvCHHSbS!V#%66CHHSWaZ i "CHHQrT1W#%66CHHSWaZ g "CHHQrT1W!#CHHRUAX!#CHHRUAX#%66CHHSWaZ #%66CHHSWaZ  s=Q=f=q	HYYq\A&&v.4133IFF1IL66!9K66!9K**3/GG	 )-		%#&99#3#3#5 YY!3!33syy~~E 	  #yy<<!#*@!A#%88CII,>,>#?  =  
 '+		#!$!1!1!3 YY::!#*@!A#%88CII,>,>#? ; 
rX   c                     | j                   j                  rJ | j                  j                  sJ t        | j                   j                  d   d       t        | j                  j                  d   d       y )Nr   gp=.ArZ   r\   s    rV   r^   z6MultivariateMissingGeneralObsCov.test_using_univariate3  sn    
 ,,>>>>&&8888%%99'B	
 	##77@	
rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r`   rb   r\   s    rV   rd   z/MultivariateMissingGeneralObsCov.test_forecastsD  re   rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r`   rg   r\   s    rV   ri   z5MultivariateMissingGeneralObsCov.test_forecasts_errorJ  rj   rX   c                     t        | j                  j                  ddd d f   | j                  j                  ddd d f   d       y r`   rl   r\   s    rV   rm   z9MultivariateMissingGeneralObsCov.test_forecasts_error_covP  rn   rX   c                 n    t        | j                  j                  | j                  j                  d       y rp   rr   r\   s    rV   rt   z4MultivariateMissingGeneralObsCov.test_filtered_stateV  ru   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   rx   r\   s    rV   rz   z8MultivariateMissingGeneralObsCov.test_filtered_state_cov\  r{   rX   c                 n    t        | j                  j                  | j                  j                  d       y rp   r}   r\   s    rV   r   z5MultivariateMissingGeneralObsCov.test_predicted_stateb  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z9MultivariateMissingGeneralObsCov.test_predicted_state_covh  r   rX   c                 l    t        | j                  j                  | j                  j                         y r   r   r\   s    rV   r   z-MultivariateMissingGeneralObsCov.test_logliken  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y r   r   r\   s    rV   r   z5MultivariateMissingGeneralObsCov.test_smoothed_statest  ru   rX   c                 n    t        | j                  j                  | j                  j                  d       y r   r   r\   s    rV   r   z9MultivariateMissingGeneralObsCov.test_smoothed_states_covz  r{   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   zFMultivariateMissingGeneralObsCov.test_smoothed_measurement_disturbance  *    %%FF##DDa	
rX   c                     | j                   }| j                  }t        |j                  j	                         |j                  j	                         d       y rw   r   r   s      rV   r   zJMultivariateMissingGeneralObsCov.test_smoothed_measurement_disturbance_cov  sF    ((&&55>>@55>>@!	
rX   c                 p    t        | j                  j                  | j                  j                  d       y r   r   r\   s    rV   r   z@MultivariateMissingGeneralObsCov.test_smoothed_state_disturbance  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   zDMultivariateMissingGeneralObsCov.test_smoothed_state_disturbance_cov  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z?MultivariateMissingGeneralObsCov.test_simulation_smoothed_state  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   zQMultivariateMissingGeneralObsCov.test_simulation_smoothed_measurement_disturbance  *    !!CCAA1	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   zKMultivariateMissingGeneralObsCov.test_simulation_smoothed_state_disturbance  r   rX   N)r   r   r   r   r   rW   r^   rd   ri   rm   rt   rz   r   r   r   r   r   pytestmarkskipr   r   r   r   r   r   r   r   rX   rV   r   r      s    &+e 5
 5
n
"









 [[
 
 [[
 



 [[
 

rX   r   c                   ,     e Zd ZdZe fd       Z xZS )TestMultivariateGeneralObsCovz
    This class tests the univariate method when the observation covariance
    matrix is not diagonal and all data is available.

    Tests are against the conventional smoother.
    c                 $    t         |   d       y )Nnoner   r   s      rV   rW   z)TestMultivariateGeneralObsCov.setup_class  s    F#rX   r   r   r   r   r   rW   r   r   s   @rV   r  r    s     $ $rX   r  c                   ,     e Zd ZdZe fd       Z xZS )'TestMultivariateAllMissingGeneralObsCovz
    This class tests the univariate method when the observation covariance
    matrix is not diagonal and there are cases of fully missing data only.

    Tests are against the conventional smoother.
    c                 $    t         |   d       y )Nr   r   r   s      rV   rW   z3TestMultivariateAllMissingGeneralObsCov.setup_class  s    E"rX   r  r   s   @rV   r  r    s     # #rX   r  c                   8     e Zd ZdZe fd       Zd Zd Z xZS )+TestMultivariatePartialMissingGeneralObsCovz
    This class tests the univariate method when the observation covariance
    matrix is not diagonal and there are cases of partially missing data only.

    Tests are against the conventional smoother.
    c                 $    t         |   d       y )Nr   r   r   s      rV   rW   z7TestMultivariatePartialMissingGeneralObsCov.setup_class  s    I&rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y Nr   rq   rb   r\   s    rV   rd   z:TestMultivariatePartialMissingGeneralObsCov.test_forecasts  re   rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r#  rg   r\   s    rV   ri   z@TestMultivariatePartialMissingGeneralObsCov.test_forecasts_error  rj   rX   	r   r   r   r   r   rW   rd   ri   r   r   s   @rV   r   r     s&     ' '

rX   r   c                   8     e Zd ZdZe fd       Zd Zd Z xZS ))TestMultivariateMixedMissingGeneralObsCovz
    This class tests the univariate method when the observation covariance
    matrix is not diagonal and there are cases of both partially missing and
    fully missing data.

    Tests are against the conventional smoother.
    c                 $    t         |   d       y )Nr   r   r   s      rV   rW   z5TestMultivariateMixedMissingGeneralObsCov.setup_class  s    G$rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r#  rb   r\   s    rV   rd   z8TestMultivariateMixedMissingGeneralObsCov.test_forecasts  re   rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r#  rg   r\   s    rV   ri   z>TestMultivariateMixedMissingGeneralObsCov.test_forecasts_error  rj   rX   r%  r   s   @rV   r'  r'    s&     % %

rX   r'  c                      e Zd Zedd       Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zej                   j"                  d        Zej                   j"                  d        Zd Zd Zd Zej                   j"                  d        Zd Zy)TestMultivariateVARc                    t         j                  j                  t        dd      }t	        j
                  |      | _        t        j                  j                         j                  }t	        j                  ddd      |_        |g d   j                         j                  dd  }|d	k(  rGt        j                   |j                  d d
d d f<   t        j                   |j                  ddd d f<   n|dk(  rCt        j                   |j                  dd
df<   t        j                   |j                  dddf<   n|dk(  rt        j                   |j                  dd
df<   t        j                   |j                  dddf<   t        j                   |j                  dddf<   t        j                   |j                  dddf<   t        j                   |j                  dddf<   t#        |fddd|}t        j$                  d      |d<   t        j&                  g dg dg dg      |d<   t        j&                  g dg dg dg      |d<   t        j$                  d      |d <   t        j&                  g d!g d"g d#g      |d$<   |j)                  d%       |j*                  | _        d&| j,                  _        | j,                  j1                         | _        | j,                  j4                  | j,                  j6                  z   | j,                  j8                  z  }| j,                  j;                  t        j<                  |      t        j<                  | j,                  j>                        '      | _         d&| j,                  _!        | j,                  j1                         | _"        | j,                  j;                  t        j<                  |      t        j<                  | j,                  j>                        '      | _#        y )(Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r-   )g@        r.  )r.  g=z4
?r.  )r.  r.  g%'Q+_@r2   )g^g
G?g
{vX?)gίE.gXOE@gƹ?)gja?g4CϿg8ur.   r0   )g1=NC@̿Q%@T|l@)r/  g+=}@pqQ@)r0  r1  g0Z$@r3   r   Tr   )$r   r   r   r   r$   r   r   r   r   r   r   r'   r   r   r   r(   r   r   r/   r1   r   r+   r,   r;   r<   r=   r>   r?   r@   rA   r5   r   rB   rC   rD   rE   )rF   r   rH   r   r   r   r   rU   s           rV   rW   zTestMultivariateVAR.setup_class  s7    ww||L)CEkk$'   ,,.33MM&1>	45::<AA!"EE>!vvCHHSbS!V#%66CHHSWaZ i "CHHQrT1W#%66CHHSWaZ g "CHHQrT1W!#CHHRUAX!#CHHRUAX#%66CHHSWaZ #%66CHHSWaZ  s=Q=f=q	H44>#@ AI HH999&; <L 66!9K88A@A%C DK 	**3/GG	 )-		%#&99#3#3#5 YY!3!33syy~~E 	  #yy<<!#*@!A#%88CII,>,>#?  =  
 '+		#!$!1!1!3 YY::!#*@!A#%88CII,>,>#? ; 
rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r`   rb   r\   s    rV   rd   z"TestMultivariateVAR.test_forecasts>  re   rX   c                     t        | j                  j                  dd d f   | j                  j                  dd d f   d       y r`   rg   r\   s    rV   ri   z(TestMultivariateVAR.test_forecasts_errorD  rj   rX   c                     t        | j                  j                  ddd d f   | j                  j                  ddd d f   d       y r`   rl   r\   s    rV   rm   z,TestMultivariateVAR.test_forecasts_error_covJ  rn   rX   c                 n    t        | j                  j                  | j                  j                  d       y rp   rr   r\   s    rV   rt   z'TestMultivariateVAR.test_filtered_stateP  ru   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   rx   r\   s    rV   rz   z+TestMultivariateVAR.test_filtered_state_covV  r{   rX   c                 n    t        | j                  j                  | j                  j                  d       y rp   r}   r\   s    rV   r   z(TestMultivariateVAR.test_predicted_state\  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z,TestMultivariateVAR.test_predicted_state_covb  r   rX   c                 l    t        | j                  j                  | j                  j                         y r   r   r\   s    rV   r   z TestMultivariateVAR.test_loglikeh  r   rX   c                 l    t        | j                  j                  | j                  j                         y r   )r   r=   r   rD   r\   s    rV   r   z(TestMultivariateVAR.test_smoothed_statesn  s(    %%44##22	
rX   c                 p    t        | j                  j                  | j                  j                  d       y )Ng&.>r   )r   r=   r   rD   r\   s    rV   r   z,TestMultivariateVAR.test_smoothed_states_covt  s*    %%88##66T	
rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z9TestMultivariateVAR.test_smoothed_measurement_disturbancez  r  rX   c                     | j                   j                  }| j                  }t        |j                  j                         |j                  j                         d       y rw   )r]   r=   rD   r   r   r   r   s      rV   r   z=TestMultivariateVAR.test_smoothed_measurement_disturbance_cov  sK    yy--&&55>>@55>>@	
rX   c                 p    t        | j                  j                  | j                  j                  d       y r   r   r\   s    rV   r   z3TestMultivariateVAR.test_smoothed_state_disturbance  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z7TestMultivariateVAR.test_smoothed_state_disturbance_cov  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z2TestMultivariateVAR.test_simulation_smoothed_state  r   rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   zDTestMultivariateVAR.test_simulation_smoothed_measurement_disturbance  r  rX   c                 n    t        | j                  j                  | j                  j                  d       y rw   r   r\   s    rV   r   z>TestMultivariateVAR.test_simulation_smoothed_state_disturbance  r   rX   N)r  )r   r   r   r   rW   rd   ri   rm   rt   rz   r   r   r   r   r   r  r  r  r   r   r   r   r   r   r   r   rX   rV   r,  r,    s    =
 =
~









 [[
 
 [[
 



 [[
 

rX   r,  c                     t        j                  g d      } t        j                  d      }d|dd df<   d|ddd f<   t        | dd	      }|j	                  g d
       ||j
                  d<   |j
                  j                         }t        | dd	      }d|j
                  _        |j	                  g d
       ||j
                  d<   |j
                  j                         }|j                  |j                  z   |j                  z  }|j                  t        j                  |      t        j                  |j                              }|j                  t        j                  |      t        j                  |j                              }t        |j                  dd d f   |j                  dd d f          t        |j                   dd d f   |j                   dd d f          t        |j"                  ddd d f   |j"                  ddd d f          t        |j$                  |j$                         t        |j&                  |j&                         t        |j(                  |j(                         t        |j*                  |j*                         t        |j,                  |j,                         t        |j.                  |j.                         t        |j0                  |j0                         t        |j2                  |j2                         t        |j4                  j7                         |j4                  j7                                t        |j8                  |j8                         t        |j:                  |j:                         t        |j<                  |j<                         t        |j>                  |j>                         t        |j@                  |j@                         y )N)
   r         @g      ?rE  r   rD  )r   r   r   g      ?.r   r   )r   r   r   T)ordermeasurement_error)g       @      ?rH  r.   r   r   )!r(   r1   onesr   updater+   r<   rC   r>   r?   r@   rA   r5   r   r   rc   rh   r[   rs   ry   r~   r   r   r   r   r   r   r   r   r   r   r   r   )	endogr.   mod1res1mod2res2rU   sim1sim2s	            rV   test_time_varying_transitionrR    s    HH34E#JJsBQBwJsABw 5	TBDKK'DHH\88??D 5	TBD!%DHHKK'DHH\88??D #llT]]:diiG##XX&<=!xx6 $ 8D ##XX&<=!xx6 $ 8D
 DNN1a4($..A*>?D((A.0D0DQT0JKD,,Q1W5,,Q1W57D'')<)<=D++T-D-DED(($*>*>?D,,d.F.FGDLL$,,/D'')<)<=D++T-D-DED9999;D==FFH==FFHJD33335D77779 D(($*>*>?D::::<D44446rX   ) r   r   numpyr(   numpy.testingr   r   pandasr$   r  statsmodelsr   #statsmodels.tsa.statespace.mlemodelr   (statsmodels.tsa.statespace.tests.resultsr   "statsmodels.tsa.statespace.sarimaxr   r   dirnameabspath__file__r   r
   r   r   r  r  r   r'  r,  rR  r   rX   rV   <module>r]     s    
  >     8 J 6wwrwwx89P
 P
f<] <t
 t
n	$$D 	$
#(
#
(
2
(
4l
 l
^76rX   