예제 #1
0
def weights(t):
    #must accept one arguement, even though it is not used here
    s = KaplanMeier(dta, 0, censoring=2)
    s.fit()
    s = s.results[0][0]
    s = s * (1 - s)
    return s
예제 #2
0
def weights(t):
    #must accept one arguement, even though it is not used here
    s = KaplanMeier(dta,0,censoring=2)
    s.fit()
    s = s.results[0][0]
    s = s * (1 - s)
    return s
예제 #3
0
def competing_risk(data, outcome, tt_outcome, use_kmf):
    """Gets the probability of the event for all subjects

    Notes
    -----
    This is used for the net benefit associated with treating all patients

    Parameters
    ----------
    data : pd.DataFrame
        the dataset to analyze
    outcome : str
        the column in `data` with outcome values
    tt_outcome : str
        the column in `data` with times to the outcome values 
    use_kmf : bool
        the algorithm to use for fitting the survival curve
        if `True`, use KaplanMeier; if `False`, use cumulative increase
    
    Returns
    -------

    """
    raise NotImplementedError()
    #construct a new dataframe of just the outcome and tt_outcome columns
    df = pd.DataFrame({outcome: data[outcome].values, 
                       tt_outcome: data[tt_outcome].values})
    if use_kmf:
        from statsmodels.sandbox.survival2 import KaplanMeier
        kmf = KaplanMeier(df.values, 1)
        kmf.fit()
    else:  # use cuminc
        pass
예제 #4
0
import statsmodels.api as sm
import matplotlib.pyplot as plt
import numpy as np
from statsmodels.sandbox.survival2 import KaplanMeier

#Getting the strike data as an array
dta = sm.datasets.strikes.load(as_pandas=False)
print('basic data')
print('\n')
dta = list(dta.values()[-1])
print(dta[lrange(5), :])
print('\n')

#Create the KaplanMeier object and fit the model

km = KaplanMeier(dta, 0)
km.fit()

#show the results

km.plot()
print('basic  model')
print('\n')
km.summary()
print('\n')

#Mutiple survival curves

km2 = KaplanMeier(dta, 0, exog=1)
km2.fit()
print('more than one curve')
예제 #5
0
import statsmodels.api as sm
import matplotlib.pyplot as plt
import numpy as np
from statsmodels.sandbox.survival2 import KaplanMeier

#Getting the strike data as an array
dta = sm.datasets.strikes.load()
print 'basic data'
print '\n'
dta = dta.values()[-1]
print dta[range(5),:]
print '\n'

#Create the KaplanMeier object and fit the model

km = KaplanMeier(dta,0)
km.fit()

#show the results

km.plot()
print 'basic  model'
print '\n'
km.summary()
print '\n'

#Mutiple survival curves

km2 = KaplanMeier(dta,0,exog=1)
km2.fit()
print 'more than one curve'