Welcome to methcomp’s documentation!

methcomp.regression.deming(method1, method2, vr=None, sdr=None, bootstrap=1000, x_label='Method 1', y_label='Method 2', title=None, CI=0.95, line_reference=True, line_CI=False, legend=True, color_points='#000000', color_deming='#008bff', point_kws=None, square=False, ax=None)[source]

Provide a method comparison using Deming regression.

This is an Axis-level function which will draw the Deming plot onto the current active Axis object unless ax is provided.

Parameters
  • method1 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • method2 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • vr (float) – The assumed known ratio of the (residual) variance of the ys relative to that of the xs. Defaults to 1.

  • sdr (float) – The assumed known standard deviations. Parameter vr takes precedence if both are given. Defaults to 1.

  • bootstrap (int or None) – Amount of bootstrap estimates that should be performed to acquire standard errors (and confidence intervals). If None, no bootstrapping is performed. Defaults to 1000.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the plot. If None is provided, no title will be plotted.

  • CI (float, optional) – The confidence interval employed in Deming line. Defaults to 0.95.

  • line_reference (bool, optional) – If True, a grey reference line at y=x will be plotted in the plot. Defaults to true.

  • line_CI (bool, optional) – If True, dashed lines will be plotted at the boundaries of the confidence intervals. Defaults to false.

  • legend (bool, optional) – If True, will provide a legend containing the computed Deming equation. Defaults to true.

  • color_points (str, optional) – Color of the individual differences that will be plotted. Color should be provided in format compatible with matplotlib.

  • color_deming (str, optional) – Color of the mean difference line that will be plotted. Color should be provided in format compatible with matplotlib.

  • square (bool, optional) – If True, set the Axes aspect to “equal” so each cell will be square-shaped.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the Deming plot.

Return type

matplotlib Axes

See also

Koopmans, T., Haarlem, Netherlands., Deming, W., NY, 1985

methcomp.regression.linear(method1, method2, x_label='Method 1', y_label='Method 2', title=None, CI=0.95, line_reference=True, line_CI=False, legend=True, color_points='#000000', color_regr='#008bff', point_kws=None, square=False, ax=None)[source]

Provide a method comparison using simple, linear regression.

This is an Axis-level function which will draw the linear regression plot onto the current active Axis object unless ax is provided.

Parameters
  • method1 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • method2 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the linear regression plot. If None is provided, no title will be plotted.

  • CI (float, optional) – The confidence interval employed in the linear regression line. Defaults to 0.95.

  • line_reference (bool, optional) – If True, a grey reference line at y=x will be plotted in the plot. Defaults to true.

  • line_CI (bool, optional) – If True, dashed lines will be plotted at the boundaries of the confidence intervals. Defaults to false.

  • legend (bool, optional) – If True, will provide a legend containing the computed Linear regression equation. Defaults to true.

  • color_points (str, optional) – Color of the individual differences that will be plotted. Color should be provided in format compatible with matplotlib.

  • color_paba (str, optional) – Color of the mean difference line that will be plotted. Color should be provided in format compatible with matplotlib.

  • square (bool, optional) – If True, set the Axes aspect to “equal” so each cell will be square-shaped.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the linear regression plot.

Return type

matplotlib Axes

See also

methcomp.regression.passingbablok(method1, method2, x_label='Method 1', y_label='Method 2', title=None, CI=0.95, line_reference=True, line_CI=False, legend=True, color_points='#000000', color_paba='#008bff', point_kws=None, square=False, ax=None)[source]

Provide a method comparison using Passing-Bablok regression.

This is an Axis-level function which will draw the Passing-Bablok plot onto the current active Axis object unless ax is provided.

Parameters
  • method1 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • method2 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the Passing-Bablok plot. If None is provided, no title will be plotted.

  • CI (float, optional) – The confidence interval employed in the passing-bablok line. Defaults to 0.95.

  • line_reference (bool, optional) – If True, a grey reference line at y=x will be plotted in the plot. Defaults to true.

  • line_CI (bool, optional) – If True, dashed lines will be plotted at the boundaries of the confidence intervals. Defaults to false.

  • legend (bool, optional) – If True, will provide a legend containing the computed Passing-Bablok equation. Defaults to true.

  • color_points (str, optional) – Color of the individual differences that will be plotted. Color should be provided in format compatible with matplotlib.

  • color_paba (str, optional) – Color of the mean difference line that will be plotted. Color should be provided in format compatible with matplotlib.

  • square (bool, optional) – If True, set the Axes aspect to “equal” so each cell will be square-shaped.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the Passing-Bablok plot.

