ó
áp7]c           @   sL   d  Z  d d l m Z d d l Z d d l m Z d e f d „  ƒ  YZ d S(   s?  
Empirical Likelihood Linear Regression Inference

The script contains the function that is optimized over nuisance parameters to
 conduct inference on linear regression parameters.  It is called by eltest
in OLSResults.


General References
-----------------

Owen, A.B.(2001). Empirical Likelihood. Chapman and Hall

iÿÿÿÿ(   t   divisionN(   t
   _OptFunctst
   _ELRegOptsc        	   B   s8   e  Z d  Z d „  Z d d d d d d d d d „ Z RS(   sæ   

    A class that holds functions to be optimized over when conducting
    hypothesis tests and calculating confidence intervals.

    Parameters
    ----------

    OLSResults : Results instance
        A fitted OLS result

    c         C   s   d  S(   N(    (   t   self(    (    s<   lib/python2.7/site-packages/statsmodels/emplike/elregress.pyt   __init__#   s    c
         C   s  | | | <t  j t  j t  j | ƒ | ƒ ƒ }
 | | |
 <| j | d ƒ } | |  _ | | t  j t  j | | ƒ ƒ j t | ƒ d ƒ } |	 sEt  j	 | d d ƒd } t  j
 | | d d ƒd | } | d d … d d … f | } | | d d … d d … f | } t  j | | f d d ƒ} t  j | | f d d ƒ} n  t  j t | ƒ ƒ d | } t  j | j d ƒ j d d ƒ } yn |  j | | | ƒ } d t  j | | j ƒ } d | d | |  _ t  j
 t  j | |  j ƒ ƒ } d | SWn t  j j j k
 rt  j SXd S(   s»  
        A function that is optimized over nuisance parameters to conduct a
        hypothesis test for the parameters of interest

        Parameters
        ----------
        nuisance_params: 1darray
            Parameters to be optimized over

        Returns
        -------
        llr : float
            -2 x the log-likelihood of the nuisance parameters and the
            hypothesized value of the parameter(s) of interest.
        i   t   axisi    Ng      ð?iÿÿÿÿiþÿÿÿ(   t   npt   int_t   deletet   aranget   reshapet
   new_paramst   squeezet   dott   intt   meant   sumt   concatenatet   onest   zerost   shapet   _modif_newtont   Tt   new_weightst   logt   linalgt   LinAlgErrort   inf(   R   t   nuisance_paramst
   param_numst   endogt   exogt   nobst   nvart   paramst   b0_valst   stochastic_exogt   nuis_param_indexR   t   est_vectt
   exog_meanst	   exog_mom2t   mean_est_vectt   mom2_est_vectt   regressor_est_vectt   wtst   x0t   eta_start   denomt   llr(    (    s<   lib/python2.7/site-packages/statsmodels/emplike/elregress.pyt   _opt_nuis_regress&   s8    

	2 $	"N(   t   __name__t
   __module__t   __doc__R   t   NoneR1   (    (    (    s<   lib/python2.7/site-packages/statsmodels/emplike/elregress.pyR      s   	(   R4   t
   __future__R    t   numpyR   t   statsmodels.emplike.descriptiveR   R   (    (    (    s<   lib/python2.7/site-packages/statsmodels/emplike/elregress.pyt   <module>   s   