Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 96 additions & 96 deletions renal_capacity_model/config_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,151 +264,151 @@
"initialisation": {
"not_listed": {
"early": {
1: [0.926963321, 2127.231053],
2: [1.102888443, 2360.960064],
3: [1.042024424, 1757.881403],
4: [1.102673686, 1641.614239],
5: [1.149855608, 1561.636782],
6: [1.151814597, 1190.40286],
1: {"shape": 0.926963321, "scale": 2127.231053},
2: {"shape": 1.102888443, "scale": 2360.960064},
3: {"shape": 1.042024424, "scale": 1757.881403},
4: {"shape": 1.102673686, "scale": 1641.614239},
5: {"shape": 1.149855608, "scale": 1561.636782},
6: {"shape": 1.151814597, "scale": 1190.40286},
},
"late": {
1: [1.099732869, 4314.8445],
2: [1.239811029, 2204.356655],
3: [1.025879638, 1940.947327],
4: [1.17279732, 1700.235305],
5: [1.168619527, 1512.312581],
6: [1.156286321, 1253.912137],
1: {"shape": 1.099732869, "scale": 4314.8445},
2: {"shape": 1.239811029, "scale": 2204.356655},
3: {"shape": 1.025879638, "scale": 1940.947327},
4: {"shape": 1.17279732, "scale": 1700.235305},
5: {"shape": 1.168619527, "scale": 1512.312581},
6: {"shape": 1.156286321, "scale": 1253.912137},
},
},
"listed": {
"early": {
1: [1.426589565, 13064.21921],
2: [1.501319694, 8229.734667],
3: [1.475457685, 6126.819295],
4: [1.388640715, 4221.17834],
5: [1.381583619, 2805.868318],
6: [1.262968437, 1862.925138],
1: {"shape": 1.426589565, "scale": 13064.21921},
2: {"shape": 1.501319694, "scale": 8229.734667},
3: {"shape": 1.475457685, "scale": 6126.819295},
4: {"shape": 1.388640715, "scale": 4221.17834},
5: {"shape": 1.381583619, "scale": 2805.868318},
6: {"shape": 1.262968437, "scale": 1862.925138},
},
"late": {
1: [1.403897083, 13250.96392],
2: [1.359190822, 8393.578341],
3: [1.435707658, 5981.108405],
4: [1.326446673, 4096.723314],
5: [1.469351223, 2905.94038],
6: [1.244780918, 1800.673553],
1: {"shape": 1.403897083, "scale": 13250.96392},
2: {"shape": 1.359190822, "scale": 8393.578341},
3: {"shape": 1.435707658, "scale": 5981.108405},
4: {"shape": 1.326446673, "scale": 4096.723314},
5: {"shape": 1.469351223, "scale": 2905.94038},
6: {"shape": 1.244780918, "scale": 1800.673553},
},
},
"received_Tx": {
"early": {
1: [1.945083614, 11291.09043],
2: [1.765333669, 8449.099418],
3: [1.750669869, 6535.672038],
4: [1.61142907, 4693.44361],
5: [1.51886545, 3189.62546],
6: [1.315655704, 2078.132622],
1: {"shape": 1.945083614, "scale": 11291.09043},
2: {"shape": 1.765333669, "scale": 8449.099418},
3: {"shape": 1.750669869, "scale": 6535.672038},
4: {"shape": 1.61142907, "scale": 4693.44361},
5: {"shape": 1.51886545, "scale": 3189.62546},
6: {"shape": 1.315655704, "scale": 2078.132622},
},
"late": {
1: [1.982364823, 10573.47681],
2: [1.658109448, 8611.590105],
3: [1.699130074, 6499.195977],
4: [1.491659213, 4669.1818],
5: [1.678178577, 3296.367133],
6: [1.306592647, 1990.733317],
1: {"shape": 1.982364823, "scale": 10573.47681},
2: {"shape": 1.658109448, "scale": 8611.590105},
3: {"shape": 1.699130074, "scale": 6499.195977},
4: {"shape": 1.491659213, "scale": 4669.1818},
5: {"shape": 1.678178577, "scale": 3296.367133},
6: {"shape": 1.306592647, "scale": 1990.733317},
},
},
},
"incidence": {
"not_listed": {
"early": {
1: [1.021124756, 1630.450226],
2: [1.033558934, 1601.726618],
3: [1.175150289, 1788.324784],
4: [1.171027698, 1671.61871],
5: [1.182843607, 1604.030346],
6: [1.111932566, 1324.708399],
1: {"shape": 1.021124756, "scale": 1630.450226},
2: {"shape": 1.033558934, "scale": 1601.726618},
3: {"shape": 1.175150289, "scale": 1788.324784},
4: {"shape": 1.171027698, "scale": 1671.61871},
5: {"shape": 1.182843607, "scale": 1604.030346},
6: {"shape": 1.111932566, "scale": 1324.708399},
},
"late": {
1: [1.025446743, 2098.5119],
2: [0.86558945, 2071.301577],
3: [0.787953011, 1428.187242],
4: [1.093861294, 1533.652413],
5: [0.817406992, 1170.501979],
6: [0.829891, 841.5931435],
1: {"shape": 1.025446743, "scale": 2098.5119},
2: {"shape": 0.86558945, "scale": 2071.301577},
3: {"shape": 0.787953011, "scale": 1428.187242},
4: {"shape": 1.093861294, "scale": 1533.652413},
5: {"shape": 0.817406992, "scale": 1170.501979},
6: {"shape": 0.829891, "scale": 841.5931435},
},
},
"listed": {
"early": {
1: [1.76722409, 7565.454427],
2: [2.071602421, 5267.578147],
3: [1.842843082, 5294.787645],
4: [2.276835063, 3862.063689],
5: [1.990617668, 3148.737229],
6: [2.435166079, 2479.412332],
1: {"shape": 1.76722409, "scale": 7565.454427},
2: {"shape": 2.071602421, "scale": 5267.578147},
3: {"shape": 1.842843082, "scale": 5294.787645},
4: {"shape": 2.276835063, "scale": 3862.063689},
5: {"shape": 1.990617668, "scale": 3148.737229},
6: {"shape": 2.435166079, "scale": 2479.412332},
},
"late": {
1: [2.732803839, 5100.306997],
2: [1.7523112, 6999.685955],
3: [2.667855187, 3817.522327],
4: [2.39938038, 3728.91519],
5: [2.195794462, 2550.374846],
6: [2.435166079, 2479.412332],
1: {"shape": 2.732803839, "scale": 5100.306997},
2: {"shape": 1.7523112, "scale": 6999.685955},
3: {"shape": 2.667855187, "scale": 3817.522327},
4: {"shape": 2.39938038, "scale": 3728.91519},
5: {"shape": 2.195794462, "scale": 2550.374846},
6: {"shape": 2.435166079, "scale": 2479.412332},
},
},
"received_Tx": {
"early": {
1: [2.51486622, 6903.239543],
2: [3.159509376, 5391.985192],
3: [2.70710626, 5381.509481],
4: [2.893707823, 4282.49379],
5: [2.35276178, 3550.906294],
6: [4.316362639, 3118.52084],
1: {"shape": 2.51486622, "scale": 6903.239543},
2: {"shape": 3.159509376, "scale": 5391.985192},
3: {"shape": 2.70710626, "scale": 5381.509481},
4: {"shape": 2.893707823, "scale": 4282.49379},
5: {"shape": 2.35276178, "scale": 3550.906294},
6: {"shape": 4.316362639, "scale": 3118.52084},
},
"late": {
1: [3.160772244, 5169.606112],
2: [2.323615011, 7944.757158],
3: [3.8964386, 4637.1169],
4: [5.45663996, 3913.875032],
5: [3.071596253, 3120.115725],
6: [4.316362639, 3118.52084],
1: {"shape": 3.160772244, "scale": 5169.606112},
2: {"shape": 2.323615011, "scale": 7944.757158},
3: {"shape": 3.8964386, "scale": 4637.1169},
4: {"shape": 5.45663996, "scale": 3913.875032},
5: {"shape": 3.071596253, "scale": 3120.115725},
6: {"shape": 4.316362639, "scale": 3118.52084},
},
},
},
}