Return type

matplotlib Axes

See also

Passing, vol., no., 1983, pp.

methcomp.blandaltman.blandaltman(method1, method2, x_label='Mean of methods', y_label='Difference between methods', title=None, diff='absolute', limit_of_agreement=1.96, reference=False, CI=0.95, xlim=None, ylim=None, color_mean='#008bff', color_loa='#FF7000', color_points='#000000', point_kws=None, ax=None)[source]

Provide a method comparison using Bland-Altman plotting.

This is an Axis-level function which will draw the Bland-Altman plot onto the current active Axis object unless ax is provided.

Parameters
  • method1 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • method2 (array, or list) – Values obtained from both methods, preferably provided in a np.array.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the Bland-Altman plot. If None is provided, no title will be plotted.

  • diff ("absolute" or "percentage") – The difference to display, whether it is an absolute one or a percentual one. If None is provided, it defaults to absolute.

  • limit_of_agreement (float, optional) – Multiples of the standard deviation to plot the limit of afgreement bounds at. This defaults to 1.96.

  • reference (bool, optional) – If True, a grey reference line at y=0 will be plotted in the Bland-Altman.

  • CI (float, optional) – The confidence interval employed in the mean difference and limit of agreement lines. Defaults to 0.95.

  • xlim (list, optional) – Minimum and maximum limits for X-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • ylim (list, optional) – Minimum and maximum limits for Y-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • color_mean (str, optional) – Color of the mean difference line that will be plotted.

  • color_loa (str, optional) – Color of the limit of agreement lines that will be plotted.

  • color_points (str, optional) – Color of the individual differences that will be plotted.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the Bland-Altman plot.

Return type

matplotlib Axes

See also

pyCompare, Altman, D., and, J., vol., no., 1983, pp., Altman, D., and, J., vol., no., 1999, pp.

methcomp.glucose.clarke(reference, test, units, x_label=None, y_label=None, title=None, xlim=None, ylim=None, color_grid='#000000', color_gridlabels='auto', color_points='auto', grid=True, percentage=False, point_kws=None, grid_kws=None, square=False, ax=None)[source]

Provide a glucose error grid analyses as designed by Clarke.

This is an Axis-level function which will draw the Clarke-error grid plot. onto the current active Axis object unless ax is provided.

