How to reproduce the shock decomposition graph?

Hi,
I had taken a lot of time to finish my mod file. But I closed the shock decomposition graphs immediately, then I couldn’t find the graphs in the output file.I have oo_.shock_decomposition data, but I don’t know the matlab code.
So how could I reproduce the shock decomposition graph like I just finished the mod file?
Thanks for your comments.

You could try loading the results file and typing

It may be that you need to set var_list first. It is a character array with the names of the endogenous variables to plot.

Hi Johannes,
I have a similar problem. I run the model estimation with the shock_decomposition function and now I’m trying to tap on the results to reproduce them in Excel. However, I don’t have any idea how the output stored at “oo_.shock_decomposition” is meant to be read. It makes no sense at all to me! Could you teach me how to do so? I copied below part of the txt file output in case it helps. As you can see below, the object’s dimension (26x12x42) doesn’t match exactly the details of my problem: 26 endogenous variables, 10 exogenous shocks and 40 time periods).
Thanks so much.

val(:,:,1) =
Columns 1 through 5
-0.0002 -0.0001 0.0023 -0.0066 0.0000
0.0001 -0.0002 0.0038 0.0018 0.0003
-0.0000 -0.0000 0.0000 -0.0000 0.0000
-0.0013 0 0 0 0
0.0002 -0.0010 -0.0029 0.0048 -0.0149
0.0002 -0.0010 -0.0029 0.0048 -0.0149
0.0001 -0.0013 -0.0026 0.0034 -0.0116
-0.0001 -0.0022 -0.0014 -0.0016 -0.0001
0.0001 -0.0017 -0.0028 0.0036 -0.0120
-0.0000 -0.0000 0.0000 0.0000 0.0000
-0.0000 -0.0120 -0.0044 -0.0009 -0.0003
0 -0.0095 0 0 0
-0.0002 0.0092 0.0022 -0.0057 0.0001
0.0000 0.0024 0.0012 0.0009 0.0001
0.0000 -0.0000 -0.0000 -0.0000 -0.0000
-0.0003 0.0102 0.0025 -0.0087 -0.0001
-0.0003 0.0102 0.0025 -0.0087 -0.0001
-0.0000 -0.0017 -0.0003 -0.0007 -0.0001
-0.0000 -0.0001 0.0000 -0.0001 0.0126
0 0 0 -0.0078 0
0.0000 0.0000 0.0016 -0.0000 0.0000
0 0 0 0 0
0.0000 0.0000 0.0000 0.0000 0.0124
0 0 0 0 0
0.0000 0.0000 0.0000 0.0000 -0.0000
0.0000 -0.0000 0.0000 0.0000 0.0000
Columns 6 through 10
0.0120 0 -0.0001 0.0000 -0.0010
-0.0015 0 -0.0002 0.0000 -0.0016
0.0723 0 -0.0000 -0.0000 -0.0000
0 0 0 0 0
-0.0090 0 -0.0007 0.0002 -0.0048
-0.0090 0 -0.0007 0.0002 -0.0048
-0.0068 0 -0.0003 0.0002 -0.0033
0.0010 0 0.0012 0.0002 0.0020
-0.0073 0 -0.0002 0.0002 -0.0033
0.0018 0 -0.0000 0.0000 -0.0000
-0.0004 0 0.0022 0.0001 0.0019
0 0 0 0 0
0.0106 0 -0.0016 -0.0001 -0.0010
-0.0005 0 -0.0009 -0.0003 -0.0008
0.0000 0 0.0000 0.0000 0.0008
0.0153 0 0.0030 0.0002 -0.0011
0.0153 0 0.0030 0.0002 -0.0011
0.0007 0 0.0038 0.0002 0.0001
0.0003 0 0.0000 0.0000 0.0001
0 0 0 0 0
-0.0000 0 0.0000 -0.0000 -0.0000
0 0 0 0 0
-0.0000 0 -0.0000 -0.0000 -0.0000
-0.0592 0 0 0 0
-0.0000 0 0.0016 0.0000 -0.0000
-0.0000 0 -0.0000 -0.0001 -0.0000
Columns 11 through 12
-0.0090 -0.0029
0.0049 0.0073
-0.0497 0.0226
-0.0007 -0.0021
-0.0329 -0.0610
-0.0329 -0.0610
0.0216 -0.0005
0.0018 0.0008
-0.0287 -0.0520
0.0008 0.0026
-0.0022 -0.0161
-0.0031 -0.0126
-0.0089 0.0046
0.0022 0.0045
0.0016 0.0024
0.0003 0.0212
-0.0018 0.0191
0.0096 0.0115
0.0198 0.0328
-0.0026 -0.0103
0.0012 0.0027
-0.0000 -0.0000
0.0193 0.0317
-0.0073 -0.0665
0.0011 0.0026
0.0000 -0.0001
val(:,:,2) =
Columns 1 through 5
-0.0008 -0.0012 0.0038 -0.0012 -0.0025
0.0003 -0.0013 0.0074 0.0020 0.0006
0.0002 -0.0021 -0.0035 0.0044 -0.0146
-0.0051 0.0000 -0.0000 0.0000 0.0000
0.0007 -0.0026 -0.0069 0.0023 -0.0211
0.0007 -0.0026 -0.0069 0.0023 -0.0211
0.0004 -0.0017 -0.0035 -0.0023 -0.0049
-0.0003 -0.0022 -0.0021 -0.0017 -0.0003
0.0005 -0.0038 -0.0069 0.0014 -0.0173
0.0000 -0.0001 -0.0001 0.0001 -0.0004
-0.0003 -0.0124 -0.0087 -0.0023 -0.0004
-0.0000 -0.0105 0.0000 -0.0000 -0.0000
-0.0007 0.0096 0.0039 -0.0007 -0.0021
0.0002 0.0038 0.0027 0.0015 0.0002
-0.0000 0.0003 0.0003 -0.0003 0.0000
-0.0011 0.0088 0.0036 -0.0024 -0.0034
-0.0011 0.0088 0.0036 -0.0024 -0.0034
-0.0001 -0.0031 -0.0012 -0.0011 -0.0004
-0.0000 -0.0001 -0.0000 -0.0001 0.0194
0.0000 -0.0000 -0.0000 -0.0032 0.0000
0.0000 0.0000 0.0026 -0.0000 0.0000
0 0 0 0 0
0.0000 0.0000 0.0000 0.0000 0.0191
-0.0000 -0.0000 -0.0000 -0.0000 -0.0000
0.0000 0.0000 0.0000 0.0000 -0.0000
0.0000 -0.0000 0.0000 0.0000 0.0000
Columns 6 through 10
0.0049 0 0.0002 0.0002 -0.0043
-0.0025 0 0.0004 0.0002 -0.0056
0.0362 0 -0.0003 0.0003 -0.0041
0.0000 0 0.0000 -0.0000 -0.0000
-0.0096 0 0.0009 0.0015 -0.0149
-0.0096 0 0.0009 0.0015 -0.0149
-0.0001 0 0.0012 0.0012 -0.0065
0.0019 0 -0.0003 0.0011 0.0065
-0.0076 0 0.0010 0.0015 -0.0098
0.0027 0 -0.0000 0.0000 -0.0001
0.0018 0 -0.0000 0.0006 0.0068
0.0000 0 -0.0000 -0.0000 0.0000
0.0042 0 -0.0001 -0.0005 -0.0041
-0.0011 0 -0.0003 -0.0016 -0.0032
0.0006 0 -0.0001 -0.0000 0.0026
0.0065 0 0.0009 0.0016 -0.0048
0.0047 0 0.0009 0.0016 -0.0048
0.0010 0 0.0008 0.0016 0.0006
0.0004 0 0.0000 0.0000 0.0005
0.0000 0 0.0000 -0.0000 -0.0000
-0.0000 0 -0.0000 -0.0000 -0.0000
0 0 0 0 0
-0.0000 0 0.0000 -0.0000 -0.0000
-0.0355 0 0.0000 0.0000 -0.0000
-0.0000 0 -0.0010 0.0000 -0.0000
-0.0000 0 0.0000 -0.0008 -0.0000
Columns 11 through 12
-0.0065 -0.0074
0.0012 0.0026
-0.0315 -0.0149
-0.0004 -0.0056
-0.0162 -0.0657
-0.0162 -0.0657
0.0138 -0.0024
0.0031 0.0058
-0.0150 -0.0561
-0.0000 0.0021
0.0024 -0.0125
-0.0014 -0.0118
-0.0077 0.0019
-0.0002 0.0020
0.0012 0.0046
0.0002 0.0100
-0.0006 0.0074
0.0080 0.0061
0.0107 0.0308
-0.0013 -0.0045
0.0006 0.0032
-0.0000 -0.0000
0.0106 0.0297
-0.0022 -0.0377
0.0004 -0.0006
0.0000 -0.0008
val(:,:,3) =
Columns 1 through 5
0.0004 -0.0026 -0.0012 0.0045 -0.0035
0.0001 -0.0028 0.0007 -0.0000 0.0010
0.0007 -0.0047 -0.0085 0.0018 -0.0215
0.0012 0.0000 -0.0000 0.0000 0.0000
-0.0002 -0.0019 -0.0042 -0.0026 -0.0282
-0.0002 -0.0019 -0.0042 -0.0026 -0.0282
-0.0008 0.0010 0.0023 -0.0039 -0.0057
-0.0001 0.0019 0.0012 -0.0001 -0.0005
-0.0002 -0.0026 -0.0047 -0.0028 -0.0236
0.0000 -0.0002 -0.0003 0.0002 -0.0009
-0.0003 0.0070 -0.0013 -0.0012 -0.0008
-0.0000 0.0037 0.0000 -0.0000 -0.0000
0.0004 -0.0051 -0.0005 0.0044 -0.0029
0.0002 0.0004 0.0012 0.0008 0.0004
-0.0000 0.0007 0.0009 -0.0001 -0.0001
0.0004 -0.0088 -0.0027 0.0050 -0.0049
0.0004 -0.0087 -0.0026 0.0049 -0.0046
-0.0001 -0.0013 -0.0016 -0.0007 -0.0008
-0.0000 -0.0001 -0.0001 0.0000 0.0276
0.0000 -0.0000 -0.0000 0.0042 0.0000
0.0000 0.0000 -0.0003 0.0000 0.0000
0 0 0 0 0
-0.0000 -0.0000 -0.0000 -0.0000 0.0273
-0.0000 0.0000 -0.0000 -0.0000 -0.0000
-0.0000 0.0000 0.0000 -0.0000 -0.0000
-0.0000 -0.0000 -0.0000 -0.0000 0.0000
Columns 6 through 10
0.0048 0 0.0013 0.0010 -0.0024
-0.0028 0 0.0017 0.0010 -0.0004
0.0365 0 0.0012 0.0018 -0.0121
0.0000 0 0.0000 -0.0000 -0.0000
-0.0110 0 0.0037 0.0048 0.0048
-0.0110 0 0.0037 0.0048 0.0048
-0.0007 0 0.0009 0.0033 0.0152
0.0021 0 -0.0062 0.0030 -0.0009
-0.0086 0 0.0015 0.0049 0.0057
0.0035 0 0.0000 0.0001 -0.0004
0.0022 0 -0.0115 0.0015 0.0013
0.0000 0 -0.0000 -0.0000 0.0000
0.0041 0 0.0084 -0.0011 -0.0025
-0.0015 0 0.0043 -0.0048 -0.0015
0.0007 0 -0.0001 -0.0002 -0.0006
0.0064 0 -0.0142 0.0055 -0.0023
0.0037 0 -0.0142 0.0055 -0.0022
0.0013 0 -0.0189 0.0052 0.0008
0.0005 0 -0.0002 0.0000 0.0000
0.0000 0 -0.0000 -0.0000 -0.0000
-0.0000 0 -0.0000 -0.0000 0.0000
0 0 0 0 0
-0.0000 0 0.0000 -0.0000 0.0000
-0.0354 0 -0.0000 0.0000 -0.0000
-0.0000 0 -0.0081 0.0000 0.0000
-0.0000 0 0.0000 -0.0021 0.0000
Columns 11 through 12
-0.0043 -0.0020
-0.0005 -0.0021
-0.0176 -0.0224
-0.0003 0.0009
-0.0057 -0.0404
-0.0057 -0.0404
0.0089 0.0206
0.0032 0.0037
-0.0061 -0.0364
-0.0005 0.0015
0.0041 0.0011
-0.0006 0.0031
-0.0059 -0.0007
-0.0019 -0.0024
0.0007 0.0018
0.0012 -0.0145
0.0012 -0.0167
0.0068 -0.0094
0.0057 0.0336
-0.0007 0.0036
0.0003 0.0000
-0.0000 -0.0000
0.0058 0.0331
-0.0007 -0.0361
0.0001 -0.0080
0.0000 -0.0021
val(:,:,4) =
Columns 1 through 5
0.0012 -0.0023 -0.0087 -0.0027 -0.0048
-0.0004 -0.0028 -0.0126 -0.0002 0.0007
-0.0003 -0.0034 -0.0061 -0.0032 -0.0297
0.0076 0.0000 -0.0000 0.0000 0.0000
-0.0012 -0.0000 0.0058 0.0008 0.0124
-0.0012 -0.0000 0.0058 0.0008 0.0124
-0.0007 0.0018 0.0091 0.0027 0.0316
0.0004 0.0017 0.0059 0.0000 -0.0004
-0.0010 -0.0007 0.0052 0.0001 0.0084
0.0000 -0.0002 -0.0004 0.0001 -0.0016
0.0002 0.0027 0.0142 0.0003 -0.0001
0.0000 -0.0002 0.0000 0.0000 -0.0000
0.0011 -0.0017 -0.0078 -0.0022 -0.0041
-0.0001 -0.0007 -0.0036 0.0004 0.0003
0.0000 0.0006 0.0009 0.0002 -0.0002
0.0015 -0.0030 -0.0107 -0.0040 -0.0064
0.0015 -0.0029 -0.0105 -0.0041 -0.0055
0.0001 -0.0006 -0.0001 -0.0007 -0.0008
0.0000 -0.0001 -0.0001 -0.0001 -0.0041
-0.0000 -0.0000 -0.0000 -0.0021 0.0000
-0.0000 -0.0000 -0.0044 -0.0000 -0.0000
0 0 0 0 0
-0.0000 -0.0000 -0.0000 0.0000 -0.0036
-0.0000 0.0000 0.0000 0.0000 -0.0000
-0.0000 0.0000 -0.0000 0.0000 0.0000
-0.0000 -0.0000 -0.0000 0.0000 -0.0000
Columns 6 through 10
0.0030 0 -0.0001 0.0028 0.0073
-0.0025 0 -0.0007 0.0027 0.0096
0.0258 0 0.0019 0.0061 0.0066
0.0000 0 -0.0000 -0.0000 0.0000
-0.0112 0 -0.0027 0.0054 0.0252
-0.0112 0 -0.0027 0.0054 0.0252
0.0003 0 -0.0056 0.0005 0.0134
0.0019 0 -0.0023 0.0005 -0.0114
-0.0084 0 -0.0043 0.0055 0.0191
0.0041 0 0.0001 0.0002 -0.0002
0.0022 0 -0.0068 -0.0007 -0.0110
0.0000 0 0.0000 -0.0000 -0.0000
0.0025 0 0.0056 0.0006 0.0066
-0.0015 0 0.0042 -0.0034 0.0041
0.0008 0 0.0005 -0.0008 -0.0047
0.0041 0 -0.0125 0.0076 0.0089
0.0006 0 -0.0125 0.0075 0.0093
0.0014 0 -0.0148 0.0049 -0.0002
0.0006 0 -0.0001 0.0000 -0.0006
0.0000 0 -0.0000 -0.0000 0.0000
-0.0000 0 0.0000 -0.0000 0.0000
0 0 0 0 0
-0.0000 0 -0.0000 -0.0000 0.0000
-0.0268 0 -0.0000 0.0000 -0.0000
-0.0000 0 0.0004 0.0000 0.0000
-0.0000 0 -0.0000 -0.0006 0.0000
Columns 11 through 12
-0.0021 -0.0065
-0.0006 -0.0069
-0.0076 -0.0100
-0.0002 0.0074
0.0006 0.0351
0.0006 0.0351
0.0054 0.0587
0.0024 -0.0013
-0.0005 0.0233
-0.0006 0.0012
0.0037 0.0048
-0.0003 -0.0005
-0.0040 -0.0034
-0.0024 -0.0029
0.0002 -0.0025
0.0027 -0.0119
0.0031 -0.0135
0.0058 -0.0050
0.0030 -0.0014
-0.0003 -0.0024
0.0001 -0.0043
-0.0000 -0.0000
0.0032 -0.0004
-0.0002 -0.0270
0.0001 0.0004
0.0000 -0.0006
val(:,:,5) =
Columns 1 through 5
-0.0014 -0.0014 -0.0070 0.0003 0.0019
-0.0000 -0.0019 -0.0134 -0.0007 0.0010
-0.0012 -0.0011 0.0059 0.0001 0.0086
-0.0060 0.0000 0.0000 0.0000 0.0000
0.0009 0.0024 0.0114 -0.0003 -0.0293
0.0009 0.0024 0.0114 -0.0003 -0.0293
0.0016 0.0027 0.0053 -0.0008 -0.0327
-0.0000 0.0037 0.0045 0.0004 -0.0007
0.0007 0.0025 0.0115 -0.0007 -0.0252
-0.0000 -0.0003 -0.0003 0.0001 -0.0014
0.0002 0.0155 0.0158 0.0004 -0.0015
0.0000 0.0104 -0.0000 0.0000 -0.0000
-0.0012 -0.0114 -0.0072 0.0005 0.0018
-0.0000 -0.0038 -0.0058 -0.0000 0.0004
0.0001 0.0003 -0.0002 0.0001 -0.0005
-0.0017 -0.0129 -0.0068 0.0001 0.0019
-0.0018 -0.0127 -0.0063 -0.0000 0.0035
-0.0000 0.0018 0.0021 -0.0004 -0.0008
-0.0000 -0.0000 -0.0000 -0.0000 0.0301
-0.0000 -0.0000 0.0000 0.0007 0.0000
0.0000 -0.0000 -0.0033 0.0000 0.0000
0 0 0 0 0
0.0000 -0.0000 -0.0000 -0.0000 0.0299
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 -0.0000 -0.0000 0.0000 -0.0000
0.0000 0.0000 -0.0000 -0.0000 0.0000
Columns 6 through 10
-0.0066 0 -0.0023 0.0039 0.0117
-0.0008 0 -0.0022 0.0042 0.0121
-0.0336 0 -0.0052 0.0069 0.0231
0.0000 0 -0.0000 -0.0000 0.0000
-0.0046 0 -0.0006 0.0077 0.0195
-0.0046 0 -0.0006 0.0077 0.0195
0.0052 0 0.0007 0.0022 -0.0070
0.0006 0 -0.0043 0.0018 -0.0118
-0.0029 0 -0.0039 0.0078 0.0117
0.0031 0 -0.0001 0.0004 0.0004
0.0018 0 -0.0101 -0.0009 -0.0151
0.0000 0 0.0000 -0.0000 -0.0000
-0.0058 0 0.0077 0.0005 0.0112
-0.0008 0 0.0059 -0.0054 0.0075
0.0007 0 0.0010 -0.0010 -0.0042
-0.0083 0 -0.0239 0.0112 0.0131
-0.0124 0 -0.0240 0.0110 0.0133
0.0008 0 -0.0252 0.0078 -0.0017
0.0004 0 -0.0003 0.0000 -0.0007
0.0000 0 -0.0000 0.0000 0.0000
0.0000 0 0.0000 -0.0000 0.0000
0 0 0 0 0
0.0000 0 0.0000 -0.0000 0.0000
0.0225 0 -0.0000 0.0000 -0.0000
0.0000 0 -0.0056 0.0000 0.0000
0.0000 0 -0.0000 -0.0024 0.0000
Columns 11 through 12
-0.0003 -0.0011
0.0002 -0.0016
-0.0012 0.0023
-0.0001 -0.0060
0.0039 0.0108
0.0039 0.0108
0.0029 -0.0199
0.0013 -0.0043
0.0025 0.0038
-0.0007 0.0013
0.0023 0.0084
-0.0001 0.0103
-0.0021 -0.0060
-0.0022 -0.0044
-0.0003 -0.0039
0.0040 -0.0233
0.0047 -0.0245
0.0049 -0.0107
0.0015 0.0311
-0.0002 0.0005
0.0001 -0.0032
-0.0000 -0.0000
0.0017 0.0316
-0.0001 0.0224
0.0000 -0.0055
0.0000 -0.0024



