U
    Ãmœdj  ã                   @   sþ   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 ej e¡¡ZG dd	„ d	ƒZG d
d„ deƒZG dd„ dƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dƒZdd„ ZdS )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                   @   s²   e Zd ZdZeedfdd„ƒZdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)S )*Ú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                 K   sè  t j| _t | jd ¡| _tj| jd tjdddd�ddgd	�d
d … }t |d ¡|d< |d d |d< d}t	|fd|i|—Ž| _
| j
j| _ddddddgddddddgg| jjd d …d d …df< ddddddddg| jjddddddd
dgdd
ddddd
dgddddddddgf< t | jj¡| j_t | jd ¡\
}}}}	}
}}}}}|||g| jjdddgdddgdddgf< ||g| jjddgddgddgf< |
d | jjd< |d |d dd|d |	d g| jjt |¡tj|td�f < t |f¡}t |¡d }|�sJt t | jjd d …d d …df |¡| jjd d …d d …df j¡}nd| j_| j ||¡ d| j_| j ¡ | _| jj| jj  | jj! }| jj"t |¡t | jj¡d�| _#d| j_$| j ¡ | _%| jj"t |¡t | jj¡d�| _&d S )NZstatesÚdataz
1947-01-01z
1995-07-01ÚQS)ÚfreqZGDPZUNEMP)ÚindexÚcolumnsé   éd   é   Úk_statesé   r   é   é   é   Ú
parameters©r   r   r   )ÚdtypeT©Zdisturbance_variatesZinitial_state_variates)'r   Zuc_biÚtrueÚpdZ	DataFrameZtrue_statesÚ
date_rangeÚnpÚlogr   ZmlemodelÚssmÚmodelÚdesignÚ
transitionÚeyer   Ú	selectionÚarrayÚobs_covÚ	state_covZdiag_indicesÚzerosÚintÚdotÚTZtiming_init_filteredZ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   Zsigma_vZsigma_eZsigma_wZsigma_vlZsigma_ecZphi_1Zphi_2Zalpha_1Zalpha_2Zalpha_3Zinitial_stateZinitial_state_covÚn_disturbance_variates© r;   úi/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/tsa/statespace/tests/test_univariate.pyÚsetup_class*   sŽ    ýü
6üþÿÿÿ      ÿ$"     ÿÿÿ þÿþþzTestClark1989.setup_classc                 C   s@   | j jrt‚| jjst‚t| j jd dƒ t| jjd dƒ d S )Nr   gÛ+÷1áa@gEKÐš_*^@©r.   r4   ÚAssertionErrorr5   r   Úforecasts_error_cov©Úselfr;   r;   r<   Útest_using_univariatev   s    
þ
þz#TestClark1989.test_using_univariatec                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S ©Nr   é	   ©r   r.   Ú	forecastsr5   rA   r;   r;   r<   Útest_forecasts‡   s
     þzTestClark1989.test_forecastsc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rD   ©r   r.   Úforecasts_errorr5   rA   r;   r;   r<   Útest_forecasts_error�   s
     þz"TestClark1989.test_forecasts_errorc                 C   s4   t | jjddd d …f | jjddd d …f dƒ d S rD   ©r   r.   r@   r5   rA   r;   r;   r<   Útest_forecasts_error_cov“   s
     þz&TestClark1989.test_forecasts_error_covc                 C   s   t | jj| jjdƒ d S ©Né   ©r   r.   Úfiltered_stater5   rA   r;   r;   r<   Útest_filtered_state™   s
     þz!TestClark1989.test_filtered_statec                 C   s   t | jj| jjdƒ d S ©NrE   ©r   r.   Úfiltered_state_covr5   rA   r;   r;   r<   Útest_filtered_state_covŸ   s
     þz%TestClark1989.test_filtered_state_covc                 C   s   t | jj| jjdƒ d S rN   ©r   r.   Úpredicted_stater5   rA   r;   r;   r<   Útest_predicted_state¥   s
     þz"TestClark1989.test_predicted_statec                 C   s   t | jj| jjdƒ d S rS   ©r   r.   Úpredicted_state_covr5   rA   r;   r;   r<   Útest_predicted_state_cov«   s
     þz&TestClark1989.test_predicted_state_covc                 C   s   t | jj| jjƒ d S ©N©r   r.   Úllf_obsr5   rA   r;   r;   r<   Útest_loglike±   s    þzTestClark1989.test_loglikec                 C   s   t | jj| jjdƒ d S ©Né   ©r   r.   Úsmoothed_stater5   rA   r;   r;   r<   Útest_smoothed_states·   s
     þz"TestClark1989.test_smoothed_statesc                 C   s   t | jj| jjdƒ d S ©Nr   ©r   r.   Úsmoothed_state_covr5   rA   r;   r;   r<   Útest_smoothed_states_cov½   s
     þz&TestClark1989.test_smoothed_states_covc                 C   s   t | jj| jjdƒ d S rS   ©r   r.   Ú smoothed_measurement_disturbancer5   rA   r;   r;   r<   Ú%test_smoothed_measurement_disturbanceÃ   s
     þz3TestClark1989.test_smoothed_measurement_disturbancec                 C   s(   | j }| j}t|j ¡ |j ¡ dƒ d S rS   ©r.   r5   r   Ú$smoothed_measurement_disturbance_covÚdiagonal©rB   ÚconvÚunivr;   r;   r<   Ú)test_smoothed_measurement_disturbance_covÉ   s     þz7TestClark1989.test_smoothed_measurement_disturbance_covc                 C   s   t | jj| jjdd� d S ©NgH¯¼šò×z>©Zatol©r   r.   Úsmoothed_state_disturbancer5   rA   r;   r;   r<   Útest_smoothed_state_disturbanceÑ   s
    ýz-TestClark1989.test_smoothed_state_disturbancec                 C   s   t | jj| jjdƒ d S rS   ©r   r.   Úsmoothed_state_disturbance_covr5   rA   r;   r;   r<   Ú#test_smoothed_state_disturbance_covØ   s
     þz1TestClark1989.test_smoothed_state_disturbance_covc                 C   s   t | jj| jjdƒ d S rS   ©r   r3   Úsimulated_stater6   rA   r;   r;   r<   Útest_simulation_smoothed_stateÞ   s
     þz,TestClark1989.test_simulation_smoothed_statec                 C   s   t | jj| jjdƒ d S rS   ©r   r3   Ú!simulated_measurement_disturbancer6   rA   r;   r;   r<   Ú0test_simulation_smoothed_measurement_disturbanceä   s
     þz>TestClark1989.test_simulation_smoothed_measurement_disturbancec                 C   s   t | jj| jjdƒ d S rS   ©r   r3   Úsimulated_state_disturbancer6   rA   r;   r;   r<   Ú*test_simulation_smoothed_state_disturbanceê   s
     þz8TestClark1989.test_simulation_smoothed_state_disturbanceN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚclassmethodÚfloatr=   rC   rH   rK   rM   rR   rV   rY   r\   r`   re   ri   rl   rs   rx   r{   r~   r�   r„   r;   r;   r;   r<   r      s*   Kr   c                       s(   e Zd Ze‡ fdd„ƒZdd„ Z‡  ZS )ÚTestClark1989Alternatec                    s   t t| ƒj|ddi|—Ž d S )Nr8   T)Úsuperr‹   r=   ©r7   Úargsr9   ©Ú	__class__r;   r<   r=   ò   s
    
ÿÿz"TestClark1989Alternate.setup_classc                 C   s   | j jjdkst‚d S )Nr   )r    Z_kalman_filterZfilter_timingr?   rA   r;   r;   r<   Útest_using_alterate÷   s    z*TestClark1989Alternate.test_using_alterate)r…   r†   r‡   r‰   r=   r‘   Ú__classcell__r;   r;   r�   r<   r‹   ñ   s   r‹   c                   @   sÆ   e Zd Zeedfdd„ƒZdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zejjdd„ ƒZejjdd„ ƒZdd„ Zd d!„ Zd"d#„ Zejjd$d%„ ƒZd&d'„ Zd(S ))Ú MultivariateMissingGeneralObsCovFc                 K   sB  t j tdd¡}t |¡| _tj 	¡ j
}tjdddd�|_|ddd	g  ¡ jd
d … }|dkr�tj|jd d…d d …f< tj|jdd…d d …f< n |dkrÂtj|jdd…df< tj|jdd…df< nn|dk�r0t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 d¡|d< t d¡d
  d¡d }	t |	|	j¡|d< t d¡|d< t d¡|d< t d¡|d < | d!¡ |j| _d"| j_| j ¡ | _| jj| jj | jj }
| jj t !|
¡t !| jj"¡d#�| _#d"| j_$| j ¡ | _%| jj t !|
¡t !| jj"¡d#�| _&d S )$NÚresultsú%results_smoothing_generalobscov_R.csvú
1959-01-01ú	2009-7-01r
   ©ÚstartÚendr   ÚrealgdpÚrealconsÚrealinvr   Úallé2   éw   é‚   Úpartialr   Úmixedé   éF   é'   éZ   r   r   ©r   r0   r!   rE   )r   r   g      $@r&   r"   r$   r'   ç    €„.ATr   )'ÚosÚpathÚjoinÚcurrent_pathr   Úread_csvÚdesiredr   Ú	macrodataÚload_pandasr	   r   r   ÚdiffÚilocr   Únanr   r#   ZarangeZreshaper*   r+   Úinitialize_approximate_diffuser   r    r,   r-   r.   r/   r0   r1   r2   r(   r   r3   r4   r5   r6   )r7   Úwhichr   r8   r9   r«   ÚdtaÚobsÚmodÚXr:   r;   r;   r<   r=   ü   sZ    
ÿ ÿ

ÿþþz,MultivariateMissingGeneralObsCov.setup_classc                 C   s@   | j jrt‚| jjst‚t| j jd dƒ t| jjd dƒ d S )Nr   g¤p=Š�„.Ar>   rA   r;   r;   r<   rC   4  s    
þ
þz6MultivariateMissingGeneralObsCov.test_using_univariatec                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rD   rF   rA   r;   r;   r<   rH   E  s
     þz/MultivariateMissingGeneralObsCov.test_forecastsc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rD   rI   rA   r;   r;   r<   rK   K  s
     þz5MultivariateMissingGeneralObsCov.test_forecasts_errorc                 C   s4   t | jjddd d …f | jjddd d …f dƒ d S rD   rL   rA   r;   r;   r<   rM   Q  s
     þz9MultivariateMissingGeneralObsCov.test_forecasts_error_covc                 C   s   t | jj| jjdƒ d S rN   rP   rA   r;   r;   r<   rR   W  s
     þz4MultivariateMissingGeneralObsCov.test_filtered_statec                 C   s   t | jj| jjdƒ d S rS   rT   rA   r;   r;   r<   rV   ]  s
     þz8MultivariateMissingGeneralObsCov.test_filtered_state_covc                 C   s   t | jj| jjdƒ d S rN   rW   rA   r;   r;   r<   rY   c  s
     þz5MultivariateMissingGeneralObsCov.test_predicted_statec                 C   s   t | jj| jjdƒ d S rS   rZ   rA   r;   r;   r<   r\   i  s
     þz9MultivariateMissingGeneralObsCov.test_predicted_state_covc                 C   s   t | jj| jjƒ d S r]   r^   rA   r;   r;   r<   r`   o  s    þz-MultivariateMissingGeneralObsCov.test_loglikec                 C   s   t | jj| jjdƒ d S ra   rc   rA   r;   r;   r<   re   u  s
     þz5MultivariateMissingGeneralObsCov.test_smoothed_statesc                 C   s   t | jj| jjdƒ d S rf   rg   rA   r;   r;   r<   ri   {  s
     þz9MultivariateMissingGeneralObsCov.test_smoothed_states_covc                 C   s   t | jj| jjdƒ d S rS   rj   rA   r;   r;   r<   rl   �  s
     þzFMultivariateMissingGeneralObsCov.test_smoothed_measurement_disturbancec                 C   s(   | j }| j}t|j ¡ |j ¡ dƒ d S rS   rm   rp   r;   r;   r<   rs   ˆ  s     þzJMultivariateMissingGeneralObsCov.test_smoothed_measurement_disturbance_covc                 C   s   t | jj| jjdd� d S rt   rv   rA   r;   r;   r<   rx   ‘  s
    ýz@MultivariateMissingGeneralObsCov.test_smoothed_state_disturbancec                 C   s   t | jj| jjdƒ d S rS   ry   rA   r;   r;   r<   r{   ˜  s
     þzDMultivariateMissingGeneralObsCov.test_smoothed_state_disturbance_covc                 C   s   t | jj| jjdƒ d S rS   r|   rA   r;   r;   r<   r~   ž  s
     þz?MultivariateMissingGeneralObsCov.test_simulation_smoothed_statec                 C   s   t | jj| jjdƒ d S rS   r   rA   r;   r;   r<   r�   ¤  s
     þzQMultivariateMissingGeneralObsCov.test_simulation_smoothed_measurement_disturbancec                 C   s   t | jj| jjdƒ d S rS   r‚   rA   r;   r;   r<   r„   «  s
     þzKMultivariateMissingGeneralObsCov.test_simulation_smoothed_state_disturbanceN)r…   r†   r‡   r‰   rŠ   r=   rC   rH   rK   rM   rR   rV   rY   r\   r`   re   ri   ÚpytestÚmarkÚskiprl   rs   rx   r{   r~   r�   r„   r;   r;   r;   r<   r“   û   s.   7


r“   c                       s$   e Zd ZdZe‡ fdd„ƒZ‡  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                    s   t t| ƒ d¡ d S )NÚnone)rŒ   r¾   r=   r�   r�   r;   r<   r=   ¹  s    z)TestMultivariateGeneralObsCov.setup_class©r…   r†   r‡   rˆ   r‰   r=   r’   r;   r;   r�   r<   r¾   ²  s   r¾   c                       s$   e Zd ZdZe‡ fdd„ƒZ‡  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                    s   t t| ƒ d¡ d S )Nrž   )rŒ   rÁ   r=   r�   r�   r;   r<   r=   Æ  s    z3TestMultivariateAllMissingGeneralObsCov.setup_classrÀ   r;   r;   r�   r<   rÁ   ¾  s   rÁ   c                       s4   e Zd ZdZe‡ fdd„ƒZdd„ Zdd„ Z‡  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                    s   t t| ƒ d¡ d S )Nr¢   )rŒ   rÂ   r=   r�   r�   r;   r<   r=   Ó  s
    ÿÿz7TestMultivariatePartialMissingGeneralObsCov.setup_classc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S ©Nr   rO   rF   rA   r;   r;   r<   rH   Ø  s
     þz:TestMultivariatePartialMissingGeneralObsCov.test_forecastsc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rÃ   rI   rA   r;   r;   r<   rK   Þ  s
     þz@TestMultivariatePartialMissingGeneralObsCov.test_forecasts_error©	r…   r†   r‡   rˆ   r‰   r=   rH   rK   r’   r;   r;   r�   r<   rÂ   Ë  s
   rÂ   c                       s4   e Zd ZdZe‡ fdd„ƒZdd„ Zdd„ Z‡  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                    s   t t| ƒ d¡ d S )Nr£   )rŒ   rÅ   r=   r�   r�   r;   r<   r=   î  s
    ÿÿz5TestMultivariateMixedMissingGeneralObsCov.setup_classc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rÃ   rF   rA   r;   r;   r<   rH   ó  s
     þz8TestMultivariateMixedMissingGeneralObsCov.test_forecastsc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rÃ   rI   rA   r;   r;   r<   rK   ù  s
     þz>TestMultivariateMixedMissingGeneralObsCov.test_forecasts_errorrÄ   r;   r;   r�   r<   rÅ   å  s
   rÅ   c                   @   sº   e Zd Zed'dd„ƒZdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zejjdd„ ƒZejjdd„ ƒZdd„ Zdd„ Zd d!„ Zejjd"d#„ ƒZd$d%„ Zd&S )(ÚTestMultivariateVARr¿   c                 K   sn  t j tdd¡}t |¡| _tj 	¡ j
}tjdddd�|_|ddd	g  ¡ jd
d … }|dkr�tj|jd d…d d …f< tj|jdd…d d …f< n |dkrÂtj|jdd…df< tj|jdd…df< nn|dk�r0t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 d¡|d< t dddgdddgdddgg¡|d< t dd d!gd"d#d$gd%d&d'gg¡|d(< t d¡|d)< t d*d+d,gd+d-d.gd,d.d/gg¡|d0< | d1¡ |j| _d2| j_| j ¡ | _| jj| jj | jj }| jjt |¡t | jj¡d3�| _ d2| j_!| j ¡ | _"| jjt |¡t | jj¡d3�| _#d S )4Nr”   r•   r–   r—   r
   r˜   r›   rœ   r�   r   rž   rŸ   r    r¡   r¢   r   r£   r¤   r¥   r¦   r§   r   r   r¨   r!   gßÙé˜ƒ@g        g=–z²4
þ?g%'Q+_@r&   g ‘^�ôé¿g
GéùÎü?g
ó{³vXð?gÎ¯ÜE.Áÿ¿gXOÂæE@gœÆ¹÷·Òþ?gí™j�aí?g„û®4CÏ¿g¹£8†uä¿r"   r$   g1=NçC˜@gÌ¿Qƒ¿%ƒ@gT|Þþìl‹@gö+¯©û=}@gpqê¦Q@g˜¢æ0Z$Œ@r'   r©   Tr   )$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/   r0   r1   r2   r(   r   r3   r4   r5   r6   )r7   r¶   r9   r«   r·   r¸   r¹   r:   r;   r;   r<   r=     sp    
ÿ ÿ
ý
ý
ý

ÿþþzTestMultivariateVAR.setup_classc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rD   rF   rA   r;   r;   r<   rH   A  s
     þz"TestMultivariateVAR.test_forecastsc                 C   s0   t | jjdd d …f | jjdd d …f dƒ d S rD   rI   rA   r;   r;   r<   rK   G  s
     þz(TestMultivariateVAR.test_forecasts_errorc                 C   s4   t | jjddd d …f | jjddd d …f dƒ d S rD   rL   rA   r;   r;   r<   rM   M  s
     þz,TestMultivariateVAR.test_forecasts_error_covc                 C   s   t | jj| jjdƒ d S rN   rP   rA   r;   r;   r<   rR   S  s
     þz'TestMultivariateVAR.test_filtered_statec                 C   s   t | jj| jjdƒ d S rS   rT   rA   r;   r;   r<   rV   Y  s
     þz+TestMultivariateVAR.test_filtered_state_covc                 C   s   t | jj| jjdƒ d S rN   rW   rA   r;   r;   r<   rY   _  s
     þz(TestMultivariateVAR.test_predicted_statec                 C   s   t | jj| jjdƒ d S rS   rZ   rA   r;   r;   r<   r\   e  s
     þz,TestMultivariateVAR.test_predicted_state_covc                 C   s   t | jj| jjƒ d S r]   r^   rA   r;   r;   r<   r`   k  s    þz TestMultivariateVAR.test_loglikec                 C   s   t | jj| jjƒ d S r]   )r   r.   rd   r5   rA   r;   r;   r<   re   q  s    þz(TestMultivariateVAR.test_smoothed_statesc                 C   s   t | jj| jjdd� d S )Ng•Ö&è.>ru   )r   r.   rh   r5   rA   r;   r;   r<   ri   w  s
     þz,TestMultivariateVAR.test_smoothed_states_covc                 C   s   t | jj| jjdƒ d S rS   rj   rA   r;   r;   r<   rl   }  s
     þz9TestMultivariateVAR.test_smoothed_measurement_disturbancec                 C   s*   | j j}| j}t|j ¡ |j ¡ dƒ d S rS   )rB   r.   r5   r   rn   ro   rp   r;   r;   r<   rs   „  s    ýz=TestMultivariateVAR.test_smoothed_measurement_disturbance_covc                 C   s   t | jj| jjdd� d S rt   rv   rA   r;   r;   r<   rx   Ž  s
    ýz3TestMultivariateVAR.test_smoothed_state_disturbancec                 C   s   t | jj| jjdƒ d S rS   ry   rA   r;   r;   r<   r{   •  s
     þz7TestMultivariateVAR.test_smoothed_state_disturbance_covc                 C   s   t | jj| jjdƒ d S rS   r|   rA   r;   r;   r<   r~   ›  s
     þz2TestMultivariateVAR.test_simulation_smoothed_statec                 C   s   t | jj| jjdƒ d S rS   r   rA   r;   r;   r<   r�   ¡  s
     þzDTestMultivariateVAR.test_simulation_smoothed_measurement_disturbancec                 C   s   t | jj| jjdƒ d S rS   r‚   rA   r;   r;   r<   r„   ¨  s
     þz>TestMultivariateVAR.test_simulation_smoothed_state_disturbanceN)r¿   )r…   r†   r‡   r‰   r=   rH   rK   rM   rR   rV   rY   r\   r`   re   ri   r»   r¼   r½   rl   rs   rx   r{   r~   r�   r„   r;   r;   r;   r<   rÆ      s,   ?

	
rÆ   c            	   	   C   s>  t  dddddddg¡} t  d¡}d|dd d…f< d|ddd …f< t| d	d
d�}| dddg¡ ||jd< |j ¡ }t| d	d
d�}d
|j_| dddg¡ ||jd< |j ¡ }|j|j	 |j
 }|jt  |¡t  |j¡d�}|jt  |¡t  |j¡d�}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|j|jƒ t|j|jƒ t|j ¡ |j ¡ ƒ t|j|jƒ t|j|jƒ t|j|jƒ t|j|jƒ t|j |j ƒ d S )Né
   r   g      @g      ô?)r   r   rb   g      à?.r   )r   r   r   T)ÚorderZmeasurement_errorg       @g      ð?r"   r   r   )!r   r%   Zonesr   Úupdater   r-   r4   r/   r0   r1   r2   r(   r   r   rG   rJ   r@   rQ   rU   rX   r[   r_   rd   rh   rk   rn   ro   rw   rz   r}   r€   rƒ   )	Zendogr"   Zmod1Zres1Zmod2Zres2r:   Zsim1Zsim2r;   r;   r<   Útest_time_varying_transition¯  sj    





þ
þ&&ÿÿ
ÿÿÿÿÿrÊ   ) rˆ   rª   Únumpyr   Znumpy.testingr   r   Zpandasr   r»   Zstatsmodelsr   Z#statsmodels.tsa.statespace.mlemodelr   Z(statsmodels.tsa.statespace.tests.resultsr   Z"statsmodels.tsa.statespace.sarimaxr   r«   ÚdirnameÚabspathÚ__file__r­   r   r‹   r“   r¾   rÁ   rÂ   rÅ   rÆ   rÊ   r;   r;   r;   r<   Ú<module>   s8    T
 8
ÿ
ÿ
ÿ 0