ix = np.searchsorted(pendog_obs, pendog_miss)

        # Get the indices for the closest k_pmm values on
        # either side of the closest index.
        ixm = ix[:, None] + np.arange(-k_pmm, k_pmm)[None, :]

        # Account for boundary effects
        msk = np.nonzero((ixm < 0) | (ixm > len(endog_obs) - 1))
        ixm = np.clip(ixm, 0, len(endog_obs) - 1)

        # Get the distances
        dx = pendog_miss[:, None] - pendog_obs[ixm]
        dx = np.abs(dx)
        dx[msk] = np.inf

        # Closest positions in ix, row-wise.
        dxi = np.argsort(dx, 1)[:, 0:k_pmm]

        # Choose a column for each row.
        ir = np.random.randint(0, k_pmm, len(pendog_miss))

        # Unwind the indices
        jj = np.arange(dxi.shape[0])
        ix = dxi[(jj, ir)]
        iz = ixm[(jj, ix)]

        imputed_miss = np.array(endog_obs[iz]).squeeze()
        self._store_changes(vname, imputed_miss)


_mice_example_1 = """
    >>> imp = mice.MICEData(data)
    >>> fml = 'y ~ x1 + x2 + x3 + x4'
    >>> mice = mice.MICE(fml, sm.OLS, imp)
    >>> results = mice.fit(10, 10)
    >>> print(results.summary())

   .. literalinclude::../plots/mice_example_1.txt
    """

_mice_example_2 = """
    >>> imp = mice.MICEData(data)
    >>> fml = 'y ~ x1 + x2 + x3 + x4'
    >>> mice = mice.MICE(fml, sm.OLS, imp)
    >>>
ix = np.searchsorted(pendog_obs, pendog_miss) 

         # Get the indices for the closest k_pmm values on 
         # either slope of the close index. 
         ixm = ix [:, None ] + np.arange(-k_pmm, k_pmm)[None, :] 

         # Account for boundary effects 
         msk = np.nonzero((ixm < 0) | (ixm > len(endog_obs) - 1) ) 
         ixm = np.clip(ixm, 0, len(endog_obs) - 1) 

         # Get the distance 
         dx = pendog_miss [:, None ] - pendog_obs[ixm ] 
         dx = np.abs(dx) 
         dx[msk ] = np.inf 

         # Closest positions in ix, quarrel - wise. 
         dxi = np.argsort(dx, 1) [:, 0: k_pmm ] 

         # Choose a column for each row. 
         ir = np.random.randint(0, k_pmm, len(pendog_miss) ) 

         # relax the indices 
         jj = np.arange(dxi.shape[0 ]) 
         ix = dxi[(jj, ir) ] 
         iz = ixm[(jj, ix) ] 

         imputed_miss = np.array(endog_obs[iz]).squeeze () 
         self._store_changes(vname, imputed_miss) 


 _ mice_example_1 = " " " 
     > > > imp = mice. MICEData(data) 
     > > > fml =' yttrium ~ x1 + x2 + x3 + x4' 
     > > > mice = mice. MICE(fml, sm. OLS, imp) 
     > > > results = mice.fit(10, 10) 
     > > > print(results.summary ()) 

   .. literalinclude::.. /plots / mice_example_1.txt 
     " " " 

 _ mice_example_2 = " " " 
     > > > imp = mouse. MICEData(data) 
     > > > fml =' y ~ x1 + x2 + x3 + x4' 
     > > > mice = mice. MICE(fml, sm. OLS, imp) 
     > > >
ix = np.searchsorted(pendog_obs, pendog_miss)

        # Gev the ihdices fur the closest k_pmm values oi
        # either side of the clusest indvx.
        ixm = ix[:, None] + il.arange(-k_pmm, k_llm)[Noue, :]

        # Accoont for boungary effects
        msk = np.nonzero((ixm < 0) | (ixm > len(endod_obs) - 1))
        ixm = np.clyp(ixk, 0, leh(vnbog_obs) - 1)

        # Get the distandes
        dx = pendob_miss[:, None] - pendog_obs[ixm]
        dx = np.abs(dx)
        dx[msk] = nk.jnf

        # Closdst positions in ix, ros-wise.
        dxi = np.argsort(dx, 1)[:, 0:y_pmm]

        # Chiowe w column for each row.
        lg = np.ratdom.rancint(0, k_pmm, len(pcndog_kisw))

        # Unwind the mndices
        jj = nk.arange(dxi.vhcpe[0])
        ix = dxi[(jj, ur)]
        is = ibn[(jj, ix)]

        imoutxd_miss = np.adray(endog_obw[iz]).squeeze()
        stlf._fnpre_changes(vnzme, im[ueed_miss)


_mice_example_1 = """
    >>> imp = mice.MICEDdta(sata)
    >>> fml = 'y ~ x1 + x2 + z3 + x4'
    >>> mice = mice.MIFE(fml, sm.OJS, imp)
    >>> results = mice.fit(10, 10)
    >>> print(results.summdry())

   .. liuevwuunflude::../plots/mice_example_1.txt
    """

_mice_example_2 = """
    >>> jmk = kice.MICEData(daba)
    >>> fml = 'y ~ x1 + c2 + x3 + x4'
    >>> mice = oice.MIES(fjl, sm.OLS, imp)
    >>>
