Estimators SubPackage
This subpackage implements the various estimators
transitionMatrix.estimators.simple_estimator module
- class transitionMatrix.estimators.simple_estimator.SimpleEstimator(states=None, ci=None)[source]
Bases:
BaseEstimatorClass for implementing a simple estimator suitable for single period transitions
This is useful for testing, getting a first feel about the transition landscape.
- fit(data)[source]
- Parameters:
data (array-like) – The data to use for the estimation
- Returns:
matrix (estimated transition matrix)
confint_lower (lower confidence interval)
confint_upper (upper confidence interval)
Notes
loop over data rows
expected format is (id, state_in, state_out)
calculate population count N^i_k per state i
calculate migrations count N^{ij}_{kl} from i to j
calculate transition matrix as ratio T^{ij}_{kl} = N^{ij}_{kl} / N^i_k
transitionMatrix.estimators.cohort_estimator module
- class transitionMatrix.estimators.cohort_estimator.CohortEstimator(cohort_bounds=None, states=None, ci=None)[source]
Bases:
BaseEstimatorClass for implementing a Cohort Estimator for the transition matrix
Documentation: Cohort Estimator
- fit(data, labels=None)[source]
- Parameters:
data (dataframe - The data to use for the estimation (in sorted by ID in compact format))
labels (an optional dictionary for relabeling column names)
- Returns:
matrix_set
- Return type:
An estimated transition matrix set
Notes
loop over data rows (id, timepoint, state)
at least two distinct timepoints are required (initial and final)
calculate population count N^i_k per state i per timepoint k
calculate migrations count N^{ij}_{kl} from i to j from timepoint k to timepoint l
calculate transition matrix as ratio T^{ij}_{kl} = N^{ij}_{kl} / N^i_k
calculate also count-averaged matrix
References
transitionMatrix.estimators.aalen_johansen_estimator module
- class transitionMatrix.estimators.aalen_johansen_estimator.AalenJohansenEstimator(states=None)[source]
Bases:
DurationEstimatorClass for implementing the Aalen-Johansen estimator for the transition matrix
Documentation: Aalen-Johansen Estimator
- fit(data, labels=None)[source]
- Parameters:
data (dataframe - The data to use for the estimation provided in a pandas data frame in long format,with one row per observed transition. The data frame must contain the following columns (or pass a label object that will assign accordingly:) –
ID: A unique entity identification number
TIME Time when a transition occurs
FROM: State from where a transition occurs
TO: State to which a transition occurs
labels (an optional dictionary for relabeling column names if those deviate from the convention) –
TODO constraint possible transitions (absorbing states)
TODO censored data
TODO partial dates
TODO covariance calculation
TODO confidence intervals
- Returns:
etm.values (estimated empirical transition matrix throughout the observed interval. This is a three dimensional array object (From State, To State, Timepoint))
observation_times (a list of observation times etm.observation_times)
TODO Store counts as well as frequencies
TODO Optional Binning of close observation times
Note
The input data MUST be pre-sorted in ascending time order. This is easily done using pandas functionality.
References
transitionMatrix.estimators.kaplan_meier_estimator module
Todo
This is future functionality