コード例 #1
0
# simulate the cohort
simOutputs2 = cohort2.simulate()
survival_mean_CI_text2 = F.format_estimate_interval(
    estimate=simOutputs2.get_sumStat_survival_times().get_mean(),
    interval=simOutputs2.get_sumStat_survival_times().get_t_CI(
        alpha=Data.ALPHA),
    deci=2)
print(
    "  Estimate of mean survival time and {:.{prec}%} confidence interval if anticoagulation is used:"
    .format(1 - Data.ALPHA, prec=0), survival_mean_CI_text2)

#Problem 6: Survival curves (Weight 2): Estimate the survival curves of
# a patient who start in state “Well” under both alternatives.

PathCls.graph_sample_path(sample_path=simOutputs.get_survival_curve(),
                          title='Survival curve if no drug is used',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

#a patient with anticoagulation

PathCls.graph_sample_path(sample_path=simOutputs2.get_survival_curve(),
                          title='Survival curve if anticoagulation is used',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

#Problem 7: Number of strokes (Weight 2): Estimate the mean and show the histogram of the number of stokes
# that an individual who start in state “Well” may experience under both alternatives.

#get mean number of strokes
stroke_mean_CI_text = F.format_estimate_interval(
    estimate=simOutputs.get_sumState_stroketimes().get_mean(),
コード例 #2
0
import MarkovClasses as MarkovCls
import SupportMarkovModel as SupportMarkov
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create and cohort
cohort = MarkovCls.Cohort(
    id=0,
    therapy=P.Therapies.ANTICOAG)

simOutputs = cohort.simulate()

# graph survival curve
PathCls.graph_sample_path(
    sample_path=simOutputs.get_survival_curve(),
    title='Survival curve',
    x_label='Simulation time step',
    y_label='Number of alive patients'
    )

# graph histogram of survival times
Figs.graph_histogram(
    data=simOutputs.get_survival_times(),
    title='Survival times of patients with Stroke',
    x_label='Survival time (years)',
    y_label='Counts',
    bin_width=1
)


# graph histogram of number of strokes
Figs.graph_histogram(
コード例 #3
0
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# Problem 3 (6 and 7)
# create a cohort
cohort = MarkovCls.Cohort(
    id=0,
    therapy=P.Therapies.NATURAL_HISTORY)

# simulate the cohort
simOutputs = cohort.simulate()

# graph survival curve
PathCls.graph_sample_path(
    sample_path=simOutputs.get_survival_curve(),
    title='Survival curve under the natural history of disease',
    x_label='Simulation time step',
    y_label='Number of alive patients'
    )

# graph histogram of survival times
Figs.graph_histogram(
    data=simOutputs.get_survival_times(),
    title='Survival times of patients under the natural history of disease',
    x_label='Survival time (years)',
    y_label='Counts',
    bin_width=1
)

# graph histogram of stroke counts
Figs.graph_histogram(
    data=simOutputs.get_stroke_counts(),
コード例 #4
0
      para.get_transition_prob_whole())

#question 5
# create a cohort
cohort2 = MarkovCls.Cohort(id=1, therapy=P.Therapies.COMBO)

# simulate the cohort
simOutputs2 = cohort2.simulate()

#get the mean survival time and 95% CI under anticoagulation
SupportMarkov.print_outcomes(simOutputs2, 'Combo therapy:')

# question 6
# graph survival curve under no treatment
PathCls.graph_sample_path(sample_path=simOutputs.get_survival_curve(),
                          title='Survival curve under no treatment',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# graph survival curve receiving anticoagulation
PathCls.graph_sample_path(sample_path=simOutputs2.get_survival_curve(),
                          title='Survival curve receiving anticoagulation',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# question 7
#histogram of number of stroke times no treatment
Figs.graph_histogram(
    data=simOutputs.get_cohort_stroke(),
    title='Times of stroke of patients',
    x_label='Number of stroke during life time with no treatment',
    y_label='Counts',
コード例 #5
0
TIME_STEPS = 100  # simulation length
SIM_POP_SIZE = 1000  # population size of the simulated cohort
ALPHA = 0.05  # significance level

# create a cohort of patients
myCohort = Cls.Cohort(id=1,
                      pop_size=SIM_POP_SIZE,
                      mortality_prob=MORTALITY_PROB)

# simulate the cohort
cohortOutcome = myCohort.simulate(TIME_STEPS)

# plot the sample path
SamplePathSupport.graph_sample_path(
    sample_path=cohortOutcome.get_survival_curve(),
    title='Survival Curve',
    x_label='Time-Step (Year)',
    y_label='Number Survived')

# plot the histogram
Fig.graph_histogram(data=myCohort.get_survival_times(),
                    title='Histogram of Patient Survival Time',
                    x_label='Survival Time (Year)',
                    y_label='Count')

# print the patient survival time
print('Average survival time (years):', cohortOutcome.get_ave_survival_time())
print('95% CI of average survival time (years)',
      cohortOutcome.get_CI_survival_time(ALPHA))

#Question 1
コード例 #6
0
#question 4
A = P.ParametersFixed(P.Therapies.ANTI)
print("the transition prob matrix after Anticoagulation is:",
      A.get_transition_prob_whole())

#question 5
cohortTWO = MarkovCls.Cohort(id=1, therapy=P.Therapies.ANTI)

# simulate the cohort
simOutputsTWO = cohortTWO.simulate()

SupportMarkov.print_outcomes(simOutputsTWO, 'ANTI therapy:')

# question 6
PathCls.graph_sample_path(sample_path=simOutputs.get_survival_curve(),
                          title='Survival curve NORMAL treatment',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

PathCls.graph_sample_path(sample_path=simOutputsTWO.get_survival_curve(),
                          title='Survival curve receiving ANTI treatment',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# question 7
Figs.graph_histogram(
    data=simOutputs.get_cohort_stroke(),
    title='Times of stroke of patients',
    x_label='Number of stroke during life time with NORMAL treatment',
    y_label='numbers',
)
コード例 #7
0
    id=0,
    therapy=Therapies.ANTICOAG)

# simulate the cohort
simOutputs2 = cohort2.simulate()

# print the outcomes of this simulated cohort
print("Problem 5:")
print_outcomes(simOutputs2, 'WITH anticoagulation:', "No")
print("")

# Problem 6
# graph survival curves
PathCls.graph_sample_path(
    sample_path=simOutputs.get_survival_curve(),
    title='Problem 6: Survival curve for WITHOUT anticoagulation',
    x_label='Simulation time step',
    y_label='Number of alive patients'
    )

PathCls.graph_sample_path(
    sample_path=simOutputs2.get_survival_curve(),
    title='Problem 6: Survival curve for WITH anticoagulation',
    x_label='Simulation time step',
    y_label='Number of alive patients'
    )

# Problem 7
# means without
print("Problem 7:")
print_outcomes(simOutputs, 'WITHOUT anticoagulation', "Yes")
print("")