
    >hm                         S SK rS SKrS SKJrJr  S SKJr    SS jr	SS jr
S r " S S5      r " S	 S
5      r  SS jrSS jrSS jrg)    N)chi2norm)utilsc                 t   Uc  [         R                  " U SS9u  pgO<[         R                  " X45      n[         R                  " USS9u  pgUS[        U 5       n[        U5      n	Uc  [         R                  " XqU	S9n
O[         R                  " XqU-  U	S9n
Uc  [         R                  " XyS9nO[         R                  " XrU	S9nUby  [         R
                  " U5      U-
  n[         R                  " XcSS9nUc  [         R                  " XS9nO[         R                  " XU	S9n[         R
                  " U5      U-
  nX-
  nO"[         R
                  " USSS	2   5      SSS	2   nU(       a%  [         R                  " U
S:  5      nX   n
X   nXn   nS
XR                  [         R                  5      -  -
  nUS:  nSX'   [         R                  " U5      n[         R
                  " U5      n[         R                  " U5      nSX'   U(       d  XX{U
4$ Uc  XU
-
  -  n[         R                  " US[         R                  5      nU
UR                  [         R                  5      -  n[         R                  UX:H  US:H  -  '   [         R
                  " U5      n[         R                  " U5      n[         R                   " U5      US:g  -  nUU==   UU   -  ss'   [         R                  UU) '   OPXU-  R                  [         R                  5      -  n[         R
                  " U5      n[         R                  " U5      nUUXgX4$ )zL
Calculate the survival function and its standard error for a single
group.
NTreturn_inverser   weights	minlengthr   leftside   gؗҜ<g-q=)npuniqueconcatenatelenbincountcumsumsearchsortedflatnonzeroastypefloat64logexpclipinfnansqrtisfinite)timestatusr
   entrycompressretallutimertimetxmldnrentryn0iispdenomselocss                      pC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\statsmodels/duration/survfunc.py_calc_survfunc_rightr6      s    }yyd;u^^TM*yyD9aD	" 
UBKK<KKg~D KK,KK"=IIaL1F;?V2BVCBYYr]RFIIa"gtt$ ^^AE"EE	 
Q"**%%	%B	eBBF	B	2B	BBF%A%% Uubff-bjj))"$&&AFqAvYYr]WWR[{{2"'*
4BtHFFD5	 a%

++YYr]WWR[r5%%    c                    US:  R                  [        R                  5      n[        XUSSS9u  pEpgn[	        UR                  5       5      n	/ n[        U	5       H{  n
XS-   :H  R                  [        R                  5      nUc  [        R                  " Xc[        U5      S9nO![        R                  " XcU-  [        U5      S9nUR                  U5        M}     / n[        R                  SUSS 4   U-  n[        U	5       H/  n
[        R                  " XU
   -  5      nUR                  U5        M1     Ub  USU4$ / n[        U5      n[        U	5       GH  n
UXwU-
  -  -  nX   S-  [        R                  " U5      -  nUSX   -  [        R                  " X   U-  5      -  -  nU[        R                  " X   S-  U-  5      -  nXxU
   -
  X   -  U-  nU[        R                  " US-  U-  5      -  nXU
   -  U-  nUSX   -  [        R                  " U5      -  -  nUS[        R                  " X   U-  5      -  -  nUR                  [        R                  " U5      5        GM     XU4$ )zE
Calculate the cumulative incidence function and its standard error.
r   F)r&   r'   Nr	   r      )r   r   r   r6   intmaxranger   r   appendr_r   sumr!   )r#   r$   r
   status0r1   r(   r)   r-   r,   ngrpkd0ipsp0ip0r3   daravs                      r5   _calc_incidence_rightrJ   V   s=    {""2::.G1$;@PBu vzz|D 	A4[U?**2::6?Us5zJBUGO'*5z3B	  
B
%%2cr7

a
C4[iid
#
		# 
 4	B	QB4[1B< E1Hryy}$	QY252:...	RYYruax"}%%A$h!$"	RYYsAv{##Q4Z!^	QY2&&	Q252:&&&
		"''!*   5=r7   c                    [        U 5      [        U5      :w  a  [        S5      eUb%  [        U5      [        U 5      :w  a  Sn[        U5      eUb*  [        R                  " X :  5      (       a  Sn[        U5      eUb#  [        U5      [        U 5      :w  a  [        S5      eUb(  UR                  S   [        U 5      :w  a  [        S5      eg g )Nz)time and status must have the same lengthz5entry times and event times must have the same lengthz2Entry times must not occur on or after event timesz2weights, time and status must have the same lengthr   z'the rows of exog should align with time)r   
ValueErrorr   anyshape)r#   r$   r%   freq_weightsexogmsgs         r5   
_checkargsrR      s    
4yCKDEEc%jCI5EoRVVEM22BoS%6#d)%CMNNTZZ]c$i7BCC 8r7   c                   &    \ rS rSrSr  SS jrSrg)CumIncidenceRight   a	  
Estimation and inference for a cumulative incidence function.

If J = 1, 2, ... indicates the event type, the cumulative
incidence function for cause j is:

I(t, j) = P(T <= t and J=j)

Only right censoring is supported.  If frequency weights are provided,
the point estimate is returned without a standard error.

Parameters
----------
time : array_like
    An array of times (censoring times or event times)
status : array_like
    If status >= 1 indicates which event occurred at time t.  If
    status = 0, the subject was censored at time t.
title : str
    Optional title used for plots and summary output.
freq_weights : array_like
    Optional frequency weights
exog : array_like
    Optional, if present used to account for violation of
    independent censoring.
bw_factor : float
    Band-width multiplier for kernel-based estimation.  Only
    used if exog is provided.
dimred : bool
    If True, proportional hazards regression models are used to
    reduce exog to two columns by predicting overall events and
    censoring in two separate models.  If False, exog is used
    directly for calculating kernel weights without dimension
    reduction.

Attributes
----------
times : array_like
    The distinct times at which the incidence rates are estimated
cinc : list of arrays
    cinc[k-1] contains the estimated cumulative incidence rates
    for outcome k=1,2,...
cinc_se : list of arrays
    The standard errors for the values in `cinc`.  Not available when
    exog and/or frequency weights are provided.

Notes
-----
When exog is provided, a local estimate of the cumulative incidence
rate around each point is provided, and these are averaged to
produce an estimate of the marginal cumulative incidence
functions.  The procedure is analogous to that described in Zeng
(2004) for estimation of the marginal survival function.  The
approach removes bias resulting from dependent censoring when the
censoring becomes independent conditioned on the columns of exog.

References
----------
The Stata stcompet procedure:
    http://www.stata-journal.com/sjpdf.html?articlenum=st0059

Dinse, G. E. and M. G. Larson. 1986. A note on semi-Markov models
for partially censored data. Biometrika 73: 379-386.

Marubini, E. and M. G. Valsecchi. 1995. Analysing Survival Data
from Clinical Trials and Observational Studies. Chichester, UK:
John Wiley & Sons.

D. Zeng (2004).  Estimating marginal survival function by
adjusting for dependent censoring using many covariates.  Annals
of Statistics 32:4.
https://arxiv.org/pdf/math/0409180.pdf
Nc                   ^ [        XS US 5        [        R                  " U5      =ol        [        R                  " U5      =o l        Ub  [        R                  " U5      =o@l        Ub_  SSKJn  [        R                  " U5      =oPl        UR                  S   n	U	S-  U-  mU4S jn
U" XXZUU5      nUS   U l
        US   U l        g [        XU5      nUS   U l        US   U l        US   U l
        U(       d  SU l        g UU l        g )Nr   )_kernel_cumincidencer   UUUUUUտc                 b   > [         R                  " U S-  * TS-  -  5      R                  S5      $ Nr9   r   r   r   r?   xkws    r5   <lambda>,CumIncidenceRight.__init__.<locals>.<lambda>   '    bffadURU]377:r7   r9    )rR   r   asarrayr#   r$   rO   _kernel_estimatesrW   rP   rN   timescincrJ   cinc_setitle)selfr#   r$   rh   rO   rP   	bw_factordimredrW   nobskfuncr]   r^   s               @r5   __init__CumIncidenceRight.__init__   s     	4|T:::d++y!zz&11#/1zz,/GGL,?!zz$//D9::a=D)+B:E$T4%+-A1DJ!DI!$=aD	tqT
$R
%
r7   )rf   rg   rP   rO   r$   r#   re   rh   )NNN      ?T)__name__
__module____qualname____firstlineno____doc__rn   __static_attributes__ r7   r5   rT   rT      s    HT ?C150r7   rT   c                   P    \ rS rSrSr  SS jrSS jrS rSS jrS r	SS	 jr
S
rg)SurvfuncRighti  a"	  
Estimation and inference for a survival function.

The survival function S(t) = P(T > t) is the probability that an
event time T is greater than t.

This class currently only supports right censoring.

Parameters
----------
time : array_like
    An array of times (censoring times or event times)
status : array_like
    Status at the event time, status==1 is the 'event'
    (e.g. death, failure), meaning that the event
    occurs at the given value in `time`; status==0
    indicates that censoring has occurred, meaning that
    the event occurs after the given value in `time`.
entry : array_like, optional An array of entry times for handling
    left truncation (the subject is not in the risk set on or
    before the entry time)
title : str
    Optional title used for plots and summary output.
freq_weights : array_like
    Optional frequency weights
exog : array_like
    Optional, if present used to account for violation of
    independent censoring.
bw_factor : float
    Band-width multiplier for kernel-based estimation.  Only used
    if exog is provided.

Attributes
----------
surv_prob : array_like
    The estimated value of the survivor function at each time
    point in `surv_times`.
surv_prob_se : array_like
    The standard errors for the values in `surv_prob`.  Not available
    if exog is provided.
surv_times : array_like
    The points where the survival function changes.
n_risk : array_like
    The number of subjects at risk just before each time value in
    `surv_times`.  Not available if exog is provided.
n_events : array_like
    The number of events (e.g. deaths) that occur at each point
    in `surv_times`.  Not available if exog is provided.

Notes
-----
If exog is None, the standard Kaplan-Meier estimator is used.  If
exog is not None, a local estimate of the marginal survival
function around each point is constructed, and these are then
averaged.  This procedure gives an estimate of the marginal
survival function that accounts for dependent censoring as long as
the censoring becomes independent when conditioning on the
covariates in exog.  See Zeng et al. (2004) for details.

References
----------
D. Zeng (2004).  Estimating marginal survival function by
adjusting for dependent censoring using many covariates.  Annals
of Statistics 32:4.
https://arxiv.org/pdf/math/0409180.pdf
Nc                   ^ [        XX5U5        [        R                  " U5      =ol        [        R                  " U5      =o l        Ub  [        R                  " U5      =oPl        Ub  [        R                  " U5      =o0l        Ubl  Ub  [        S5      eSSKJ	n  [        R                  " U5      =o`l
        UR                  S   n	U	S-  U-  mU4S jn
U" XXjU5      nUS   U l        US   U l        g [        XUUS9nUS   U l        US   U l        US   U l        US	   U l        US
   U l        U(       d  SU l        g UU l        g )Nz%exog and entry cannot both be presentr   )_kernel_survfuncr   rX   c                 b   > [         R                  " U S-  * TS-  -  5      R                  S5      $ rZ   r[   r\   s    r5   r_   (SurvfuncRight.__init__.<locals>.<lambda>^  ra   r7   )r
   r%   r9         rb   )rR   r   rc   r#   r$   rO   r%   rL   rd   r{   rP   rN   	surv_prob
surv_timesr6   surv_prob_sen_riskn_eventsrh   )ri   r#   r$   r%   rh   rO   rP   rj   r{   rl   rm   r]   r^   s               @r5   rn   SurvfuncRight.__init__K  s9    	4d;::d++y!zz&11#/1zz,/GGL,!#E!22EJ  !HII;!zz$//D9::a=D)+B:E tLIAqTDNdDO |',. 1aDA$d!$R
%
r7   c                     [        X5      $ )a  
Plot the survival function.

Examples
--------
Change the line color:

>>> import statsmodels.api as sm
>>> data = sm.datasets.get_rdataset("flchain", "survival").data
>>> df = data.loc[data.sex == "F", :]
>>> sf = sm.SurvfuncRight(df["futime"], df["death"])
>>> fig = sf.plot()
>>> ax = fig.get_axes()[0]
>>> li = ax.get_lines()
>>> li[0].set_color('purple')
>>> li[1].set_color('purple')

Do not show the censoring points:

>>> fig = sf.plot()
>>> ax = fig.get_axes()[0]
>>> li = ax.get_lines()
>>> li[1].set_visible(False)
)plot_survfunc)ri   axs     r5   plotSurvfuncRight.plotn  s    4 T&&r7   c                     [         R                  " U R                  SU-
  :  5      n[        U5      S:X  a  [         R                  $ U R
                  US      $ )z
Estimated quantile of a survival distribution.

Parameters
----------
p : float
    The probability point at which the quantile
    is determined.

Returns the estimated quantile.
r   r   )r   r   r   r   r    r   )ri   pr0   s      r5   quantileSurvfuncRight.quantile  sF     ^^DNNQU23r7a<66Mr!u%%r7   c                    [         R                  " SUS-  -
  5      nUR                  5       nUS:X  a  S nS nOLUS:X  a  S nS nO?US	:X  a  [        R                  nS
 nO%US:X  a  S nS nOUS:X  a  S nS nO[        S5      eU" U R                  5      U" SU-
  5      -
  nXv" U R                  5      U R                  -  -  n[        R                  " [        R                  " U5      U:*  5      n[        U5      S:X  a   [        R                  [        R                  4$ U R                  US      n	US   [        U R                  5      S-
  :X  a  [        R                  n
X4$ U R                  US   S-      n
X4$ )a
  
Returns a confidence interval for a survival quantile.

Parameters
----------
p : float
    The probability point for which a confidence interval is
    determined.
alpha : float
    The confidence interval has nominal coverage probability
    1 - `alpha`.
method : str
    Function to use for g-transformation, must be ...

Returns
-------
lb : float
    The lower confidence limit.
ub : float
    The upper confidence limit.

Notes
-----
The confidence interval is obtained by inverting Z-tests.  The
limits of the confidence interval will always be observed
event times.

References
----------
The method is based on the approach used in SAS, documented here:

  http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_lifetest_details03.htm
r   r9   cloglogc                 X    [         R                  " [         R                  " U 5      * 5      $ Nr   r   r]   s    r5   r_   +SurvfuncRight.quantile_ci.<locals>.<lambda>  s    "&&"&&),r7   c                 :    SU [         R                  " U 5      -  -  $ )Nr   r   r   s    r5   r_   r     s    rQ]3r7   linearc                     U $ r   rw   r   s    r5   r_   r     s    !r7   c                     gNr   rw   r   s    r5   r_   r     s    qr7   r   c                     SU -  $ r   rw   r   s    r5   r_   r     s    q1ur7   logitc                 :    [         R                  " U SU -
  -  5      $ r   r   r   s    r5   r_   r     s    "&&a!e-r7   c                     SU SU -
  -  -  $ r   rw   r   s    r5   r_   r     s    qAQK0r7   asinsqrtc                 V    [         R                  " [         R                  " U 5      5      $ r   )r   arcsinr!   r   s    r5   r_   r     s    "))BGGAJ/r7   c                 n    SS[         R                  " U 5      -  [         R                  " SU -
  5      -  -  $ )Nr   r9   )r   r!   r   s    r5   r_   r     s&    qA
NRWWQU^$CDr7   zunknown methodr   r   )r   ppflowerr   r   rL   r   r   r   absr   r    r   r   )ri   r   alphamethodtrggprimerr0   lbubs              r5   quantile_ciSurvfuncRight.quantile_ci  s\   F XXa%!)m$Y,A3FxA Fu_A$Fw-A0Fz!/ADF-..dnn!a%(	fT^^$t'8'889^^BFF1IO,r7a<66266>!__RU#b6S)A--B v B!,Bvr7   c                     [         R                  " U R                  S9nSUR                  l        U R
                  US'   U R                  US'   U R                  US'   U R                  US'   U$ )z
Return a summary of the estimated survival function.

The summary is a dataframe containing the unique event times,
estimated survival function values, and related quantities.
)indexTimez	Surv probzSurv prob SEznum at riskz
num events)	pd	DataFramer   r   namer   r   r   r   )ri   dfs     r5   summarySurvfuncRight.summary  s_     \\0..;!..> KK===<	r7   c                 T   UR                  5       nUS:w  a  Sn[        U5      eUS:w  a  [        S5      eUR                  5       nU R                  S-  U R                  S-  -  nU R                  nUS:X  a~  [
        R                  " U5      [
        R                  " U R                  5      -  nSSXe-  -   -  U-  n[
        R                  " U5      nU R                  SU-  -  n	U R                  U-  n
X4$ US	:X  Ga$  SnUSXe-  -   S[
        R                  " U5      -  -  -  nU[
        R                  " U R                  SU R                  -
  -  5      -  n[
        R                  " [
        R                  " U R                  5      5      n[
        R                  " X-
  S
[
        R                  5      n[
        R                  " U5      S-  n	[
        R                  " X-   [
        R                  * [
        R                  S-  5      n[
        R                  " U5      S-  n
X4$ [        S5      e)aV  
Returns a simultaneous confidence band for the survival function.

Parameters
----------
alpha : float
    `1 - alpha` is the desired simultaneous coverage
    probability for the confidence region.  Currently alpha
    must be set to 0.05, giving 95% simultaneous intervals.
method : str
    The method used to produce the simultaneous confidence
    band.  Only the Hall-Wellner (hw) method is currently
    implemented.
transform : str
    The used to produce the interval (note that the returned
    interval is on the survival probability scale regardless
    of which transform is used).  Only `log` and `arcsin` are
    implemented.

Returns
-------
lcb : array_like
    The lower confidence limits corresponding to the points
    in `surv_times`.
ucb : array_like
    The upper confidence limits corresponding to the points
    in `surv_times`.
hwz0only the Hall-Wellner (hw) method is implemented皙?zalpha must be set to 0.05r9   r   g_)Ǻ?r   r   r   zUnknown transform)r   rL   r   r   r   r   r!   r   r   r   r   r   sinpi)ri   r   r   	transformrQ   s2nnr2   thetalcbucbrB   frI   s                 r5   simultaneous_cbSurvfuncRight.simultaneous_cb  s   < T>DCS/!D=899OO%	!DNNA$55[[GGBK"&&"88Ea"'k*U2EFF5ME..1U7+C..%'C x ("A!bg+!bggbk/22A1t~~+=>??A		"''$..12Aq"&&)A&&)Q,Cwa0A&&)Q,C x 011r7   )r%   rP   rO   r   r   r$   r   r   r   r#   rh   )NNNNrp   r   )r   r   )r   r   r   )rq   rr   rs   rt   ru   rn   r   r   r   r   r   rv   rw   r7   r5   ry   ry     s2    AF 8<9;!0F'8&*FP";r7   ry   c           	      F   [         R                  " U 5      n [         R                  " U5      n[         R                  " U5      n[         R                  " U5      nUc  [        XX#UU40 UD6u  pO][         R                  " U5      n[         R                  " U5      n
Su  pU
 H'  nXK:H  n[        X   X   X,   X7U40 UD6u  pX-  nX-  n	M)     UR	                  [         R
                  R                  X5      5      nS[        R                  " U[        U5      S-
  5      -
  nUU4$ )a  
Test for the equality of two survival distributions.

Parameters
----------
time : array_like
    The event or censoring times.
status : array_like
    The censoring status variable, status=1 indicates that the
    event occurred, status=0 indicates that the observation was
    censored.
group : array_like
    Indicators of the two groups
weight_type : str
    The following weight types are implemented:
        None (default) : logrank test
        fh : Fleming-Harrington, weights by S^(fh_p),
             requires exponent fh_p to be provided as keyword
             argument; the weights are derived from S defined at
             the previous event time, and the first weight is
             always 1.
        gb : Gehan-Breslow, weights by the number at risk
        tw : Tarone-Ware, weights by the square root of the number
             at risk
strata : array_like
    Optional stratum indicators for a stratified test
entry : array_like
    Entry times to handle left truncation. The subject is not in
    the risk set on or before the entry time.

Returns
-------
chisq : The chi-square (1 degree of freedom) distributed test
        statistic value
pvalue : The p-value for the chi^2 test
)        r   r   )
r   rc   r   	_survdiffdotlinalgsolver   cdfr   )r#   r$   groupweight_typestratar%   kwargsgrobsvarstustr0   obs1var1chisqpvalues                    r5   survdiffr   6  s   N ::dDZZFJJuE	5	B~T5r".&,.S F#iiB,B"48VZ#.EE=CEJDKCKC  GGBIIOOC-.E%R++F&=r7   c                 x   Uc  [         R                  " U SS9u  pxO:[         R                  " [         R                  " X45      SS9u  pxUS[        U 5       nU V	s/ s H  oS 4PM     n
n	Ub'  [	        U5       H  u  pX$U   :H  nX]   nXK   U4X'   M     / / nn[        U5      nU
 H  u  nnUU:H  n[         R
                  " UUUS9n[         R
                  " XU-  US9nUR                  U5        Ubc  [         R                  " U5      U-
  n[         R                  " UUSS9n[         R
                  " UUS9n[         R                  " U5      U-
  nUU-
  nO"[         R                  " US S S2   5      S S S2   nUR                  U5        M     [        U5      n[        U5      n[         R                  " US	:  5      nS nUb  UR                  5       nUS
:X  a  UnOUS:X  a  [         R                  " U5      nOUS:X  a  SU;  a  Sn[        U5      eUS   nS	UUR                  [         R                  5      -  -
  n [         R                   " U 5      n [         R                  " U 5      n [         R"                  " U 5      n U U-  n[         R$                  " US	5      nS	US'   O[        S5      e[        U5      S	-
  n![         R&                  " U5      [         R(                  " US[         R*                  5      S S S 24   -  n"/ n#/ n$US	-
  n%[         R(                  " U%S[         R*                  5      n%[-        S	U!S	-   5       H  nUU   U"U   U-  -
  n&U"S	S 2S S 24   R.                  [         R0                  " S	U!US	-
  5      R3                  5       U"US S 2S 4   -
  -  n'UUU-
  -  U%-  n(U'U(S S 2S 4   -  n)Ub  UU&-  n&US-  S S 2S 4   U)-  n)U#R                  U&U   R                  5       5        U$R                  U)U   R                  SS95        M     [         R4                  " U#5      n*[         R&                  " U$5      n+U*U+4$ s  sn	f )NTr   r   r	   r   r   r   r   r   gbtwfhfh_pz4weight_type type 'fh' requires specification of fh_pzweight_type not implementedg|=r9   )axis)r   r   r   r   	enumerater   r=   r   r   r?   r   r   r!   rL   r   r   r   r   rollvstackr   r   r<   Teyeravelhstack),r#   r$   r   r   r   r%   r   utimesrtimesgr_itserB   _r0   entry1nriskobsvr+   r   entry0mkr-   obr.   r/   nrr   	nrisk_totixr
   rQ   r   r1   dfsr   	groups_oe
groups_var	var_denomoevar_tensor_partvar_scalar_partr   obs_vecvar_mats,                                               r5   r   r   x  s    }4=2>>4-#@268#d)$ %'
'BD$<BC
'bMDAa5.BYFeV_CF " b4E	VB	6qjKKb9[[bAB		!q A__VV&AFVr2B2#BaB1TrT7#DbD)BR# & d)CE
I		A	&BG!'')$GD ggi(GD V#L o%&>D S9++BJJ777BB2BB$hGgggq)GGAJ:;;
b'A+C
		%2779eRVV<T1WEEA IJAI	5"&&1I 1c!e_!WqtCx ABE(**q#qs(;(A(A(Ca1d
m(STS1I=4 882BA:q$w'#-C 	B&#b'++1+-. " ii	"Gii
#GGs (s   P7c           
      z   [         R                  " U5      u  p! [        U S   5      [        L d   e [	        U 5       GH\  u  p4[
        R                  " S/UR                  45      n[
        R                  " S/UR                  45      n[        UR                  5      nXuS   :  a3  [
        R                  " XW/45      n[
        R                  " XfS   /45      n[        USSUS-   -  5      nUR                  XVSUSSS	9u  n	[
        R                  " [
        R                  " UR                  5      5      n
[
        R                   " UR                  U
   5      n[
        R"                  " X[5      S-
  nXl   nUR%                  XS
SU	R'                  5       US-   S9  GM_     UR)                  SS5        U$ !   U /n  GN= f)a%  
Plot one or more survivor functions.

Parameters
----------
survfuncs : object or array_like
    A single SurvfuncRight object, or a list or SurvfuncRight
    objects that are plotted together.

Returns
-------
A figure instance on which the plot was drawn.

Examples
--------
Add a legend:

>>> import statsmodels.api as sm
>>> from statsmodels.duration.survfunc import plot_survfunc
>>> data = sm.datasets.get_rdataset("flchain", "survival").data
>>> df = data.loc[data.sex == "F", :]
>>> sf0 = sm.SurvfuncRight(df["futime"], df["death"])
>>> sf1 = sm.SurvfuncRight(3.0 * df["futime"], df["death"])
>>> fig = plot_survfunc([sf0, sf1])
>>> ax = fig.get_axes()[0]
>>> ax.set_position([0.1, 0.1, 0.64, 0.8])
>>> ha, lb = ax.get_legend_handles_labels()
>>> leg = fig.legend((ha[0], ha[1]), (lb[0], lb[1]), loc='center right')

Change the line colors:

>>> fig = plot_survfunc([sf0, sf1])
>>> ax = fig.get_axes()[0]
>>> ax.set_position([0.1, 0.1, 0.64, 0.8])
>>> ha, lb = ax.get_legend_handles_labels()
>>> ha[0].set_color('purple')
>>> ha[1].set_color('orange')
r   r   r   rh   zGroup %d-r9   post)labellwwhere+   z points)mscolorr  g)\(?)r   create_mpl_axtypery   r   r   r   r   r   r;   r#   getattrstepr   logical_notr$   r   r   r   	get_colorset_ylim)	survfuncsr   figgxsfr   r   mxtr  lir0   tijjr1   s                 r5   r   r     s   P !!"%GC IaL!]222 I& ^^aS"--$89
NNQC#67	 "''lBU(;<J	bM?'CDIGZ26%:;ggjS!"  $ ^^BNN29956YYrwwr{#__Z,q0]
",,.i' 	 	)1 '6 KK4JA K	s   F2 2F:)NNTTr   )NNN)numpyr   pandasr   scipy.stats.distributionsr   r   statsmodels.graphicsr   r6   rJ   rR   rT   ry   r   r   r   rw   r7   r5   <module>r     sd      0 & KO $L&^3lD(d0 d0Nl l^	 <@?DhVNr7   