diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java index 2e6baf9..4aa4470 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java @@ -6,23 +6,24 @@ import lombok.Builder; import lombok.Getter; import java.io.Serializable; +import java.util.List; import java.util.Map; @Builder public class CompetingRiskFunctions implements Serializable { - private final Map causeSpecificHazardFunctionMap; - private final Map cumulativeIncidenceFunctionMap; + private final List causeSpecificHazards; + private final List cumulativeIncidenceCurves; @Getter private final MathFunction survivalCurve; public MathFunction getCauseSpecificHazardFunction(int cause){ - return causeSpecificHazardFunctionMap.get(cause); + return causeSpecificHazards.get(cause-1); } public MathFunction getCumulativeIncidenceFunction(int cause) { - return cumulativeIncidenceFunctionMap.get(cause); + return cumulativeIncidenceCurves.get(cause-1); } public double calculateEventSpecificMortality(final int event, final double tau){ diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java index 8da1d91..ed5fff2 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java @@ -55,8 +55,9 @@ public class CompetingRiskFunctionCombiner implements ResponseCombiner causeSpecificCumulativeHazardFunctionMap = new HashMap<>(); - final Map cumulativeIncidenceFunctionMap = new HashMap<>(); + + final List causeSpecificCumulativeHazardFunctionList = new ArrayList<>(events.length); + final List cumulativeIncidenceFunctionList = new ArrayList<>(events.length); for(final int event : events){ @@ -78,14 +79,14 @@ public class CompetingRiskFunctionCombiner implements ResponseCombiner responses) { - final Map causeSpecificCumulativeHazardFunctionMap = new HashMap<>(); - final Map cumulativeIncidenceFunctionMap = new HashMap<>(); + final List causeSpecificCumulativeHazardFunctionList = new ArrayList<>(events.length); + final List cumulativeIncidenceFunctionList = new ArrayList<>(events.length); final double[] timesToUse; if(times != null){ @@ -103,16 +103,16 @@ public class CompetingRiskResponseCombiner implements ResponseCombiner