| 1 | Set Include( "serie.oza" ); |
|---|
| 2 | |
|---|
| 3 | Date MMC_DefIni = y2005m01d01; |
|---|
| 4 | Date MMC_DefEnd = y2013m01d01; |
|---|
| 5 | |
|---|
| 6 | NameBlock nb = [[ |
|---|
| 7 | Serie _.serie = CliTotEst.SPFRes.Base.Sem.Disct.Log.53; |
|---|
| 8 | Text _.arima = "P1_52DIF0_0AR0_0MA1.2_52"; |
|---|
| 9 | Date _.iniEst = y2008m01d28; |
|---|
| 10 | Date _.endEst = y2011m04d25; |
|---|
| 11 | Set _.linearInput = SetOfAnything( |
|---|
| 12 | @InputDef(0.1,Serie ((1-B)*(1-B^52)):(SubSer(Pulse(y2008m01d07, Semanal),MMC_DefIni,MMC_DefEnd))) |
|---|
| 13 | ); |
|---|
| 14 | Set _.transformation = SetOfReal(1,0) |
|---|
| 15 | ]]; |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | //serie a modelar |
|---|
| 19 | Serie ser = If( |
|---|
| 20 | ObjectExist("Serie","nb::_.serie"), |
|---|
| 21 | nb::_.serie, |
|---|
| 22 | { |
|---|
| 23 | WriteLn( |
|---|
| 24 | "AVISO: función MMC_Est.ExecEstFromModelEst, no se ha" + NL + |
|---|
| 25 | " defindo en objeto _.serie en el NameBlock nb " + NL + |
|---|
| 26 | " serie creada vacia. " |
|---|
| 27 | ); |
|---|
| 28 | Serie SubSer(CalInd(W,C),MMC_DefIni, MMC_DefEnd) |
|---|
| 29 | } |
|---|
| 30 | ); |
|---|
| 31 | |
|---|
| 32 | //arima |
|---|
| 33 | Text arima = If( |
|---|
| 34 | ObjectExist("Text","nb::_.arima"), |
|---|
| 35 | nb::_.arima, |
|---|
| 36 | { |
|---|
| 37 | WriteLn( |
|---|
| 38 | "AVISO: función MMC_Est.ExecEstFromModelEst, no se ha" + NL + |
|---|
| 39 | " defindo en objeto _.arima en el NameBlock nb " + NL + |
|---|
| 40 | " etiqueta creada como P0DIF0AR0MA0. " |
|---|
| 41 | |
|---|
| 42 | ); |
|---|
| 43 | "P0DIF0AR0MA0" |
|---|
| 44 | } |
|---|
| 45 | ); |
|---|
| 46 | |
|---|
| 47 | //conjunto de inputs |
|---|
| 48 | Set linearInput = If( |
|---|
| 49 | ObjectExist("Set","nb::_.linearInput"), |
|---|
| 50 | nb::_.linearInput, |
|---|
| 51 | Copy(Empty) |
|---|
| 52 | ); |
|---|
| 53 | |
|---|
| 54 | Set nonLinearInput = If( |
|---|
| 55 | ObjectExist("Set","nb::_.nonLinearInput"), |
|---|
| 56 | nb::_.nonLinearInput, |
|---|
| 57 | Copy(Empty) |
|---|
| 58 | ); |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | Set boxCox = If( |
|---|
| 62 | ObjectExist("Set","nb::_.transformation"), |
|---|
| 63 | nb::_.transformation, |
|---|
| 64 | SetOfReal(0,0) |
|---|
| 65 | ); |
|---|
| 66 | |
|---|
| 67 | //constante |
|---|
| 68 | Real constant = If(ObjectExist("Real","nb::_.constant"),nb::_.constant, 0); |
|---|
| 69 | |
|---|
| 70 | //inicio de estimación |
|---|
| 71 | Date iniEst = If( |
|---|
| 72 | ObjectExist("Date","nb::_.iniEst"), |
|---|
| 73 | nb::_.iniEst, |
|---|
| 74 | MMC_DefIni |
|---|
| 75 | ); |
|---|
| 76 | |
|---|
| 77 | //fin de estimación |
|---|
| 78 | Date endEst = If( |
|---|
| 79 | ObjectExist("Date","nb::_.endEst"), |
|---|
| 80 | nb::_.endEst, |
|---|
| 81 | Succ(Now, Diario, -1) |
|---|
| 82 | ); |
|---|
| 83 | |
|---|
| 84 | //extraemos el ARIMA |
|---|
| 85 | Set arimaSet = Traspose(GetArimaFromLabel(arima)); |
|---|
| 86 | //periodo |
|---|
| 87 | Real period = SetMin(arimaSet[1]); |
|---|
| 88 | //diferencia |
|---|
| 89 | Polyn dif = BinGroup("*",arimaSet[4]); |
|---|
| 90 | //autoregresivo |
|---|
| 91 | Set ar = arimaSet[2]; |
|---|
| 92 | //media movil |
|---|
| 93 | Set ma = arimaSet[3]; |
|---|
| 94 | |
|---|
| 95 | //se define el modelo |
|---|
| 96 | Set model = ModelDef( |
|---|
| 97 | ser, boxCox[1], boxCox[2], period, constant, |
|---|
| 98 | dif, ar, ma, linearInput, nonLinearInput |
|---|
| 99 | ); |
|---|
| 100 | |
|---|
| 101 | //se genera la estimación |
|---|
| 102 | Set estimation = Estimate(model, iniEst, endEst) |
|---|
| 103 | |
|---|