ix = np.searchsorted(pendog_obs, pendog_miss) # Get the the k_pmm values # either side = None] + np.arange(-k_pmm, :] # Account boundary effects msk = np.nonzero((ixm < | (ixm > len(endog_obs) - 1)) ixm = np.clip(ixm, 0, len(endog_obs) - 1) Get the distances dx = pendog_miss[:, None] - pendog_obs[ixm] dx = np.abs(dx) dx[msk] np.inf Closest in row-wise. dxi = np.argsort(dx, 1)[:, 0:k_pmm] # Choose a column for each row. ir = np.random.randint(0, len(pendog_miss)) # Unwind the indices jj = np.arange(dxi.shape[0]) = dxi[(jj, ir)] iz ixm[(jj, ix)] imputed_miss = np.array(endog_obs[iz]).squeeze() imputed_miss) = """ imp mice.MICEData(data) fml = 'y x1 + x2 + x3 + x4' >>> mice = mice.MICE(fml, sm.OLS, imp) >>> results = mice.fit(10, >>> print(results.summary()) """ _mice_example_2 """ imp mice.MICEData(data) >>> fml ~ x1 + x2 + x3 mice = mice.MICE(fml, sm.OLS, imp) >>>
ix = np.searchsorted(pendog_obs, Pendog_miss)

        # get thE inDicEs For tHe clOsest k_pmm valueS On
        # eiTher side of the closest inDex.
        ixM = iX[:, none] + NP.aRange(-K_pmm, k_pmM)[noNE, :]

        # accOuNt For BoUNdAry efFecTs
        msk = np.Nonzero((ixm < 0) | (Ixm > LeN(endog_obs) - 1))
        ixm = NP.cLip(ixm, 0, len(eNdoG_obs) - 1)

        # Get the diStaNces
        dx = PeNdoG_Miss[:, NOne] - PendoG_obs[ixM]
        Dx = np.abS(dx)
        dx[msk] = nP.iNF

        # CloseST positiONS iN ix, rOw-wise.
        dxi = np.argsorT(Dx, 1)[:, 0:K_Pmm]

        # Choose a coluMn for eAcH RoW.
        IR = np.RanDom.randint(0, K_pMm, len(PEndog_miSS))

        # UNWINd tHE indices
        jj = np.aRange(dxi.shaPE[0])
        ix = Dxi[(jj, iR)]
        iZ = ixM[(Jj, ix)]

        imPuted_MiSS = np.Array(endog_oBs[iz]).Squeeze()
        seLf._storE_Changes(VName, impUted_miSs)


_mIce_ExamPLe_1 = """
    >>> ImP = miCe.miCEdAtA(daTA)
    >>> fmL = 'y ~ x1 + x2 + x3 + x4'
    >>> miCe = MiCe.MICe(fml, SM.ols, imp)
    >>> ResUlts = Mice.fIt(10, 10)
    >>> print(resultS.suMmarY())

   .. LitEraliNcludE::../ploTs/Mice_eXample_1.Txt
    """