val(:,:,37) =
Columns 1 through 5
0.0009 0.0019 -0.0057 -0.0019 -0.0014
-0.0001 0.0028 -0.0047 0.0002 0.0006
0.0003 0.0015 -0.0153 0.0013 -0.0109
0.0048 -0.0000 -0.0000 0.0000 -0.0000
-0.0008 -0.0021 -0.0031 0.0021 0.0183
-0.0008 -0.0021 -0.0031 0.0021 0.0183
-0.0008 -0.0019 0.0072 0.0001 0.0259
0.0001 -0.0032 0.0061 -0.0003 -0.0005
-0.0006 -0.0015 -0.0043 0.0015 0.0160
0.0000 0.0004 -0.0015 -0.0002 0.0015
-0.0000 -0.0134 0.0049 -0.0001 -0.0004
-0.0000 -0.0084 0.0000 -0.0000 -0.0000
0.0008 0.0096 -0.0045 -0.0015 -0.0013
-0.0000 0.0024 -0.0029 0.0001 0.0002
-0.0000 -0.0004 0.0022 0.0000 0.0001
0.0012 0.0123 -0.0084 -0.0027 -0.0017
0.0012 0.0119 -0.0073 -0.0025 -0.0036
0.0001 -0.0005 -0.0020 -0.0005 0.0005
0.0000 0.0001 -0.0002 -0.0001 -0.0191
0.0000 0.0000 -0.0000 -0.0022 0.0000
-0.0000 0.0000 0.0000 -0.0000 -0.0000
0 0 0 0 0
-0.0000 0.0000 -0.0000 0.0000 -0.0190
-0.0000 -0.0000 0.0000 0.0000 -0.0000
-0.0000 0.0000 0.0000 0.0000 0.0000
-0.0000 -0.0000 -0.0000 0.0000 0.0000
Columns 6 through 10
0.0017 0 0.0023 -0.0055 0.0047
-0.0017 0 0.0020 -0.0062 0.0061
0.0154 0 0.0059 -0.0096 0.0049
0.0000 0 0.0000 0.0000 0.0000
-0.0069 0 0.0000 -0.0014 0.0086
-0.0069 0 0.0000 -0.0014 0.0086
0.0013 0 -0.0039 0.0059 0.0024
0.0014 0 0.0007 0.0057 -0.0060
-0.0056 0 0.0008 -0.0015 0.0063
0.0019 0 0.0002 -0.0005 0.0002
0.0016 0 0.0016 0.0070 -0.0072
0.0000 0 -0.0000 0.0000 -0.0000
0.0014 0 -0.0010 -0.0048 0.0044
-0.0006 0 -0.0011 -0.0034 0.0033
0.0006 0 -0.0006 0.0015 -0.0021
0.0023 0 0.0095 -0.0072 0.0054
0.0007 0 0.0094 -0.0069 0.0054
0.0007 0 0.0080 -0.0005 -0.0004
0.0003 0 0.0001 -0.0001 -0.0002
0.0000 0 -0.0000 -0.0000 0.0000
-0.0000 0 -0.0000 -0.0000 0.0000
0 0 0 0 0
-0.0000 0 -0.0000 -0.0000 0.0000
-0.0181 0 -0.0000 -0.0000 -0.0000
-0.0000 0 0.0034 0.0000 0.0000
-0.0000 0 -0.0000 -0.0017 0.0000
Columns 11 through 12
0.0001 -0.0029
-0.0000 -0.0011
0.0005 -0.0060
-0.0000 0.0048
0.0007 0.0154
0.0007 0.0154
-0.0000 0.0362
-0.0000 0.0041
0.0001 0.0112
0.0004 0.0025
0.0000 -0.0060
-0.0000 -0.0084
0.0001 0.0032
-0.0000 -0.0020
-0.0000 0.0012
0.0000 0.0108
-0.0003 0.0080
0.0000 0.0054
-0.0000 -0.0191
-0.0000 -0.0022
0.0000 0.0000
-0.0000 -0.0000
0.0000 -0.0190
0.0000 -0.0181
-0.0000 0.0034
0.0000 -0.0017
val(:,:,38) =
Columns 1 through 5
0.0001 0.0003 -0.0100 0.0000 0.0042
-0.0002 0.0010 -0.0145 0.0002 0.0017
-0.0007 -0.0014 -0.0067 0.0016 0.0211
0.0019 -0.0000 -0.0000 0.0000 -0.0000
-0.0005 -0.0044 0.0086 0.0012 -0.0632
-0.0005 -0.0044 0.0086 0.0012 -0.0632
0.0003 -0.0025 0.0110 -0.0008 -0.0639
0.0002 -0.0030 0.0083 -0.0003 -0.0013
-0.0003 -0.0045 0.0076 0.0007 -0.0495
-0.0000 0.0004 -0.0016 -0.0001 0.0020
0.0002 -0.0131 0.0166 -0.0005 -0.0029
0.0000 -0.0091 0.0000 -0.0000 0.0000
0.0001 0.0095 -0.0092 0.0002 0.0041
-0.0001 0.0042 -0.0068 0.0002 0.0011
0.0000 0.0001 0.0013 -0.0001 0.0000
0.0003 0.0096 -0.0119 -0.0003 0.0045
0.0003 0.0091 -0.0104 -0.0002 0.0030
0.0001 -0.0023 0.0001 -0.0005 -0.0004
0.0000 0.0000 -0.0002 -0.0001 0.0475
-0.0000 0.0000 -0.0000 -0.0004 -0.0000
-0.0000 0.0000 -0.0038 -0.0000 0.0000
0 0 0 0 0
0.0000 0.0000 -0.0000 -0.0000 0.0461
-0.0000 -0.0000 0.0000 0.0000 -0.0000
-0.0000 0.0000 -0.0000 0.0000 -0.0000
-0.0000 -0.0000 -0.0000 -0.0000 0.0000
Columns 6 through 10
-0.0063 0 0.0017 -0.0028 0.0067
-0.0009 0 0.0024 -0.0040 0.0085
-0.0319 0 0.0013 -0.0023 0.0078
0.0000 0 0.0000 -0.0000 -0.0000
-0.0011 0 0.0011 0.0040 0.0142
-0.0011 0 0.0011 0.0040 0.0142
0.0047 0 0.0008 0.0053 0.0025
0.0008 0 -0.0003 0.0052 -0.0086
-0.0006 0 0.0017 0.0042 0.0086
0.0011 0 0.0003 -0.0005 0.0004
0.0020 0 0.0006 0.0062 -0.0105
0.0000 0 -0.0000 0.0000 -0.0000
-0.0057 0 -0.0010 -0.0038 0.0066
-0.0006 0 -0.0007 -0.0061 0.0056
0.0006 0 -0.0006 0.0007 -0.0030
-0.0078 0 0.0075 -0.0008 0.0070
-0.0098 0 0.0073 -0.0004 0.0068
0.0004 0 0.0066 0.0031 -0.0014
0.0001 0 0.0001 -0.0000 -0.0005
0.0000 0 0.0000 -0.0000 0.0000
0.0000 0 -0.0000 -0.0000 0.0000
0 0 0 0 0
0.0000 0 0.0000 -0.0000 0.0000
0.0221 0 0.0000 0.0000 -0.0000
0.0000 0 0.0002 0.0000 0.0000
0.0000 0 0.0000 -0.0015 0.0000
Columns 11 through 12
0.0001 -0.0060
-0.0000 -0.0058
0.0004 -0.0108
-0.0000 0.0019
0.0007 -0.0393
0.0007 -0.0393
-0.0000 -0.0425
-0.0000 0.0009
0.0000 -0.0320
0.0004 0.0022
0.0000 -0.0013
-0.0000 -0.0091
0.0001 0.0009
-0.0000 -0.0033
-0.0000 -0.0010
0.0000 0.0081
-0.0003 0.0056
0.0000 0.0058
-0.0000 0.0469
-0.0000 -0.0004
0.0000 -0.0038
-0.0000 -0.0000
0.0000 0.0461
0.0000 0.0221
0.0000 0.0002
-0.0000 -0.0015
val(:,:,39) =
Columns 1 through 5
-0.0003 -0.0018 -0.0037 -0.0030 -0.0097
-0.0000 -0.0013 -0.0085 0.0009 0.0020
-0.0003 -0.0051 0.0077 0.0007 -0.0584
-0.0010 0.0000 0.0000 0.0000 0.0000
0.0000 -0.0052 0.0111 0.0030 -0.0420
0.0000 -0.0052 0.0111 0.0030 -0.0420
0.0004 -0.0009 0.0027 0.0013 0.0164
0.0000 -0.0010 0.0035 -0.0009 -0.0010
0.0001 -0.0056 0.0110 0.0020 -0.0338
-0.0000 0.0003 -0.0014 -0.0001 0.0005
0.0001 -0.0063 0.0103 -0.0007 -0.0012
0.0000 -0.0055 -0.0000 -0.0000 -0.0000
-0.0003 0.0044 -0.0042 -0.0024 -0.0080
-0.0001 0.0035 -0.0063 0.0006 0.0014
0.0000 0.0006 -0.0002 -0.0001 0.0004
-0.0003 0.0022 -0.0026 -0.0042 -0.0136
-0.0002 0.0018 -0.0009 -0.0041 -0.0156
0.0001 -0.0027 0.0019 -0.0007 -0.0014
0.0000 -0.0000 -0.0001 -0.0001 0.0351
0.0000 -0.0000 0.0000 -0.0037 0.0000
0.0000 0.0000 -0.0010 -0.0000 0.0000
0 0 0 0 0
0.0000 0.0000 -0.0000 0.0000 0.0343
-0.0000 -0.0000 0.0000 0.0000 -0.0000
0.0000 0.0000 -0.0000 0.0000 -0.0000
0.0000 -0.0000 -0.0000 0.0000 0.0000
Columns 6 through 10
0.0018 0 0.0023 0.0006 0.0046
-0.0005 0 0.0030 -0.0005 0.0043
0.0117 0 0.0023 0.0046 0.0108
-0.0000 0 0.0000 -0.0000 -0.0000
-0.0034 0 0.0023 0.0069 0.0026
-0.0034 0 0.0023 0.0069 0.0026
-0.0017 0 0.0002 0.0029 -0.0098
0.0002 0 -0.0035 0.0028 -0.0035
-0.0024 0 0.0017 0.0073 -0.0016
0.0014 0 0.0003 -0.0004 0.0006
0.0002 0 -0.0057 0.0028 -0.0062
0.0000 0 -0.0000 -0.0000 -0.0000
0.0016 0 0.0038 -0.0013 0.0050
-0.0004 0 0.0018 -0.0059 0.0047
0.0001 0 -0.0005 -0.0004 -0.0008
0.0023 0 -0.0009 0.0048 0.0040
0.0012 0 -0.0012 0.0053 0.0036
0.0004 0 -0.0044 0.0047 -0.0019
0.0002 0 -0.0000 0.0000 -0.0003
-0.0000 0 0.0000 -0.0000 0.0000
-0.0000 0 -0.0000 -0.0000 0.0000
0 0 0 0 0
-0.0000 0 0.0000 -0.0000 -0.0000
-0.0093 0 -0.0000 0.0000 -0.0000
-0.0000 0 -0.0039 0.0000 0.0000
0.0000 0 0.0000 -0.0011 0.0000
Columns 11 through 12
0.0001 -0.0091
-0.0000 -0.0006
0.0004 -0.0256
-0.0000 -0.0010
0.0007 -0.0239
0.0007 -0.0239
-0.0000 0.0113
-0.0000 -0.0033
0.0000 -0.0212
0.0004 0.0015
0.0000 -0.0065
-0.0000 -0.0055
0.0001 -0.0015
-0.0000 -0.0006
-0.0000 -0.0009
0.0000 -0.0082
-0.0003 -0.0104
0.0000 -0.0039
-0.0000 0.0347
-0.0000 -0.0037
0.0000 -0.0010
-0.0000 -0.0000
0.0000 0.0343
0.0000 -0.0093
0.0000 -0.0039
0 -0.0011
val(:,:,40) =
Columns 1 through 5
-0.0006 -0.0032 -0.0038 0.0070 -0.0065
0.0003 -0.0032 -0.0101 -0.0012 0.0019
0.0001 -0.0066 0.0120 0.0024 -0.0407
-0.0039 0.0000 0.0000 0.0000 0.0000
0.0005 -0.0049 0.0169 -0.0037 -0.0307
0.0005 -0.0049 0.0169 -0.0037 -0.0307
0.0003 0.0003 0.0051 -0.0050 0.0085
-0.0002 -0.0002 0.0026 0.0009 -0.0013
0.0005 -0.0056 0.0170 -0.0033 -0.0259
-0.0000 0.0001 -0.0011 -0.0001 -0.0006
-0.0001 -0.0064 0.0126 -0.0001 -0.0018
-0.0000 -0.0073 -0.0000 -0.0000 -0.0000
-0.0005 0.0049 -0.0048 0.0063 -0.0050
0.0001 0.0029 -0.0063 -0.0003 0.0015
-0.0000 0.0009 -0.0013 -0.0001 0.0000
-0.0007 0.0024 -0.0019 0.0087 -0.0097
-0.0007 0.0021 -0.0005 0.0088 -0.0102
-0.0000 -0.0031 0.0031 0.0000 -0.0020
-0.0000 -0.0001 -0.0001 0.0000 0.0291
0.0000 -0.0000 0.0000 0.0074 0.0000
0.0000 0.0000 -0.0038 0.0000 0.0000
0 0 0 0 0
0.0000 0.0000 -0.0000 -0.0000 0.0287
-0.0000 -0.0000 0.0000 0.0000 -0.0000
0.0000 0.0000 -0.0000 -0.0000 -0.0000
0.0000 -0.0000 -0.0000 -0.0000 0.0000
Columns 6 through 10
-0.0013 0 0.0015 0.0034 0.0013
0.0001 0 0.0017 0.0028 0.0025
-0.0075 0 0.0024 0.0086 -0.0013
0.0000 0 -0.0000 -0.0000 -0.0000
-0.0019 0 -0.0009 0.0080 0.0076
-0.0019 0 -0.0009 0.0080 0.0076
0.0011 0 -0.0030 0.0010 0.0032
-0.0001 0 -0.0023 0.0009 -0.0029
-0.0012 0 -0.0016 0.0085 0.0015
0.0011 0 0.0004 -0.0002 0.0006
0.0001 0 -0.0050 -0.0005 -0.0037
0.0000 0 0.0000 -0.0000 0.0000
-0.0011 0 0.0036 0.0008 0.0020
-0.0001 0 0.0026 -0.0049 0.0037
0.0001 0 -0.0001 -0.0011 -0.0008
-0.0018 0 -0.0030 0.0090 -0.0001
-0.0031 0 -0.0034 0.0094 -0.0007
0.0002 0 -0.0057 0.0057 -0.0019
0.0002 0 -0.0000 0.0000 -0.0005
0.0000 0 -0.0000 0.0000 -0.0000
0.0000 0 0.0000 -0.0000 0.0000
0 0 0 0 0
0.0000 0 -0.0000 -0.0000 0.0000
0.0048 0 -0.0000 0.0000 0.0000
0.0000 0 -0.0007 0.0000 0.0000
0.0000 0 0.0000 -0.0012 0.0000
Columns 11 through 12
0.0001 -0.0022
-0.0000 -0.0053
0.0004 -0.0303
-0.0000 -0.0039
0.0006 -0.0085
0.0006 -0.0085
-0.0000 0.0115
-0.0000 -0.0026
0.0000 -0.0100
0.0004 0.0007
0.0000 -0.0050
-0.0000 -0.0073
0.0001 0.0061
-0.0000 -0.0009
-0.0000 -0.0024
0.0000 0.0029
-0.0004 0.0014
0.0000 -0.0036
-0.0000 0.0286
-0.0000 0.0074
0.0000 -0.0038
-0.0000 -0.0000
0.0000 0.0287
0.0000 0.0048
-0.0000 -0.0007
-0.0000 -0.0012
val(:,:,41) =
Columns 1 through 5
-0.0002 -0.0039 0.0013 0.0018 -0.0051
0.0003 -0.0044 -0.0039 -0.0020 0.0013
0.0006 -0.0068 0.0198 -0.0041 -0.0321
-0.0023 0.0000 0.0000 -0.0000 0.0000
0.0002 -0.0035 0.0154 -0.0020 -0.0118
0.0002 -0.0035 0.0154 -0.0020 -0.0118
-0.0003 0.0014 -0.0016 0.0017 0.0146
-0.0003 0.0015 -0.0016 0.0016 -0.0010
0.0002 -0.0042 0.0160 -0.0017 -0.0115
-0.0000 -0.0001 -0.0005 -0.0002 -0.0013
-0.0003 0.0001 0.0056 0.0019 -0.0013
-0.0000 -0.0032 -0.0000 0.0000 -0.0000
-0.0001 0.0003 -0.0003 0.0014 -0.0039
0.0002 0.0011 -0.0039 -0.0011 0.0013
-0.0000 0.0011 -0.0022 0.0002 -0.0002
-0.0003 -0.0028 0.0048 0.0027 -0.0079
-0.0003 -0.0029 0.0059 0.0027 -0.0073
-0.0001 -0.0023 0.0036 0.0005 -0.0020
-0.0000 -0.0001 0.0000 0.0000 0.0156
0.0000 -0.0000 0.0000 0.0038 0.0000
0.0000 0.0000 -0.0019 0.0000 0.0000
0 0 0 0 0
0.0000 0.0000 -0.0000 -0.0000 0.0157
-0.0000 0.0000 0.0000 0.0000 -0.0000
0.0000 0.0000 -0.0000 -0.0000 -0.0000
0.0000 -0.0000 -0.0000 -0.0000 0.0000
Columns 6 through 10
-0.0002 0 -0.0003 0.0050 0.0006
0.0003 0 0.0000 0.0051 0.0001
-0.0021 0 -0.0016 0.0102 0.0025
-0.0000 0 -0.0000 -0.0000 -0.0000
-0.0020 0 -0.0020 0.0061 0.0062
-0.0020 0 -0.0020 0.0061 0.0062
-0.0002 0 -0.0011 -0.0018 -0.0012
-0.0003 0 -0.0010 -0.0019 -0.0007
-0.0014 0 -0.0028 0.0066 0.0003
0.0011 0 0.0003 0.0001 0.0006
-0.0004 0 -0.0028 -0.0038 -0.0010
0.0000 0 0.0000 -0.0000 0.0000
-0.0001 0 0.0019 0.0028 0.0011
0.0002 0 0.0022 -0.0019 0.0021
0.0001 0 0.0003 -0.0014 -0.0002
-0.0005 0 -0.0050 0.0099 -0.0006
-0.0016 0 -0.0054 0.0101 -0.0012
0.0000 0 -0.0055 0.0044 -0.0014
0.0002 0 -0.0000 0.0000 -0.0005
-0.0000 0 -0.0000 0.0000 -0.0000
0.0000 0 0.0000 -0.0000 0.0000
0 0 0 0 0
0.0000 0 -0.0000 -0.0000 -0.0000
0.0015 0 -0.0000 0.0000 0.0000
-0.0000 0 -0.0003 -0.0000 0.0000
0.0000 0 -0.0000 -0.0003 -0.0000
Columns 11 through 12
0.0000 -0.0009
-0.0000 -0.0030
0.0004 -0.0133
-0.0000 -0.0023
0.0006 0.0072
0.0006 0.0072
-0.0000 0.0115
-0.0000 -0.0037
-0.0000 0.0015
0.0004 0.0004
0.0000 -0.0021
-0.0000 -0.0032
0.0001 0.0033
-0.0000 0.0002
-0.0000 -0.0025
-0.0000 0.0003
-0.0004 -0.0004
0.0000 -0.0028
-0.0000 0.0152
-0.0000 0.0038
0.0000 -0.0019
-0.0000 -0.0000
0.0000 0.0157
0.0000 0.0015
-0.0000 -0.0003
0 -0.0003
val(:,:,42) =
Columns 1 through 5
-0.0001 -0.0036 0.0047 0.0005 -0.0024
0.0003 -0.0044 0.0019 -0.0017 0.0006
0.0002 -0.0052 0.0190 -0.0022 -0.0154
-0.0014 0.0000 0.0000 -0.0000 0.0000
0.0000 -0.0015 0.0110 -0.0006 -0.0018
0.0000 -0.0015 0.0110 -0.0006 -0.0018
-0.0002 0.0020 -0.0044 0.0015 0.0077
-0.0002 0.0021 -0.0044 0.0015 -0.0005
-0.0000 -0.0020 0.0118 -0.0002 -0.0039
0.0000 -0.0002 -0.0000 -0.0002 -0.0017
-0.0003 0.0027 -0.0012 0.0021 -0.0008
-0.0000 -0.0014 -0.0000 0.0000 -0.0000
-0.0000 -0.0015 0.0030 0.0001 -0.0017
0.0002 -0.0004 -0.0006 -0.0014 0.0008
-0.0000 0.0009 -0.0025 0.0002 -0.0003
-0.0002 -0.0038 0.0084 0.0013 -0.0042
-0.0002 -0.0037 0.0089 0.0015 -0.0028
-0.0001 -0.0014 0.0030 0.0009 -0.0018
-0.0000 -0.0001 0.0001 0.0000 0.0082
0.0000 -0.0000 0.0000 0.0019 0.0000
0.0000 0.0000 -0.0009 -0.0000 0.0000
0 0 0 0 0
0.0000 -0.0000 -0.0000 -0.0000 0.0086
-0.0000 0.0000 0.0000 0.0000 -0.0000
0.0000 0.0000 -0.0000 -0.0000 0.0000
0.0000 -0.0000 0.0000 -0.0000 -0.0000
Columns 6 through 10
-0.0000 0 -0.0014 0.0049 -0.0007
0.0003 0 -0.0014 0.0056 -0.0015
-0.0012 0 -0.0031 0.0081 0.0010
-0.0000 0 -0.0000 -0.0000 -0.0000
-0.0022 0 -0.0020 0.0033 0.0064
-0.0022 0 -0.0020 0.0033 0.0064
-0.0002 0 0.0000 -0.0029 0.0003
-0.0004 0 0.0001 -0.0029 0.0007
-0.0017 0 -0.0028 0.0035 0.0007
0.0010 0 0.0002 0.0003 0.0007
-0.0006 0 -0.0007 -0.0052 0.0012
0.0000 0 0.0000 -0.0000 0.0000
0.0001 0 0.0005 0.0034 -0.0002
0.0004 0 0.0013 0.0005 0.0005
0.0001 0 0.0005 -0.0013 0.0001
-0.0004 0 -0.0057 0.0084 -0.0017
-0.0015 0 -0.0060 0.0083 -0.0023
-0.0002 0 -0.0046 0.0028 -0.0008
0.0001 0 -0.0001 0.0000 -0.0005
-0.0000 0 -0.0000 0.0000 -0.0000
0.0000 0 0.0000 -0.0000 0.0000
0 0 0 0 0
0.0000 0 -0.0000 -0.0000 -0.0000
0.0004 0 -0.0000 0.0000 0.0000
-0.0000 0 -0.0001 -0.0000 0.0000
0.0000 0 -0.0000 -0.0001 -0.0000

