utils.stats.plot_coeff_vs_pvals

utils.stats.plot_coeff_vs_pvals(
    data,
    xlabels=None,
    xlim=(0, 1),
    xlab='p-value',
    ylim=None,
    ylab=None,
    xscale_log=True,
    yscale_log=False,
    title=None,
    show=True,
    y_scaler=1.1,
)

Plot the coefficient estimates from fit_all_lm against the corresponding p-values.

Parameters

Name Type Description Default
data dict A dictionary containing the estimated coefficients, p-values, and other information. Generated by the fit_all_lm function. required
xlabels list A list of x-axis labels. None
xlim tuple A tuple of the x-axis limits. (0, 1)
xlab str The x-axis label. 'p-value'
ylim tuple A tuple of the y-axis limits. None
ylab str The y-axis label. None
xscale_log bool Whether to use a log scale on the x-axis. True
yscale_log bool Whether to use a log scale on the y-axis. False
title str The plot title. None
show bool Whether to display the plot. True
y_scaler float A scaling factor for the y-axis limits. Default is 1.1, i.e., 10% more than the maximum value. 1.1

Returns

Name Type Description
None None

Notes

  • Based on the R package ‘allestimates’ by Zhiqiang Wang, see https://cran.r-project.org/package=allestimates

References

Wang, Z. (2007). Two Postestimation Commands for Assessing Confounding Effects in Epidemiological Studies. The Stata Journal, 7(2), 183-196. https://doi.org/10.1177/1536867X0700700203

Examples

>>> from spotpython.utils.stats import plot_coeff_vs_pvals, fit_all_lm
>>> import pandas as pd
>>> data = pd.DataFrame({
>>>     'y': [1, 2, 3],
>>>     'x1': [4, 5, 6],
>>>     'x2': [7, 8, 9]
>>> })
>>> estimates = fit_all_lm("y ~ x1", ["x2"], data)
>>> plot_coeff_vs_pvals(estimates)