Parameters
  • reference (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • test (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • units (str) – The SI units which the glucose values are provided in. Options: ‘mmol’, ‘mgdl’ or ‘mg/dl’.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the Clarke error grid plot. If None is provided, no title will be plotted.

  • xlim (list, optional) – Minimum and maximum limits for X-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • ylim (list, optional) – Minimum and maximum limits for Y-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • color_grid (str, optional) – Color of the Clarke error grid lines.

  • color_gridlabels (str, optional) – Color of the gridlabels (A, B, C, ..) that will be plotted. If set to ‘auto’, it will plot the points according to their zones.

  • color_points (str, optional) – Color of the individual differences that will be plotted. If set to ‘auto’, it will plot the points according to their zones.

  • grid (bool, optional) – Enable the grid lines of the Parkes error. Defaults to True.

  • percentage (bool, optional) – If True, percentage of the zones will be depicted in the plot.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • grid_kws (dict of key, value mappings, optional) – Additional keyword arguments for the grid with plt.plot.

  • square (bool, optional) – If True, set the Axes aspect to “equal” so each cell will be square-shaped.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the Clarke-error grid plot.

Return type

matplotlib Axes

See also

Clarke, W., Cox, D., et, vol., no., 1987, pp.

methcomp.glucose.clarkezones(reference, test, units, numeric=False)[source]

Provides the error zones as depicted by the Clarke error grid analysis for each point in the reference and test datasets.

Parameters
  • reference (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • test (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • units (str) – The SI units which the glucose values are provided in. Options: ‘mmol’, ‘mgdl’ or ‘mg/dl’.

  • numeric (bool, optional) – If this is set to true, returns integers (0 to 4) instead of characters for each of the zones.

Returns

clarkezones – Returns a list depecting the zones for each of the reference and test values.

Return type

list

methcomp.glucose.parkes(type, reference, test, units, x_label=None, y_label=None, title=None, xlim=None, ylim=None, color_grid='#000000', color_gridlabels='auto', color_points='auto', grid=True, percentage=False, point_kws=None, grid_kws=None, square=False, ax=None)[source]

Provide a glucose error grid analyses as designed by Parkes.

This is an Axis-level function which will draw the Parke-error grid plot. onto the current active Axis object unless ax is provided.

Parameters
  • type (int) – Parkes error grid differ for each type of diabetes. This should be either 1 or 2 corresponding to the type of diabetes.

  • reference (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • test (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • units (str) – The SI units which the glucose values are provided in. Options: ‘mmol’, ‘mgdl’ or ‘mg/dl’.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the Parkes-error grid plot. If None is provided, no title will be plotted.

  • xlim (list, optional) – Minimum and maximum limits for X-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • ylim (list, optional) – Minimum and maximum limits for Y-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • color_grid (str, optional) – Color of the Clarke error grid lines. Defaults to #000000 which represents the black color.

  • color_gridlabels (str, optional) – Color of the grid labels (A, B, C, ..) that will be plotted. Defaults to ‘auto’ which colors the points according to their relative zones.

  • color_points (str, optional) – Color of the individual differences that will be plotted. Defaults to ‘auto’ which colors the points according to their relative zones.

  • grid (bool, optional) – Enable the grid lines of the Parkes error. Defaults to True.

  • percentage (bool, optional) – If True, percentage of the zones will be depicted in the plot.

  • square (bool, optional) – If True, set the Axes aspect to “equal” so each cell will be square-shaped.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • grid_kws (dict of key, value mappings, optional) – Additional keyword arguments for the grid with plt.plot.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the Parkes error grid plot.

Return type

matplotlib Axes

See also

Parkes, J., Slatin, vol., no., 2000, pp., Pfutzner, A., Klonoff, et, vol., no., 2013, pp.

methcomp.glucose.parkeszones(type, reference, test, units, numeric=False)[source]

Provides the error zones as depicted by the Parkes error grid analysis for each point in the reference and test datasets.

Parameters
  • type (int) – Parkes error grid differ for each type of diabetes. This should be either 1 or 2 corresponding to the type of diabetes.

  • reference (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • test (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • units (str) – The SI units which the glucose values are provided in. Options: ‘mmol’, ‘mgdl’ or ‘mg/dl’.

  • numeric (bool, optional) – If this is set to true, returns integers (0 to 4) instead of characters for each of the zones.

Returns

parkeszones – Returns a list depicting the zones for each of the reference and test values.

Return type

list

methcomp.glucose.seg(reference, test, units, x_label=None, y_label=None, title=None, xlim=None, ylim=None, color_points='white', percentage=False, point_kws=None, square=False, ax=None)[source]

Provide a glucose error grid analyses as designed by the surveillance error grid.

This is an Axis-level function which will draw the surveillance error grid plot. onto the current active Axis object unless ax is provided.

Parameters
  • reference (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • test (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • units (str) – The SI units which the glucose values are provided in. Options: ‘mmol’, ‘mgdl’ or ‘mg/dl’.

  • x_label (str, optional) – The label which is added to the X-axis. If None is provided, a standard label will be added.

  • y_label (str, optional) – The label which is added to the Y-axis. If None is provided, a standard label will be added.

  • title (str, optional) – Title of the plot. If None is provided, no title will be plotted.

  • xlim (list, optional) – Minimum and maximum limits for X-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • ylim (list, optional) – Minimum and maximum limits for Y-axis. Should be provided as list or tuple. If not set, matplotlib will decide its own bounds.

  • color_points (str, optional) – Color of the individual differences that will be plotted. Defaults to ‘white’.

  • percentage (bool, optional) – If True, percentage of the zones will be depicted in the plot.

  • point_kws (dict of key, value mappings, optional) – Additional keyword arguments for plt.scatter.

  • square (bool, optional) – If True, set the Axes aspect to “equal” so each cell will be square-shaped.

  • ax (matplotlib Axes, optional) – Axes in which to draw the plot, otherwise use the currently-active Axes.

Returns

ax – Axes object with the Surveillance error grid plot.

Return type

matplotlib Axes

See also

Klonoff, D., Lias, C., et, vol., no., 2014, pp, Kovatchev, B., Wakeman, C., et, vol, no., 2014, pp.

methcomp.glucose.segscores(reference, test, units)[source]

Provides the raw error values as depicted by the surveillance error grid analysis for each point in the reference and test datasets.

Parameters
  • reference (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • test (array, or list) – Glucose values obtained from the reference and predicted methods, preferably provided in a np.array.

  • units (str) – The SI units which the glucose values are provided in. Options: ‘mmol’, ‘mgdl’ or ‘mg/dl’.

Returns

segscores – Returns a list with a SEG score for each test, reference pair.

Return type

list

Indices and tables