The field oo_.shock_decomposition is a n_var by nshock+2 by nperiods array. The first nshock columns store the respective shock contributions, column n+1 stores the role of the initial conditions, while column n+2 stores the value of the smoothed variables.
This explains why there are more columns than endogenous variables. Are you sure that you have 40 observations and not 42? If yes, please send me the mod-file and the data for me to check what is going on.

%% To reproduce shock decomposition graphs on the Matlab

% Access the shock decomposition results

shock_decomposition = oo_.shock_decomposition;

% Specify the endogenous variable index and time period

endogenous_variable_index = 1; % Change this to the index of the desired endogenous variable

time_period = 1:120; % Change this to the desired time period

% Extract the contributions of shocks and initial conditions for the specified variable and time period

contributions = squeeze(shock_decomposition(endogenous_variable_index, 1:M_.exo_nbr+1, time_period));

% Get the names of shocks and initial conditions

shock_names = M_.exo_names;

initial_condition_name = ‘Initial Condition’;

% Create a bar plot

figure;

bar(time_period, contributions, ‘stacked’);

legend([shock_names; initial_condition_name], ‘Location’, ‘bestoutside’);

title(['Shock Decomposition for ', M_.endo_names{endogenous_variable_index}]);

xlabel(‘Time Period’);

ylabel(‘Contribution’);

%Note: remember to change ‘datetime’ to ‘numeric double’ before inserting year

%along x-axis