<jupyter_start><jupyter_text>__Draw the IRF result output from RATS package *FAVAR_TWO_STEPS_LYX*__by *<NAME>*   __Copyright Notice__  AUTHOR:- *<NAME>*- *Prof. [<NAME>](http://sf.cufe.edu.cn/info/1112/10555.htm)'s workshop, School of Finance,Central University of Finance and Economics* (CUFE) CONTACT:- Remaining errors are mine.- For corrections about the code,  please mail me at: [<EMAIL>](<EMAIL>) or [<EMAIL>](<EMAIL>)   ATTENTION:  - The copyright belongs to *<NAME>*, 2021/08/11.- *Enjoy! (...and extend/modify)*  __Preparation__ Import libraries<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
import pandas as pd<jupyter_output><empty_output><jupyter_text>Filt warning<jupyter_code>warnings.filterwarnings("ignore")<jupyter_output><empty_output><jupyter_text>Set scheme of graph<jupyter_code>%matplotlib inline
sns.set_style("whitegrid")
plt.rcParams['font.sans-serif'] = 'Times New Roman'<jupyter_output><empty_output><jupyter_text>Set working directory<jupyter_code>cd C:\Users\Lenovo\Desktop\new<jupyter_output>C:\Users\Lenovo\Desktop\new<jupyter_text>__Input files__ Load IRF result file<jupyter_code>df = pd.read_excel('IRF_FAVAR.xlsx')
df<jupyter_output><empty_output><jupyter_text>Load names of response variables<jupyter_code>names = pd.read_excel("names.xlsx")
names
names_ls = list(names.names)
names_ls<jupyter_output><empty_output><jupyter_text>__Draw IRF__  Generate time array<jupyter_code>horizon = np.arange(0, df.shape[0])
horizon<jupyter_output><empty_output><jupyter_text>TestResponse of FFR to MP shock<jupyter_code>plt.figure(figsize=(8, 8))
#  Draw the horizontal line y=0
plt.axhline(0, color="#FF6464",linestyle='dashed', lw=1)

#  Draw median value of IRF
plt.plot(horizon, 
         df['TOTAL_RESULT(1)'],
         color="#17486E", 
         lw=4.5,
         label='Median')

#  Draw upper and lower bound of IRF
plt.fill_between(horizon,
                 df['TOTAL_RESULT(2)'],
                 df['TOTAL_RESULT(3)'],
                 alpha=0.15, color="royalblue",
                label='90% CI')

plt.legend(loc='upper right', fontsize=18)
plt.yticks(fontsize=15)
plt.xticks(fontsize=15)
plt.show()<jupyter_output><empty_output><jupyter_text>Define a function to draw each IRF subgraph<jupyter_code>def sub_IRF(x_,legend=False):
    
    #  Draw the horizontal line y=0
    plt.axhline(0, color="#FF6464",linestyle='dashed', lw=1.6)
    
    #  Draw median value of IRF
    plt.plot(horizon, 
         df['TOTAL_RESULT({})'.format(3*(x_-1)+1)],
         color="#17486E",
         lw=4.5,
         label='Median')
    
    #  Draw median value of IRF
    plt.fill_between(horizon,
                     df['TOTAL_RESULT({})'.format(3*(x_-1)+2)],
                     df['TOTAL_RESULT({})'.format(3*(x_-1)+3)],
                     alpha=0.2, color="royalblue",
                     label='90% CI')
    if legend:
        plt.legend(loc='upper right', fontsize=26)
        
    plt.title(names_ls[x_ - 1], fontsize=20)
    plt.yticks(fontsize=15)
    plt.xticks(fontsize=15)<jupyter_output><empty_output><jupyter_text>Draw and save figureIRF of FFR and other 19 Macroeconomic variables in __*xdata.xlsx*__ to MP schock<jupyter_code>plt.figure(figsize=(30, 24))
for i_ in range(1, len(names_ls) + 1):
    plt.subplot(4,5,i_)
    if i_ != 1:
        sub_IRF(i_)
    else:
        sub_IRF(i_, legend=True)
        
plt.savefig('Impluse response of FFR and other 19 Macroeconomic variables to MP schock.svg',
           dpi=900)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13638920134983126, 'fraction_numerical': 0.028683914510686165, 'mean_word_length': 4.066951566951567, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '541111', 'license': 'BSD-4-Clause-UC', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1294, 'n_words': 245, 'path': 'Draw IRF.ipynb', 'repo_name': 'lyx66/Factor-augmented-vector-autoregressive-FAVAR-WINRATS-code-package-', 'size': '3632'}