src/estimagic/sensitivity/msm_sensitivity.py
def calculate_actual_sensitivity_to_removal(jac, weights, moments_cov, params_cov):
    """calculate the actual sensitivity to removal.

    The sensitivity measure is calculated for each parameter wrt each moment.

    It answers the following question: How much precision would be lost if the kth
        moment was excluded from the estimation if "weights" is used as weighting
        matrix?

    Args:
        sensitivity_to_bias (np.ndarray or pandas.DataFrame): See
            ``calculate_sensitivity_to_bias`` for details.
        weights (np.ndarray or pandas.DataFrame): The weighting matrix used for
            msm estimation.
        moments_cov (numpy.ndarray or pandas.DataFrame): The covariance matrix of the
            empirical moments.
        params_cov (numpy.ndarray or pandas.DataFrame): The covariance matrix of the
            parameter estimates.

    Returns:
        np.ndarray or pd.DataFrame: Sensitivity measure with shape (n_params, n_moments)

    """
    m4 = []

    _jac, _weights, _moments_cov, _params_cov, names = process_pandas_arguments(
        jac=jac, weights=weights, moments_cov=moments_cov, params_cov=params_cov
    )

    for k in range(len(_weights)):
        weight_tilde_k = np.copy(_weights)
        weight_tilde_k[k, :] = 0
        weight_tilde_k[:, k] = 0

        sigma_tilde_k = cov_robust(_jac, weight_tilde_k, _moments_cov)

        m4k = sigma_tilde_k - _params_cov
        m4k = m4k.diagonal()

        m4.append(m4k)

    m4 = np.array(m4).T

    params_variances = np.diagonal(_params_cov)
    e4 = m4 / params_variances.reshape(-1, 1)

    if names:
        e4 = pd.DataFrame(e4, index=names.get("params"), columns=names.get("moments"))

    return e4
calculate the actual sensitivity to removal.

    The sensitivity measure is calculated for each parameter wrt each moment.

    It answers the following question: How much precision would be lost if the kth
        moment was excluded from the estimation if "weights" is used as weighting
        matrix?

    Args:
        sensitivity_to_bias (np.ndarray or pandas.DataFrame): See
            ``calculate_sensitivity_to_bias`` for details.
        weights (np.ndarray or pandas.DataFrame): The weighting matrix used for
            msm estimation.
        moments_cov (numpy.ndarray or pandas.DataFrame): The covariance matrix of the
            empirical moments.
        params_cov (numpy.ndarray or pandas.DataFrame): The covariance matrix of the
            parameter estimates.

    Returns:
        np.ndarray or pd.DataFrame: Sensitivity measure with shape (n_params, n_moments)

    
calculate the actual sensitivity to removal.
The sensitivity measure is calculated for each parameter wrt each moment.


calculate the actual sensitivity to removal . The sensitivity measure is calculated for each parameter wrt each moment .
def calculate_actual_sensitivity_to_removal(jac, weights, moments_cov, params_cov):
    m4 = []
    _jac, _weights, _moments_cov, _params_cov, names = process_pandas_arguments(
        jac=jac, weights=weights, moments_cov=moments_cov, params_cov=params_cov
    )
    for k in range(len(_weights)):
        weight_tilde_k = np.copy(_weights)
        weight_tilde_k[k, :] = 0
        weight_tilde_k[:, k] = 0
        sigma_tilde_k = cov_robust(_jac, weight_tilde_k, _moments_cov)
        m4k = sigma_tilde_k - _params_cov
        m4k = m4k.diagonal()
        m4.append(m4k)
    m4 = np.array(m4).T
    params_variances = np.diagonal(_params_cov)
    e4 = m4 / params_variances.reshape(-1, 1)
    if names:
        e4 = pd.DataFrame(e4, index=names.get("params"), columns=names.get("moments"))
    return e4
def calculate_actual_sensitivity_to_removal ( jac , weights , moments_cov , params_cov ) : m4 = [ ] _jac , _weights , _moments_cov , _params_cov , names = process_pandas_arguments ( jac = jac , weights = weights , moments_cov = moments_cov , params_cov = params_cov ) for k in range ( len ( _weights ) ) : weight_tilde_k = np . copy ( _weights ) weight_tilde_k [ k , : ] = 0 weight_tilde_k [ : , k ] = 0 sigma_tilde_k = cov_robust ( _jac , weight_tilde_k , _moments_cov ) m4k = sigma_tilde_k - _params_cov m4k = m4k . diagonal ( ) m4 . append ( m4k ) m4 = np . array ( m4 ) . T params_variances = np . diagonal ( _params_cov ) e4 = m4 / params_variances . reshape ( - 1 , 1 ) if names : e4 = pd . DataFrame ( e4 , index = names . get ( "params" ) , columns = names . get ( "moments" ) ) return e4
calculate the actual sensitivity to removal.
calculate the actual sensitivity to removal .
"""calculate the actual sensitivity to removal.

    The sensitivity measure is calculated for each parameter wrt each moment.

    It answers the following question: How much precision would be lost if the kth
        moment was excluded from the estimation if "weights" is used as weighting
        matrix?

    Args:
        sensitivity_to_bias (np.ndarray or pandas.DataFrame): See
            ``calculate_sensitivity_to_bias`` for details.
        weights (np.ndarray or pandas.DataFrame): The weighting matrix used for
            msm estimation.
        moments_cov (numpy.ndarray or pandas.DataFrame): The covariance matrix of the
            empirical moments.
        params_cov (numpy.ndarray or pandas.DataFrame): The covariance matrix of the
            parameter estimates.

    Returns:
        np.ndarray or pd.DataFrame: Sensitivity measure with shape (n_params, n_moments)

    """
np.ndarray or pd.DataFrame: Sensitivity measure with shape (n_params, n_moments)
np . ndarray or pd . DataFrame : Sensitivity measure with shape ( n_params n_moments )
jac
weights
The weighting matrix used for
msm estimation.
The weighting matrix used for msm estimation .
moments_cov
The covariance matrix of the
empirical moments.
The covariance matrix of the empirical moments .
params_cov
The covariance matrix of the
parameter estimates.
The covariance matrix of the parameter estimates .
sensitivity_to_bias
See
``calculate_sensitivity_to_bias`` for details.
See ` ` calculate_sensitivity_to_bias ` ` for details .