tw_cadTx_values = {
1: [1.12, 719],
2: [1.23, 734],
3: [1.31, 794],
4: [1.31, 762],
5: [1.23, 619],
6: [1.02, 385],
1: {"shape": 1.12, "scale": 719},
2: {"shape": 1.23, "scale": 734},
3: {"shape": 1.31, "scale": 794},
4: {"shape": 1.31, "scale": 762},
5: {"shape": 1.23, "scale": 619},
6: {"shape": 1.02, "scale": 385},
}

tw_liveTx_values = {
1: [1.03, 399],
2: [1.06, 464],
3: [1.08, 417],
4: [1.09, 420],
5: [1.22, 391],
6: [1.01, 342],
1: {"shape": 1.03, "scale": 399},
2: {"shape": 1.06, "scale": 464},
3: {"shape": 1.08, "scale": 417},
4: {"shape": 1.09, "scale": 420},
5: {"shape": 1.22, "scale": 391},
6: {"shape": 1.01, "scale": 342},
}

tw_cadTx_initialisation_values = {
1: [1.12, 1336],
2: [1.13, 1163],
3: [1.22, 1194],
4: [1.26, 1023],
5: [1.28, 839],
6: [1.28, 409],
1: {"shape": 1.12, "scale": 1336},
2: {"shape": 1.13, "scale": 1163},
3: {"shape": 1.22, "scale": 1194},
4: {"shape": 1.26, "scale": 1023},
5: {"shape": 1.28, "scale": 839},
6: {"shape": 1.28, "scale": 409},
}

