Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/pdfforg.m

raw
1 function [imfpdf,imfpo,imfprob] = pdfforg(imfcnt,imndraws,forep,nvar,ninv,invc,Am)
2 % [imfpdf,imfpo,imfprob] = pdfforg(imfcnt,imndraws,forep,nvar,ninv,invc,Am)
3 %
4 % Produce the dataset for generating p.d.f. and export the dataset for
5 % probability (NOT density) at each bin
6 %
7 % imfcnt: 2+ninv-by-forep*nvar. Counted logcnt, yhatqgcnt, or yhatCalygcnt.
8 % In the case of impulse responses, forep=imstp and nvar=nvar^2
9 % ninv: the number of small interior intervals for sorting.
10 % invc: 1-by-forep*nvar. Whole inverval lenghth from min to max for one of
11 % (yhat, yhatqg, or yhatCalyg)
12 % Am: 1-by-forep*nvar. Range5{i}(:,:,1) is lowest range for for one of
13 % (yhat, yhatqg, or yhatCalyg)
14 %-----------------
15 % imfpdf: 2+ninv-by-forep*nvar. Density
16 % imfpo: 2+ninv-by-forep*nvar. Bin position (x-axis) in relation to imfs3
17 % imfprob: 2+ninv-by-forep*nvar. Probability (NOT density) at each bin
18 %
19 % 27 August 1998 Tao Zha
20 % Revised, October 1998
21 %
22 % Copyright (C) 1997-2012 Tao Zha
23 %
24 % This free software: you can redistribute it and/or modify
25 % it under the terms of the GNU General Public License as published by
26 % the Free Software Foundation, either version 3 of the License, or
27 % (at your option) any later version.
28 %
29 % It is distributed in the hope that it will be useful,
30 % but WITHOUT ANY WARRANTY; without even the implied warranty of
31 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 % GNU General Public License for more details.
33 %
34 % If you did not received a copy of the GNU General Public License
35 % with this software, see <http://www.gnu.org/licenses/>.
36 %
37
38 invlength = invc ./ ninv;
39 invlengthM = repmat(invlength,[2+ninv,1]);
40 invlengthM([1 2+ninv],:) = 1;
41 % first (-inf, low bound) and last (high bound, +inf), the interval is set
42 % to be 1. Of course, theoretically, the interval length should be set
43 % to infinity, but 1 is large enough compared with invlength.
44 imfprob = imfcnt ./ imndraws; % probability (NOT density)
45 imfpdf = imfprob ./ invlengthM; % density
46
47 imfpo = [1:2+ninv]'; % positions for each forecast
48 imfpo = imfpo - 2; % the first step to put back to original form
49 imfpo = repmat(imfpo,[1,forep*nvar]);
50 invcM = repmat(invc,[2+ninv,1]);
51 AmM = repmat(Am,[2+ninv,1]);
52 imfpo = ((imfpo .* invcM) ./ ninv) + AmM; % 2+ninv-by-forep*nvar
53 % the final step to put back to original form of impulse responses