ThetaArgumentMaker implements ArgumentMaker { public double[] getArgument(double[][] data) { double[] rval = new double[d_treatments.size()]; for (int i = 0; i < rval.length; ++i) { rval[i] = theta(i, data); } return rval; } ThetaArgumentMaker(List<Treatment> treatments, List<List<Pair<Treatment>>> studyPmtz, int muIdx, int deltaIdx); double[] getArgument(double[][] data);  }
@Test public void testGetArgumentTwoArm() { List<Treatment> treatments = Arrays.asList(d_ta, d_tb); List<List<Pair<Treatment>>> pmtz = Collections.singletonList( Collections.singletonList(new Pair<Treatment>(d_ta, d_tb))); double[] mu = {1.0}; double[] delta = {-1.0}; double[][] data = { mu, delta }; double[] expected = {1.0, 0.0}; ThetaArgumentMaker maker = new ThetaArgumentMaker(treatments, pmtz, 0, 1); assertArrayEquals(expected, maker.getArgument(data), EPSILON); mu[0] = -0.5; delta[0] = 0.9; expected[0] = -0.5; expected[1] = 0.4; assertArrayEquals(expected, maker.getArgument(data), EPSILON); }
@Test public void testGetArgumentTwoArmReverse() { List<Treatment> treatments = Arrays.asList(d_ta, d_tb); List<List<Pair<Treatment>>> pmtz = Collections.singletonList( Collections.singletonList(new Pair<Treatment>(d_tb, d_ta))); double[] mu = {1.0}; double[] delta = {-1.0}; double[][] data = { mu, delta }; double[] expected = {0.0, 1.0}; ThetaArgumentMaker maker = new ThetaArgumentMaker(treatments, pmtz, 0, 1); assertArrayEquals(expected, maker.getArgument(data), EPSILON); mu[0] = -0.5; delta[0] = 0.9; expected[0] = 0.4; expected[1] = -0.5; assertArrayEquals(expected, maker.getArgument(data), EPSILON); }
@SuppressWarnings("unchecked") @Test public void testGetArgumentThreeArm() { List<Treatment> treatments = Arrays.asList(d_tb, d_tc, d_td); List<List<Pair<Treatment>>> pmtz = Collections.singletonList( Arrays.asList(new Pair<Treatment>(d_tc, d_td), new Pair<Treatment>(d_tc, d_tb))); double[] mu = {2.0}; double[] delta = {3.0, 2.0}; double[][] data = { mu, delta }; double[] expected = {4.0, 2.0, 5.0}; ThetaArgumentMaker maker = new ThetaArgumentMaker(treatments, pmtz, 0, 1); assertArrayEquals(expected, maker.getArgument(data), EPSILON); }
@SuppressWarnings("unchecked") @Test public void testGetArgumentSplit() { List<Treatment> treatments = Arrays.asList(d_tb, d_tc, d_td); List<List<Pair<Treatment>>> pmtz = Arrays.asList( Collections.singletonList(new Pair<Treatment>(d_tc, d_td)), Collections.singletonList(new Pair<Treatment>(d_tc, d_tb))); double[] mu = {2.0}; double[] delta = {3.0, 2.0}; double[][] data = { mu, delta }; double[] expected = {4.0, 2.0, 5.0}; ThetaArgumentMaker maker = new ThetaArgumentMaker(treatments, pmtz, 0, 1); assertArrayEquals(expected, maker.getArgument(data), EPSILON); }
@SuppressWarnings("unchecked") @Test public void testGetArgumentSplit2() { List<Treatment> treatments = Arrays.asList(d_tb, d_tc, d_td); List<List<Pair<Treatment>>> pmtz = Arrays.asList( Collections.singletonList(new Pair<Treatment>(d_tb, d_tc)), Collections.singletonList(new Pair<Treatment>(d_tc, d_td))); double[] mu = {2.0}; double[] delta = {3.0, 2.0}; double[][] data = { mu, delta }; double[] expected = {2.0, 5.0, 7.0}; ThetaArgumentMaker maker = new ThetaArgumentMaker(treatments, pmtz, 0, 1); assertArrayEquals(expected, maker.getArgument(data), EPSILON); }