Skip to content

Commit 6163048

Browse files
Merge pull request #3 from DiogoRibeiro7/feat/first_commit
chore: work
2 parents 9c1e5d5 + 5ac5130 commit 6163048

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

.github/workflows/bump-version.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Fetch all history for all branches and tags
1820

1921
- uses: actions/setup-python@v5
2022
with:

gen_surv/cmm.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,30 @@
22
import numpy as np
33
from gen_surv.validate import validate_gen_cmm_inputs
44
from gen_surv.censoring import runifcens, rexpocens
5-
from gen_surv.cmm import generate_event_times
5+
6+
7+
def generate_event_times(z1: float, beta: list, rate: list) -> dict:
8+
"""
9+
Generate event times for a continuous-time multi-state Markov model.
10+
11+
Parameters:
12+
- z1 (float): Covariate value
13+
- beta (list of float): List of 3 beta coefficients
14+
- rate (list of float): List of 6 transition rate parameters
15+
16+
Returns:
17+
- dict: {'t12': float, 't13': float, 't23': float}
18+
"""
19+
u = np.random.uniform()
20+
t12 = (-np.log(1 - u) / (rate[0] * np.exp(beta[0] * z1)))**(1 / rate[1])
21+
22+
u = np.random.uniform()
23+
t13 = (-np.log(1 - u) / (rate[2] * np.exp(beta[1] * z1)))**(1 / rate[3])
24+
25+
u = np.random.uniform()
26+
t23 = (-np.log(1 - u) / (rate[4] * np.exp(beta[2] * z1)))**(1 / rate[5])
27+
28+
return {"t12": t12, "t13": t13, "t23": t23}
629

730
def gen_cmm(n, model_cens, cens_par, beta, covar, rate):
831
"""

0 commit comments

Comments
 (0)