SigmaRowArgumentMaker implements ArgumentMaker { public double[] getArgument(double[][] data) { double sd = data[d_sigmaIdx][0]; double var = sd * sd; double cov = var / 2; double[] arr = new double[d_nRows]; Arrays.fill(arr, d_from, d_to, cov); arr[d_row] = var; return arr; } SigmaRowArgumentMaker(List<List<Pair<Treatment>>> studyPmtz, int row, int sigmaIdx); static List<ArgumentMaker> createMatrixArgumentMaker(List<List<Pair<Treatment>>> studyPmtz, int sigmaIdx); double[] getArgument(double[][] data);  }
@SuppressWarnings("unchecked") @Test public void testGetArgumentThreeArm() { double[] sigma = new double[] {2.0}; double[] expected0 = new double[] {4.0, 2.0}; double[] expected1 = new double[] {2.0, 4.0}; List<List<Pair<Treatment>>> param = Collections.singletonList(Arrays.asList( new Pair<Treatment>(d_ta, d_tb), new Pair<Treatment>(d_ta, d_tc))); SigmaRowArgumentMaker maker0 = new SigmaRowArgumentMaker(param, 0, 0); assertArrayEquals(expected0, maker0.getArgument(new double[][] {sigma}), EPSILON); SigmaRowArgumentMaker maker0b = new SigmaRowArgumentMaker(param, 0, 1); assertArrayEquals(expected0, maker0b.getArgument(new double[][] {null, sigma}), EPSILON); SigmaRowArgumentMaker maker1 = new SigmaRowArgumentMaker(param, 1, 0); assertArrayEquals(expected1, maker1.getArgument(new double[][] {sigma}), EPSILON); }
@SuppressWarnings("unchecked") @Test public void testGetArgumentFourArm() { double[] sigma = new double[] {2.0}; double[] expected0 = new double[] {4.0, 2.0, 2.0}; double[] expected1 = new double[] {2.0, 4.0, 2.0}; List<List<Pair<Treatment>>> param = Collections.singletonList(Arrays.asList( new Pair<Treatment>(d_ta, d_tb), new Pair<Treatment>(d_ta, d_tc), new Pair<Treatment>(d_ta, d_td))); SigmaRowArgumentMaker maker0 = new SigmaRowArgumentMaker(param, 0, 0); assertArrayEquals(expected0, maker0.getArgument(new double[][] {sigma}), EPSILON); SigmaRowArgumentMaker maker1 = new SigmaRowArgumentMaker(param, 1, 0); assertArrayEquals(expected1, maker1.getArgument(new double[][] {sigma}), EPSILON); }
@SuppressWarnings("unchecked") @Test public void testGetArgumentThreeArmSplit() { double[] sigma = new double[] {2.0}; double[] expected0 = new double[] {4.0, 0.0}; double[] expected1 = new double[] {0.0, 4.0}; List<List<Pair<Treatment>>> param = Arrays.asList( Arrays.asList(new Pair<Treatment>(d_ta, d_tb)), Arrays.asList(new Pair<Treatment>(d_ta, d_tc))); SigmaRowArgumentMaker maker0 = new SigmaRowArgumentMaker(param, 0, 0); assertArrayEquals(expected0, maker0.getArgument(new double[][] {sigma}), EPSILON); SigmaRowArgumentMaker maker0b = new SigmaRowArgumentMaker(param, 0, 1); assertArrayEquals(expected0, maker0b.getArgument(new double[][] {null, sigma}), EPSILON); SigmaRowArgumentMaker maker1 = new SigmaRowArgumentMaker(param, 1, 0); assertArrayEquals(expected1, maker1.getArgument(new double[][] {sigma}), EPSILON); }
@SuppressWarnings("unchecked") @Test public void testGetArgumentFourArmSplit() { double[] sigma = new double[] {2.0}; double[] expected0 = new double[] {4.0, 2.0, 0.0}; double[] expected1 = new double[] {2.0, 4.0, 0.0}; double[] expected2 = new double[] {0.0, 0.0, 4.0}; List<List<Pair<Treatment>>> param = Arrays.asList( Arrays.asList(new Pair<Treatment>(d_ta, d_tb), new Pair<Treatment>(d_ta, d_tc)), Arrays.asList(new Pair<Treatment>(d_ta, d_td))); SigmaRowArgumentMaker maker0 = new SigmaRowArgumentMaker(param, 0, 0); assertArrayEquals(expected0, maker0.getArgument(new double[][] {sigma}), EPSILON); SigmaRowArgumentMaker maker1 = new SigmaRowArgumentMaker(param, 1, 0); assertArrayEquals(expected1, maker1.getArgument(new double[][] {sigma}), EPSILON); SigmaRowArgumentMaker maker2 = new SigmaRowArgumentMaker(param, 2, 0); assertArrayEquals(expected2, maker2.getArgument(new double[][] {sigma}), EPSILON); }