
    >hF                     *    S r SSKrSSKJr    SS jrg)zE
Bland-Altman mean-difference plots

Author: Joses Ho
License: BSD-3
    N   )utilsc           	      |   [         R                  " U5      u  ps[        U 5      [        U5      :w  a  [        S5      eUS:  a  [        SU S35      e[        R
                  " X/SS9nX-
  n	[        R
                  " U	5      n
[        R                  " U	SS9nU=(       d    0 nSU;  a  SUS'   U=(       d    0 nU=(       d    0 nXV4 H  nSU;  a  S	US'   S
U;  d  M  SUS
'   M     SU;  a  SWS'   SU;  a  SWS'   UR                  " X40 UD6  UR                  " U
40 UD6  UR                  S[        R                  " U
S5       3SSSSSS9  US:  a  SU-  U-  nUR                  X-
  X-   5        X+-  nX-
  nX-   n[        UU/5       H  u  nnUR                  " U40 UD6  M     UR                  SU SUS 3SSSSSS9  UR                  SU SUS 3SSSSS9  O!US:X  a  S U-  nUR                  X-
  X-   5        UR                  S!S"S#9  UR                  S$S"S#9  UR                  S%S&9  UR!                  5         U$ )'a  
Construct a Tukey/Bland-Altman Mean Difference Plot.

Tukey's Mean Difference Plot (also known as a Bland-Altman plot) is a
graphical method to analyze the differences between two methods of
measurement. The mean of the measures is plotted against their difference.

For more information see
https://en.wikipedia.org/wiki/Bland-Altman_plot

Parameters
----------
m1 : array_like
    A 1-d array.
m2 : array_like
    A 1-d array.
sd_limit : float
    The limit of agreements expressed in terms of the standard deviation of
    the differences. If `md` is the mean of the differences, and `sd` is
    the standard deviation of those differences, then the limits of
    agreement that will be plotted are md +/- sd_limit * sd.
    The default of 1.96 will produce 95% confidence intervals for the means
    of the differences. If sd_limit = 0, no limits will be plotted, and
    the ylimit of the plot defaults to 3 standard deviations on either
    side of the mean.
ax : AxesSubplot
    If `ax` is None, then a figure is created. If an axis instance is
    given, the mean difference plot is drawn on the axis.
scatter_kwds : dict
    Options to to style the scatter plot. Accepts any keywords for the
    matplotlib Axes.scatter plotting method
mean_line_kwds : dict
    Options to to style the scatter plot. Accepts any keywords for the
    matplotlib Axes.axhline plotting method
limit_lines_kwds : dict
    Options to to style the scatter plot. Accepts any keywords for the
    matplotlib Axes.axhline plotting method

Returns
-------
Figure
    If `ax` is None, the created figure.  Otherwise the figure to which
    `ax` is connected.

References
----------
Bland JM, Altman DG (1986). "Statistical methods for assessing agreement
between two methods of clinical measurement"

Examples
--------

Load relevant libraries.

>>> import statsmodels.api as sm
>>> import numpy as np
>>> import matplotlib.pyplot as plt

Making a mean difference plot.

>>> # Seed the random number generator.
>>> # This ensures that the results below are reproducible.
>>> np.random.seed(9999)
>>> m1 = np.random.random(20)
>>> m2 = np.random.random(20)
>>> f, ax = plt.subplots(1, figsize = (8,5))
>>> sm.graphics.mean_diff_plot(m1, m2, ax = ax)
>>> plt.show()

.. plot:: plots/graphics-mean_diff_plot.py
z'm1 does not have the same length as m2.r   z
sd_limit (z) is less than 0.)axiss   colorgray	linewidthr   	linestylez--:zmean diff:
   )Gz?g      ?rightcenter   zaxes fraction)xyhorizontalalignmentverticalalignmentfontsizexycoordsg      ?-z SD: z0.2g)r   gQ?bottom+)r   gq=
ףp?)r   r   r   r      
Difference   )r   Means   )	labelsize)r   create_mpl_axlen
ValueErrornpmeanstdscatteraxhlineannotateroundset_ylim	enumerate
set_ylabel
set_xlabeltick_paramstight_layout)m1m2sd_limitaxscatter_kwdsmean_line_kwdslimit_lines_kwdsfigmeansdiffs	mean_diffstd_diffkwds	half_ylimlimit_of_agreementlowerupperjlims                      qC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\statsmodels/graphics/agreement.pymean_diff_plotrE      s   R !!"%GC
2w#b'BCC!|:hZ/@ABBGGRH1%EGEIvve!$H%2L
,S#)rN'-22$"DMd" !D	 3
 .( [**[JJu,|,JJy+N+ KK,rxx	1567$+"*(  * !|8^x/	
I))	+%0../FAsJJs/./ 0
azuTl3#(/&., 	 	. 	azuTl3#(/,	 	 	. 
QL	
I))	+ MM,M,MM'BM'NNRN J    )g\(\?NNNN)__doc__numpyr$    r   rE    rF   rD   <module>rK      s"      AE9=MrF   