tw_liveTx_initialisation_values = {
1: [0.96, 752],
2: [1.05, 1006],
3: [0.96, 903],
4: [1.01, 665],
5: [1.27, 765],
6: [1.27, 765],
1: {"shape": 0.96, "scale": 752},
2: {"shape": 1.05, "scale": 1006},
3: {"shape": 0.96, "scale": 903},
4: {"shape": 1.01, "scale": 665},
5: {"shape": 1.27, "scale": 765},
6: {"shape": 1.27, "scale": 765},
}

# Time waiting before dialysis
Expand Down
2 changes: 1 addition & 1 deletion renal_capacity_model/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def __init__(
self.time_living_with_live_transplant: float | None = None
self.time_living_with_cadaver_transplant: float | None = None
self.transplant_count = 0
self.time_on_waiting_list = 0
self.time_on_waiting_list: float = 0
self.time_enters_waiting_list: float | None = None
self.time_of_transplant: float | None = None
18 changes: 18 additions & 0 deletions renal_capacity_model/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,21 @@ def check_time_to_event_curve_dfs(tte_df_name: str, tte_df: pd.DataFrame):
assert list(tte_df.columns) == cols
except AssertionError:
raise ValueError(f"Check {tte_df_name} csv - incorrect indices/columns")


def calculate_time_to_event(
rng: np.random.Generator, scale: float, shape: float, multiplier: float = 1
) -> float:
"""Calculate time to event, sampling from a Weibull distribution and multiplying
it with a scale and optional multiplier

Args:
rng (np.random.Generator): Random Number Generator
scale (float): Scale to be used for the calculation
shape (float): Shape parameter for Weibull distribution
multiplier (float, optional): Optional multiplier. Defaults to 1.

Returns:
float: Sampled time to event
"""
return (scale * rng.weibull(shape)) * multiplier
7 changes: 6 additions & 1 deletion renal_capacity_model/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ def main(
)
for excel_file in [path_to_inputs_file, path_to_outputs_file]:
filepaths.append(copy_excel_files(excel_file, run_start_time))
write_results_to_excel(filepaths[1], combined_results, trial.costs_dfs)
write_results_to_excel(
filepaths[1],
combined_results,
trial.costs_dfs,
sim_years=int(config.sim_duration / 365),
)


if __name__ == "__main__":
Expand Down
Loading