Changeset 405bdc0 in tol
- Timestamp:
- Oct 21, 2008, 11:02:31 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 0ed0c00
- Parents:
- 2ebc562
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/dynhlm/_db_api.estim.tol
r2ebc562 r405bdc0 82 82 Set LinearBlk.Effects = EvalSet(series.handler::_.obs.node, Set(NameBlock nsh) 83 83 { 84 Real outIsATimeSerie = ObjectExist("Serie", "nsh::_.output::_.serie"); 85 Real outIsAVector = ObjectExist("Matrix", "nsr::_.output::_.vector"); 86 Text grammar = If(outIsATimeSerie,"Serie","Matrix"); 84 87 WriteLn("[GetLinearBlkEffects] Building node "+nsh::_.id_node); 85 Set effect = EvalSet(nsh::_.input, Serie(NameBlock inp)88 Set effect = EvalSet(nsh::_.input, Anything(NameBlock inp) 86 89 { 87 90 Text inpName = Name(inp); 88 WriteLn("[GetLinearBlkEffects] Building input "+inpName); 89 Ratio tf = If(!ObjectExist("Ratio","inp::_.transferFunction"),1/1, 90 inp::_.transferFunction); 91 Polyn omega = Numerator (tf); 92 Polyn delta = Denominator(tf); 93 Real p = Degree(omega); 94 Real q = Degree(delta); 95 Real h = Max(p,q); 96 Real noTransFunFlag = h==0; 97 98 Serie eff = Case( 99 Not(inp::_.enabled), 91 Case( 92 outIsATimeSerie, 100 93 { 101 inp::_.serie*0 94 WriteLn("[GetLinearBlkEffects] Building time series input "+inpName); 95 Ratio tf = If(!ObjectExist("Ratio","inp::_.transferFunction"),1/1, 96 inp::_.transferFunction); 97 Polyn omega = Numerator (tf); 98 Polyn delta = Denominator(tf); 99 Real p = Degree(omega); 100 Real q = Degree(delta); 101 Real h = Max(p,q); 102 Real noTransFunFlag = h==0; 103 104 Serie eff = Case( 105 Not(inp::_.enabled), 106 { 107 inp::_.serie*0 108 }, 109 noTransFunFlag, 110 { 111 Real coef = 112 { 113 Text varName = "LinearBlk::"+nsh::_.id_node+"::"+inpName+"::Coef"; 114 Text varNameTol = ToName(varName); 115 Real k = FindIndexByName(colNames, varNameTol); 116 If(!k, WriteLn("Cannot find lineal parameter called "+ 117 varNameTol+" in set \n"<<colNames,"E")); 118 MatDat(param,1,k) 119 }; 120 inp::_.serie * coef 121 }, 122 1==1, 123 { 124 Polyn omega.estim = SetSum(EvalSet(Monomes(omega),Polyn(Polyn mon) 125 { 126 Text varName = "OmegaBlk::"+nsh::_.id_node+"::"+ 127 inpName+"::NumDeg."+IntText(Degree(mon)); 128 Text varNameTol = ToName(varName); 129 Real k = FindIndexByName(colNames, varNameTol); 130 If(!k, WriteLn("Cannot find omega parameter called "+ 131 varNameTol+" in set \n"<<colNames,"E")); 132 MatDat(param,1,k) 133 })); 134 Polyn delta.estim = SetSum(EvalSet(Monomes(1-delta),Polyn(Polyn mon) 135 { 136 Text varName = "DeltaBlk::"+nsh::_.id_node+"::"+ 137 inpName+"::DenDeg."+IntText(Degree(mon)); 138 Text varNameTol = ToName(varName); 139 Real k = FindIndexByName(colNames, varNameTol); 140 If(!k, WriteLn("Cannot find delta parameter called "+ 141 varNameTol+" in set \n"<<colNames,"E")); 142 MatDat(param,1,k) 143 })); 144 Set denIni.estim = For(1,h,Real denIni.param(Real lag) 145 { 146 Text varName = "DeltaBlk::"+nsh::_.id_node+"::"+ 147 inpName+"::DenIni."+IntText(h-lag); 148 Text varNameTol = ToName(varName); 149 Real k = FindIndexByName(colNames, varNameTol); 150 If(!k, WriteLn("Cannot find delta init value parameter called "+ 151 varNameTol+" in set \n"<<colNames,"E")); 152 MatDat(param,1,k) 153 }); 154 If(!h, 155 { 156 DifEq(tf, inp::_.serie) 157 }, 158 { 159 Date fst.ser = First(inp::_.serie); 160 Date fst.p = Succ(fst.ser, Dating(inp::_.serie), p); 161 Date fst.q = Succ(fst.p, Dating(inp::_.serie),-q); 162 Serie denIni.ser = MatSerSet(SetRow(denIni.estim), Dating(inp::_.serie), fst.q)[1]; 163 DifEq(omega.estim/delta.estim, inp::_.serie, denIni.ser) 164 }) 165 }); 166 Eval("Serie "+inpName+".Effect = eff") 102 167 }, 103 noTransFunFlag,168 outIsAVector, 104 169 { 105 Real coef = 106 { 107 Text varName = "LinearBlk::"+nsh::_.id_node+"::"+inpName+"::Coef"; 108 Text varNameTol = ToName(varName); 109 Real k = FindIndexByName(colNames, varNameTol); 110 If(!k, WriteLn("Cannot find lineal parameter called "+ 111 varNameTol+" in set \n"<<colNames,"E")); 112 MatDat(param,1,k) 113 }; 114 inp::_.serie * coef 170 WriteLn("[GetLinearBlkEffects] Building vector input "+inpName); 171 Matrix eff = Case( 172 Not(inp::_.enabled), 173 { 174 inp::_.vector*0 175 }, 176 noTransFunFlag, 177 { 178 Real coef = 179 { 180 Text varName = "LinearBlk::"+nsh::_.id_node+"::"+inpName+"::Coef"; 181 Text varNameTol = ToName(varName); 182 Real k = FindIndexByName(colNames, varNameTol); 183 If(!k, WriteLn("Cannot find lineal parameter called "+ 184 varNameTol+" in set \n"<<colNames,"E")); 185 MatDat(param,1,k) 186 }; 187 inp::_.vector * coef 188 }); 189 Eval("Matrix "+inpName+".Effect = eff") 115 190 }, 116 1==1,117 191 { 118 Polyn omega.estim = SetSum(EvalSet(Monomes(omega),Polyn(Polyn mon) 119 { 120 Text varName = "OmegaBlk::"+nsh::_.id_node+"::"+ 121 inpName+"::NumDeg."+IntText(Degree(mon)); 122 Text varNameTol = ToName(varName); 123 Real k = FindIndexByName(colNames, varNameTol); 124 If(!k, WriteLn("Cannot find omega parameter called "+ 125 varNameTol+" in set \n"<<colNames,"E")); 126 MatDat(param,1,k) 127 })); 128 Polyn delta.estim = SetSum(EvalSet(Monomes(1-delta),Polyn(Polyn mon) 129 { 130 Text varName = "DeltaBlk::"+nsh::_.id_node+"::"+ 131 inpName+"::DenDeg."+IntText(Degree(mon)); 132 Text varNameTol = ToName(varName); 133 Real k = FindIndexByName(colNames, varNameTol); 134 If(!k, WriteLn("Cannot find delta parameter called "+ 135 varNameTol+" in set \n"<<colNames,"E")); 136 MatDat(param,1,k) 137 })); 138 Set denIni.estim = For(1,h,Real denIni.param(Real lag) 139 { 140 Text varName = "DeltaBlk::"+nsh::_.id_node+"::"+ 141 inpName+"::DenIni."+IntText(h-lag); 142 Text varNameTol = ToName(varName); 143 Real k = FindIndexByName(colNames, varNameTol); 144 If(!k, WriteLn("Cannot find delta init value parameter called "+ 145 varNameTol+" in set \n"<<colNames,"E")); 146 MatDat(param,1,k) 147 }); 148 If(!h, 149 { 150 DifEq(tf, inp::_.serie) 151 }, 152 { 153 Date fst.ser = First(inp::_.serie); 154 Date fst.p = Succ(fst.ser, Dating(inp::_.serie), p); 155 Date fst.q = Succ(fst.p, Dating(inp::_.serie),-q); 156 Serie denIni.ser = MatSerSet(SetRow(denIni.estim), Dating(inp::_.serie), fst.q)[1]; 157 DifEq(omega.estim/delta.estim, inp::_.serie, denIni.ser) 158 }) 159 }); 160 Eval(inpName+".Effect = eff") 192 WriteLn("[GetLinearBlkEffects] Invalid input "+inpName, "E"); 193 Real Stop 194 }) 161 195 }); 162 Set Eval( nsh::_.id_node+".Effect=effect")196 Set Eval("Set "+nsh::_.id_node+".Effect=effect") 163 197 }) 164 198 };
Note: See TracChangeset
for help on using the changeset viewer.
