DifferencingModule extends DemetraModule implements IDifferencingModule, IPreprocessingModule { @Override public ProcessingResult process(ModellingContext context) { try { DataBlock res; if (context.estimation != null) { int xcount = context.estimation.getRegArima().getXCount(); int xout = context.description.getOutliers().size(); res = context.estimation.getCorrectedData(xcount - xout, xcount); } else { res = new DataBlock(context.description.transformedOriginal()); } SarimaSpecification nspec = context.description.getSpecification(); freq = context.description.getFrequency(); process(res, freq, nspec.getD(), nspec.getBD()); boolean changed = false; if (nspec.getD() != d || nspec.getBD() != bd) { changed = true; SarimaSpecification cspec = new SarimaSpecification(freq); cspec.setD(d); cspec.setBD(bd); context.description.setSpecification(cspec); context.estimation = null; } if (isMeanCorrection() != context.description.isEstimatedMean()) { changed = true; context.description.setMean(isMeanCorrection()); context.estimation = null; } return changed ? ProcessingResult.Changed : ProcessingResult.Unchanged; } catch (RuntimeException err) { context.description.setAirline(context.hasseas); context.estimation = null; return ProcessingResult.Failed; } } DifferencingModule(); @Override int getBD(); @Override boolean isMeanCorrection(); @Override int getD(); BackFilter getDifferencingFilter(); @Override ProcessingResult process(ModellingContext context); @Override void process(final IReadDataBlock res, int freq, int curd, int curbd); double getTmean(); double getK(); void setK(double k); double getTstat(); void setTstat(double tstat); @Override void setLimits(int maxd, int maxbd); boolean isRegularFirst(); void setRegularFirst(boolean regularFirst); boolean isMad(); void setMad(boolean mad); static final int MAXD; static final double EPS; }
@Test public void testSomeMethod() { ModellingContext context = new ModellingContext(); context.automodelling = true; context.hasseas = true; context.description = new ModelDescription(Data.P, null); context.description.setTransformation(DefaultTransformationType.Log); DifferencingModule diff=new DifferencingModule(); diff.process(context); }