close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Ticket #899: MissingEstimation.tol

File MissingEstimation.tol, 2.6 KB (added by Pedro Gea, 15 years ago)
Line 
1
2Real PutRandomSeed(2143);
3
4//////////////////////////////////////////////////////////////////////////////
5// Creación de los datos
6
7Date begin = y2010;
8Date end = y2010m12d31;
9
10Serie residuals = SubSer(Gaussian(0, 1, C), begin, end);
11
12Polyn ar = 1 - 0.5*B; // - 0.2*B**2 +0.3*B**3;
13Polyn ma = 1; // - 0.8*B;
14Polyn dif = 1; // - B;
15
16Serie noise0 = SubSer(Gaussian(0, 1, C), begin, end);
17Serie noise = DifEq(ma/(ar*dif),
18  SubSer(residuals, Succ(begin, C, Degree(ar)), end), noise0);
19
20Date date = y2010m03;
21Real size = 1;
22Set pulses = For(1, size, Serie(Real d) {
23  Date dt = Succ(date, C, d-1);
24  Pulse(dt,C)
25});
26Serie zero1 = 1-SetSum(pulses);
27Serie missing1 = Log(zero1*Exp(1));
28
29//////////////////////////////////////////////////////////////////////////////
30// [1] Estimación de omitidos con las interrupciones de Estimate
31
32Serie output1 = noise*missing1;
33
34Set mod1 = ModelDef(output1, 1,0,1,0,
35  Polyn dif, SetOfPolyn(ar), SetOfPolyn(ma),
36  Copy(Empty), Copy(Empty));
37Real Show(0, "ALL");
38Set est1 = Estimate(mod1);
39Real Show(1, "ALL");
40
41Set 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
55Serie output2 = noise*zero1;
56
57Set 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));
60Real Show(0, "ALL");
61Set est2 = Estimate(mod2);
62Real Show(1, "ALL");
63
64Set 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
78Set [[ results1, results2 ]];
79
80//////////////////////////////////////////////////////////////////////////////
81