1 | |
---|
2 | Real PutRandomSeed(2143); |
---|
3 | |
---|
4 | ////////////////////////////////////////////////////////////////////////////// |
---|
5 | // Creación de los datos |
---|
6 | |
---|
7 | Date begin = y2010; |
---|
8 | Date end = y2010m12d31; |
---|
9 | |
---|
10 | Serie residuals = SubSer(Gaussian(0, 1, C), begin, end); |
---|
11 | |
---|
12 | Polyn ar = 1 - 0.5*B; // - 0.2*B**2 +0.3*B**3; |
---|
13 | Polyn ma = 1; // - 0.8*B; |
---|
14 | Polyn dif = 1; // - B; |
---|
15 | |
---|
16 | Serie noise0 = SubSer(Gaussian(0, 1, C), begin, end); |
---|
17 | Serie noise = DifEq(ma/(ar*dif), |
---|
18 | SubSer(residuals, Succ(begin, C, Degree(ar)), end), noise0); |
---|
19 | |
---|
20 | Date date = y2010m03; |
---|
21 | Real size = 1; |
---|
22 | Set pulses = For(1, size, Serie(Real d) { |
---|
23 | Date dt = Succ(date, C, d-1); |
---|
24 | Pulse(dt,C) |
---|
25 | }); |
---|
26 | Serie zero1 = 1-SetSum(pulses); |
---|
27 | Serie missing1 = Log(zero1*Exp(1)); |
---|
28 | |
---|
29 | ////////////////////////////////////////////////////////////////////////////// |
---|
30 | // [1] Estimación de omitidos con las interrupciones de Estimate |
---|
31 | |
---|
32 | Serie output1 = noise*missing1; |
---|
33 | |
---|
34 | Set mod1 = ModelDef(output1, 1,0,1,0, |
---|
35 | Polyn dif, SetOfPolyn(ar), SetOfPolyn(ma), |
---|
36 | Copy(Empty), Copy(Empty)); |
---|
37 | Real Show(0, "ALL"); |
---|
38 | Set est1 = Estimate(mod1); |
---|
39 | Real Show(1, "ALL"); |
---|
40 | |
---|
41 | Set results1 = BinGroup("<<", For(1, size, Set (Real d) { |
---|
42 | Date dt = Succ(date, C, d-1); |
---|
43 | Real omit = SerDat(est1[3][4], dt); |
---|
44 | Real resid = SerDat(est1[3][1], dt); |
---|
45 | [[ PutName("Omitido_"<<dt, omit), PutName("Residuo_"<<dt, resid) ]] |
---|
46 | })) << For(Card(est1[4])-Card(Monomes(ar))-Card(Monomes(ma))+3, Card(est1[4]), Real (Real p) { |
---|
47 | Real arima = est1[4][p][4]; |
---|
48 | Text name = est1[4][p][1]<<"_"<<est1[4][p][2]<<"_"<<est1[4][p][3]; |
---|
49 | PutName(name, arima) |
---|
50 | }); |
---|
51 | |
---|
52 | ////////////////////////////////////////////////////////////////////////////// |
---|
53 | // [2] Estimación de omitidos con pulsos |
---|
54 | |
---|
55 | Serie output2 = noise*zero1; |
---|
56 | |
---|
57 | Set mod2 = ModelDef(output2, 1,0,1,0, |
---|
58 | Polyn dif, SetOfPolyn(ar), SetOfPolyn(ma), |
---|
59 | EvalSet(pulses, Set(Serie s) { InputDef(1, -s) }), Copy(Empty)); |
---|
60 | Real Show(0, "ALL"); |
---|
61 | Set est2 = Estimate(mod2); |
---|
62 | Real Show(1, "ALL"); |
---|
63 | |
---|
64 | Set results2 = BinGroup("<<", For(1, size, Set (Real d) { |
---|
65 | Date dt = Succ(date, C, d-1); |
---|
66 | Real omit = SerDat(est2[4][d][4], dt); |
---|
67 | Real resid = SerDat(est2[3][1], dt); |
---|
68 | [[ PutName("Omitido_"<<dt, omit), PutName("Residuo_"<<dt, resid) ]] |
---|
69 | })) << For(Card(est2[4])-Card(Monomes(ar))-Card(Monomes(ma))+3, Card(est2[4]), Real (Real p) { |
---|
70 | Real arima = est2[4][p][4]; |
---|
71 | Text name = est2[4][p][1]<<"_"<<est2[4][p][2]<<"_"<<est2[4][p][3]; |
---|
72 | PutName(name, arima) |
---|
73 | }); |
---|
74 | |
---|
75 | ////////////////////////////////////////////////////////////////////////////// |
---|
76 | // Resumen |
---|
77 | |
---|
78 | Set [[ results1, results2 ]]; |
---|
79 | |
---|
80 | ////////////////////////////////////////////////////////////////////////////// |
---|
81 | |
---|