tests/optimization/test_bhhh.py
def criterion_and_derivative_logit(x, task="criterion_and_derivative"):
    """Return Logit criterion and derivative.

    Args:
        x (np.ndarray): Parameter vector of shape (n_obs,).
        task (str): If task=="criterion", compute log-likelihood.
            If task=="derivative", compute derivative.
            If task="criterion_and_derivative", compute both.

    Returns:
        (np.ndarray or tuple): If task=="criterion" it returns the output of
            criterion, which is a 1d numpy array.
            If task=="derivative" it returns the first derivative of criterion,
            which is a numpy array.
            If task=="criterion_and_derivative" it returns both as a tuple.
    """
    endog, exog = generate_test_data()
    score = partial(get_score_logit, endog, exog)
    loglike = partial(get_loglikelihood_logit, endog, exog)

    result = ()

    if "criterion" in task:
        result += (-loglike(x),)
    if "derivative" in task:
        result += (score(x),)

    if len(result) == 1:
        (result,) = result

    return result
Return Logit criterion and derivative.

    Args:
        x (np.ndarray): Parameter vector of shape (n_obs,).
        task (str): If task=="criterion", compute log-likelihood.
            If task=="derivative", compute derivative.
            If task="criterion_and_derivative", compute both.

    Returns:
        (np.ndarray or tuple): If task=="criterion" it returns the output of
            criterion, which is a 1d numpy array.
            If task=="derivative" it returns the first derivative of criterion,
            which is a numpy array.
            If task=="criterion_and_derivative" it returns both as a tuple.
    
Return Logit criterion and derivative.
Return Logit criterion and derivative .
def criterion_and_derivative_logit(x, task="criterion_and_derivative"):
    endog, exog = generate_test_data()
    score = partial(get_score_logit, endog, exog)
    loglike = partial(get_loglikelihood_logit, endog, exog)
    result = ()
    if "criterion" in task:
        result += (-loglike(x),)
    if "derivative" in task:
        result += (score(x),)
    if len(result) == 1:
        (result,) = result
    return result
def criterion_and_derivative_logit ( x , task = "criterion_and_derivative" ) : endog , exog = generate_test_data ( ) score = partial ( get_score_logit , endog , exog ) loglike = partial ( get_loglikelihood_logit , endog , exog ) result = ( ) if "criterion" in task : result += ( - loglike ( x ) , ) if "derivative" in task : result += ( score ( x ) , ) if len ( result ) == 1 : ( result , ) = result return result
Return Logit criterion and derivative.
Return Logit criterion and derivative .
"""Return Logit criterion and derivative.

    Args:
        x (np.ndarray): Parameter vector of shape (n_obs,).
        task (str): If task=="criterion", compute log-likelihood.
            If task=="derivative", compute derivative.
            If task="criterion_and_derivative", compute both.

    Returns:
        (np.ndarray or tuple): If task=="criterion" it returns the output of
            criterion, which is a 1d numpy array.
            If task=="derivative" it returns the first derivative of criterion,
            which is a numpy array.
            If task=="criterion_and_derivative" it returns both as a tuple.
    """
(np.ndarray or tuple): If task=="criterion" it returns the output of
criterion, which is a 1d numpy array.
If task=="derivative" it returns the first derivative of criterion,
which is a numpy array.
If task=="criterion_and_derivative" it returns both as a tuple.
( np . ndarray or tuple ) : If task == " criterion " it returns the output of criterion which is a 1d numpy array . If task == " derivative " it returns the first derivative of criterion which is a numpy array . If task == " criterion_and_derivative " it returns both as a tuple .
x
Parameter vector of shape (n_obs,).
Parameter vector of shape ( n_obs ) .
task
If task=="criterion", compute log-likelihood.
If task=="derivative", compute derivative.
If task="criterion_and_derivative", compute both.
If task == " criterion " compute log - likelihood . If task == " derivative " compute derivative . If task = " criterion_and_derivative " compute both .