TradingDaysSelectionModule extends DemetraModule implements IPreprocessingModule { @Override public ProcessingResult process(ModellingContext context) { tdStats = new LikelihoodStatistics[tdVars.length]; PreprocessingModel tdm = createModel(context, tdVars[0], LengthOfPeriodType.LeapYear); if (tdm == null) { return ProcessingResult.Failed; } tdModel = tdm; ConcentratedLikelihood ll = tdm.estimation.getLikelihood(); tdStats[0] = tdm.estimation.getStatistics(); int nhp = tdm.description.getArimaComponent().getFreeParametersCount(); int df = ll.getN() - ll.getNx() - nhp; sigma = ll.getSsqErr() / df; ntdStats = check(null, LengthOfPeriodType.LeapYear); for (int i = 1; i < tdVars.length; ++i) { tdStats[i] = check(tdVars[i], LengthOfPeriodType.LeapYear); } calcProb(); int sel = 0; choice = -1; for (int i = 0; i < pdel.length; ++i) { if (pdel[i] < pfdel && ptd[i] < pftd) { choice = i; break; } } if (choice < 0 && ptd[pdel.length] < pftd) { choice = pdel.length; } GenericTradingDays best = choice < 0 ? null : tdVars[choice]; tdModel = createModel(context, best, LengthOfPeriodType.LeapYear); if (best == null || !checkLY(tdModel)) { boolean mean = Math.abs(tdModel.estimation.getLikelihood().getTStats(true, 2)[0]) > 1.96; context.description = backModel(context, best, LengthOfPeriodType.None, mean); } else { boolean mean = Math.abs(tdModel.estimation.getLikelihood().getTStats(true, 2)[0]) > 1.96; context.description = backModel(context, best, LengthOfPeriodType.LeapYear, mean); } context.estimation = null; return ProcessingResult.Changed; } TradingDaysSelectionModule(final double pftd, final double pfdel);  TradingDaysSelectionModule(final double pftd, final double pfdel, final GenericTradingDays[] td); double getPftd(); double getTValue(); void setTvalue(double tval); @Override ProcessingResult process(ModellingContext context); LikelihoodStatistics[] getTdStats(); double[] getPdel(); double[] getPtd(); int getChoice(); double[] getBic(); GenericTradingDays[] getTdVars(); PreprocessingModel getTdModel(); LikelihoodStatistics getNtdStats();  }
@Test public void testProd() { TradingDaysSelectionModule tdm=new TradingDaysSelectionModule(.01, .01); ModellingContext context=new ModellingContext(); context.automodelling=true; context.hasseas=true; context.description=new ModelDescription(Data.X, null); context.description.setAirline(true); context.description.setTransformation(DefaultTransformationType.Log); tdm.process(context); }