Esempio n. 1
0
def test_null_pem_model(**kwargs):
    ''' Test weibull survival model on simulated dataset
    '''
    d = load_test_dataset(n=20)
    dlong = survivalstan.prep_data_long_surv(df=d, time_col='t', event_col='event')
    testfit = survivalstan.fit_stan_survival_model(
        model_cohort = 'test model',
        model_code = model_code,
        df = dlong,
        sample_col = 'index',
        timepoint_end_col = 'end_time',
        event_col = 'end_failure',
        formula = '~ 1',
        iter = num_iter,
        chains = 2,
        seed = 9001,
        make_inits = make_inits,
        FIT_FUN = stancache.cached_stan_fit,
        **kwargs
        )
    ok_('fit' in testfit)
    ok_('coefs' in testfit)
    ok_('loo' in testfit)
    survivalstan.utils.plot_coefs([testfit])
    survivalstan.utils.plot_coefs([testfit], trans=np.exp)
    survivalstan.utils.plot_coefs([testfit], element='baseline')

    survivalstan.utils.plot_pp_survival([testfit])
    survivalstan.utils.plot_observed_survival(df=d, time_col='t', event_col='event')
    fitsum = survivalstan.utils.filter_stan_summary([testfit], pars='baseline')
    fitsum = survivalstan.utils.filter_stan_summary(testfit['fit'], remove_nan=True)
    survivalstan.utils.print_stan_summary([testfit], pars='lp__')
    survivalstan.utils.plot_stan_summary([testfit], pars='log_baseline_raw')
    return(testfit)
Esempio n. 2
0
def load_test_dataset_long(n=20):
    ''' Load test dataset from R survival package
    '''
    d = load_test_dataset(n=n)
    dlong = survivalstan.prep_data_long_surv(d,
                                             time_col='t',
                                             event_col='event')
    return dlong
def sim_test_dataset_long(n=200):
    data = survivalstan.sim.sim_data_jointmodel(N=n)
    ldf = survivalstan.prep_data_long_surv(data['events'],
                                           event_col='event_value',
                                           event_name='event_name',
                                           time_col='time',
                                           sample_col='subject_id')
    ldf = pd.merge(ldf, data['covars'], on='subject_id', how='outer')
    return (ldf)
def sim_test_dataset_long(n=200):
    data = survivalstan.sim.sim_data_jointmodel(N=n)
    ldf = survivalstan.prep_data_long_surv(data['events'],
                                           event_col='event_value',
                                           event_name='event_name',
                                           time_col='time',
                                           sample_col='subject_id')
    ldf = pd.merge(ldf, data['covars'], on='subject_id', how='outer')
    return(ldf)
Esempio n. 5
0
def sim_test_dataset_long(n=20):
    d = sim_test_dataset(n=n)
    dlong = survivalstan.prep_data_long_surv(d, time_col='t', event_col='event')
    return dlong
Esempio n. 6
0
def load_test_dataset_long(n=20):
    ''' Load test dataset from R survival package
    '''
    d = load_test_dataset(n=n)
    dlong = survivalstan.prep_data_long_surv(d, time_col='t', event_col='event')
    return dlong
Esempio n. 7
0
def sim_test_dataset_long(n=20):
    d = sim_test_dataset(n=n)
    dlong = survivalstan.prep_data_long_surv(d,
                                             time_col='t',
                                             event_col='event')
    return dlong