generate_contin_table_with_clustered_AE_with_tol#
- MDDC.utils.generate_contin_table_with_clustered_AE_with_tol(row_marginal, column_marginal, signal_mat, tol=0.1, contin_table=None, cluster_idx=None, n=100, rho=None, n_jobs=-1)#
Generate simulated contingency tables with the option of incorporating adverse event correlation within clusters and tolerance for total report count.
This function generates multiple simulated contingency tables based on the input row and column marginals, or contin_table, signal strength matrix (signal_mat), and cluster indices (cluster_idx). It incorporates adverse event correlation within each cluster according to the specified correlation parameter (rho).
Parameters:#
- row_marginallist, np.ndarray, None
Marginal sums for the rows of the contingency table.
- column_marginallist, np.ndarray, None
Marginal sums for the columns of the contingency table.
- signal_matnumpy.ndarray, pandas.DataFrame
A data matrix of the same dimensions as contin_table, where entries represent signal strength. Values should be greater than or equal to 1, where 1 indicates no signal and values greater than 1 indicate the presence of a signal.
- tolfloat, optional, default=0.1
Tolerance for the total report count, expressed in terms of the Relative Total Difference (RTD), defined as:
\[RTD = \frac{|n^{orig}_{\cdot \cdot} - n^{sim}_{\cdot \cdot}|}{n^{orig}_{\cdot \cdot}} \times 100\]This indicates the difference in the total number of reports in the simulated datasets and the original input total number of reports. Sufficiently low values of tolerance will return generated tables with total number of reports equal to the actual supplied value.
- contin_tablenumpy.ndarray, pandas.DataFrame, default=None
A data matrix representing an I x J contingency table with row (adverse event) and column (drug) names. The row and column marginals of this table are used to generate the simulated data. It is advisable to check the input contingency table using the function check_and_fix_contin_table() before using this function.
- cluster_idxnumpy.ndarray, list, pd.DataFrame
An array indicating the cluster index for each row in the contin_table. Clusters can be represented by names or numerical indices.
- nint, optional, default=100
The number of simulated contingency tables to generate.
- rhofloat, optional, numpy.ndarray, default=None
If a float or int, rho represents the correlation value to be used between elements within each cluster specified by cluster_idx.
If a numpy.ndarray, rho must be a square matrix with dimensions equal to the number of rows in contin_table. In this case the cluster_idx is not used.
If None, a covariance matrix is generated based on the correlation coefficients of contin_table.
- n_jobsint, optional, default=-1
n_jobs specifies the maximum number of concurrently running workers. If 1 is given, no joblib parallelism is used at all, which is useful for debugging. For more information on joblib n_jobs refer to - https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html.
Returns:#
- simulated tableslist of numpy.ndarray
A list containing the simulated contingency tables.