Debian Codegraph @

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

raw
1 function a = clmonq(q)
2 % function a = monq(q)
3 % Find the monthly AR coefficient for interpolated data given
4 % an estimate of the quarterly AR coefficient
5 % Written by E.M. Leeper
6 %
7 %
8 % Copyright (C) 1997-2012 Eric Leeper and Tao Zha
9 %
10 % This free software: you can redistribute it and/or modify
11 % it under the terms of the GNU General Public License as published by
12 % the Free Software Foundation, either version 3 of the License, or
13 % (at your option) any later version.
14 %
15 % It is distributed in the hope that it will be useful,
16 % but WITHOUT ANY WARRANTY; without even the implied warranty of
17 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 % GNU General Public License for more details.
19 %
20 % If you did not received a copy of the GNU General Public License
21 % with this software, see <http://www.gnu.org/licenses/>.
22 %
23 % First take the quarterly AR coefficient, q, and then
24 % seek the root, a, that solves
25 % q = (a^5 + 2 a^4 + 3 a^3 + 2 a^2 + a) / (2 a^2 + 4 a + 3) (1)
26
27 % if n = numerator poly and d = denominator poly in (1)
28 n = [1 2 3 2 1 0];
29 d = [2 4 3];
30 ln = length(n);
31 ld = length(d);
32 pad = ln - ld;
33 dd = [zeros(1,pad) d];
34 qdd = q.*dd;
35 newpol = n - qdd;
36 r = roots(newpol);
37 for i = 1:length(r)
38 if imag(r(i)) == 0
39 a = r(i);
40 end
41 end