### Question:
RandomEffectsMetaAnalysis extends AbstractMetaAnalysis implements PairWiseMetaAnalysis { public RandomEffectMetaAnalysisRelativeEffect<Measurement> getRelativeEffect(Class<? extends RelativeEffect<?>> type) { final List<RelativeEffect<? extends Measurement>> relativeEffects = getFilteredRelativeEffects(type); if (relativeEffects.isEmpty()) { return null; } return new RandomEffectsRelativeEffect(relativeEffects); } RandomEffectsMetaAnalysis(String name, OutcomeMeasure om,
			TreatmentDefinition baseline, TreatmentDefinition subject,
			List<StudyArmsEntry> studyArms, boolean corr); @Override TreatmentDefinition getFirstAlternative(); @Override TreatmentDefinition getSecondAlternative(); List<StudyArmsEntry> getStudyArms(); RandomEffectMetaAnalysisRelativeEffect<Measurement> getRelativeEffect(Class<? extends RelativeEffect<?>> type); boolean getIsCorrected(); void setIsCorrected(boolean iscorrected); @Override boolean deepEquals(Entity other); @Override MultivariateNormalSummary getRelativeEffectsSummary(); static final String PROPERTY_INCLUDED_STUDIES_COUNT; static final String PROPERTY_CORRECTED; }### Answer:
@Test public void testGetRiskRatioRelativeEffect() { RandomEffectMetaAnalysisRelativeEffect<Measurement> riskRatio = d_rema.getRelativeEffect(BasicRiskRatio.class); assertEquals(2.03, riskRatio.getHeterogeneity(), 0.01); assertEquals(calculateI2(2.03,d_rema.getIncludedStudies().size()), riskRatio.getHeterogeneityI2(), 0.01); assertEquals(1.10, (riskRatio.getConfidenceInterval().getPointEstimate()), 0.01); assertEquals(1.01, (riskRatio.getConfidenceInterval().getLowerBound()), 0.01); assertEquals(1.20, (riskRatio.getConfidenceInterval().getUpperBound()), 0.01); }
@Test public void testGetOddsRatioRelativeEffect() { RandomEffectMetaAnalysisRelativeEffect<Measurement> oddsRatio = d_rema.getRelativeEffect(BasicOddsRatio.class); assertEquals(2.14, oddsRatio.getHeterogeneity(), 0.01); assertEquals(1.30, (oddsRatio.getConfidenceInterval().getPointEstimate()), 0.01); assertEquals(1.03, (oddsRatio.getConfidenceInterval().getLowerBound()), 0.01); assertEquals(1.65, (oddsRatio.getConfidenceInterval().getUpperBound()), 0.01); }
@Test public void testContinuousMetaAnalysis() { Study s1 = ExampleData.buildContinuousStudy("s1", 50, 4, 2, 50, 6, 2); Study s2 = ExampleData.buildContinuousStudy("s2", 50, 4, 2, 50, 7, 2); List<Study> studies = new ArrayList<Study>(); studies.add(s1); studies.add(s2); RandomEffectsMetaAnalysis ma = ExampleData.buildRandomEffectsMetaAnalysis("meta", d_contEndpoint, studies, TreatmentDefinition.createTrivial(d_fluox), TreatmentDefinition.createTrivial(d_sertr)); RandomEffectMetaAnalysisRelativeEffect<Measurement> relativeEffect = ma.getRelativeEffect(BasicMeanDifference.class); assertEquals(2.5, relativeEffect.getConfidenceInterval().getPointEstimate(), 0.01); }
@Test public void testPooledIsNullWhenAllUndefined() { Study zeroRate = ExampleData.buildRateStudy("ZeroRate 2012", 0, 120, 86, 118); RandomEffectsMetaAnalysis rema = ExampleData.buildRandomEffectsMetaAnalysis("meta", d_rateEndpoint, Collections.singletonList(zeroRate), TreatmentDefinition.createTrivial(d_fluox), TreatmentDefinition.createTrivial(d_sertr)); assertNull(rema.getRelativeEffect(BasicOddsRatio.class)); }