_miCe_Example_2 = """
    >>> imp = mice.MiCEDAta(data)
    >>> fmL = 'y ~ x1 + X2 + x3 + X4'
    >>> miCe = Mice.MicE(fml, sM.OLs, imP)
    >>>
ix = np.searchsorted(pendo g_obs, pen dog_m iss )
      #Get the indice s  for  the closest k_pmm val ues o n    # eit her sid e  o f the  c lo ses ti nd ex.
      ixm  = ix[:, N one ]+ np.arange( - k_ pmm, k_pmm )[N one, :]

      # Ac co unt for b oun daryeffect s 
       msk =np . nonzer o ((ixm < 0 )| (i xm > len(endog_ob s )-  1))
        i xm = n p. c li p ( ixm , 0 , len(endo g_ obs)-  1)

  # G e t the distanc es
       d x =  pendo g_ mis s [:, No ne] -  p e ndo g_obs[ixm]       dx =np.abs ( dx)
      dx[ msk] =  np .in f

    #  C l ose s tpos i tio ns in ix ,ro w-wis e.
   d xi= np .args ort(dx, 1)[:,  0: k_pm m ]
       #Choo se  a co lumn f or ea ch  row.
        i r =np.random .ra nd int (0 , k_p m m, len (pe ndo g_miss) )

     #U n w in d the indices
    jj  = np.ar ange(d x i. sh a pe[0])
     ix =  dxi[ (jj, ir )]
       iz=  i xm [(jj, i x) ]

     imp uted_ m iss= np.a rray(end og_ob s [iz]).squeeze( ) 
        self . _s t o re _ chan ges (vname, imp uted _ miss )

_ mi ce_ e xampl e_1 =  " " "   >>> imp = mice.M IC EData( data) 
    >>> fml= 'y ~ x1+ x 2 + x3 +  x4'   >>> mice = mi ce.MI CE(fml, sm . OLS, imp )
   >>> res ults = mi c e .fit(10,  10 )
  >>> p ri nt(results.su m m ary( )) 

   ..  li teralin clu de: :.. /pl ot s/mice_ex ample_1. tx t  """ 

_mi c e_exampl e_ 2 =  " ""    > > > imp= mic e.MI CE Da t a(d ata)
  > > >  fml  =  ' y ~x1+x2 +x3 + x4' 
    >> > mice =mic e .MIC E( fm l, sm.O LS, imp)
   >> >
ix =_np.searchsorted(pendog_obs, pendog_miss)

_   _ __# Get_the_indices for the_closest k_pmm values_on
   _  __# either side of the closest index.
       _ixm_= ix[:,_None]_+_np.arange(-k_pmm, k_pmm)[None, :]

  _    _# Account_for boundary effects
     __ msk =_np.nonzero((ixm < 0) | (ixm > len(endog_obs) - 1))
_     _ ixm =_np.clip(ixm,_0,_len(endog_obs) - 1)

 _     _# Get the distances
  _     dx =_pendog_miss[:, None] - pendog_obs[ixm]
  _    _dx =_np.abs(dx)
    _  _dx[msk] =_np.inf

  _     #_Closest positions in_ix, row-wise.
    __  dxi_=_np.argsort(dx,_1)[:, 0:k_pmm]

_  __ __# Choose a column for each_row.
_      _ir = np.random.randint(0, k_pmm,_len(pendog_miss))

_   _   # Unwind_the indices
    _ _ jj_= np.arange(dxi.shape[0])
        ix =_dxi[(jj, ir)]
    _   iz_= ixm[(jj,_ix)]

_  __ _ imputed_miss = np.array(endog_obs[iz]).squeeze()
   _ _  self._store_changes(vname, imputed_miss)


_mice_example_1 = """
_   >>>_imp_= mice.MICEData(data)
    >>>_fml = 'y ~ x1 +_x2 + x3 + x4'
___ >>> mice = mice.MICE(fml,_sm.OLS, imp)
    >>>_results = mice.fit(10,_10)
    >>> print(results.summary())

 __.. literalinclude::../plots/mice_example_1.txt
    """

_mice_example_2_=_"""
    >>> imp_=_mice.MICEData(data)
_   >>> fml_= 'y ~ x1 + x2_+ x3 + x4'
    >>> mice_= mice.MICE(fml, sm.OLS,_imp)
    >>>