cjive

weak_instruments.cjive.CJIVE(Y: ndarray[tuple[int, ...], dtype[float64]], W: ndarray[tuple[int, ...], dtype[float64]], X: ndarray[tuple[int, ...], dtype[float64]], Z: ndarray[tuple[int, ...], dtype[float64]], cluster_ids: ndarray[tuple[int, ...], dtype[int32]], talk: bool = False) CJIVEResult

Implements CJIVE estimator from Frandsen, …. :param Y: The dependent variable. :type Y: NDArray[np.float64] :param W: The matrix of control variables. :type W: NDArray[np.float64] :param X: The matrix of exogenous regressors. :type X: NDArray[np.float64] :param Z: The matrix of instruments. :type Z: NDArray[np.float64] :param cluster_ids: The cluster ids for the observations. :type cluster_ids: NDArray[np.int32] :param talk: If True, prints additional information. The default is False. :type talk: bool, optional

Returns:

An object containing the following attributes:
  • beta (NDArray[np.float64]): The estimated coefficients for the CJIVE model.

  • standard_errors (NDArray[np.float64]): The standard errors of the estimated coefficients.

  • r_squared (float): The R-squared value of the model.

  • f_stat (float): The F-statistic of the model.

  • cis (NDArray[np.float64]): The confidence intervals for the estimated coefficients.

Return type:

CJIVEResult

Raises:

ValueError – If the dimensions of the inputs are inconsistent or invalid.

Notes

  • The CJIVE estimator is robust to clustering and weak instruments.

  • The function computes coefficient estimates, standard errors, confidence intervals, R-squared, and F-statistics.

  • Standard errors are clustered by the provided cluster IDs.

Example

>>> import numpy as np
>>> from weak_instruments.cjive import CJIVE
>>> n = 100
>>> Y = np.random.randn(n)
>>> W = np.random.randn(n, 1)
>>> X = np.random.randn(n, 1)
>>> Z = np.random.randn(n, 2)
>>> cluster_ids = np.random.randint(0, 5, size=n)
>>> result = CJIVE(Y, W, X, Z, cluster_ids)
>>> result.summary()
class weak_instruments.cjive.CJIVEResult(beta: ndarray[tuple[int, ...], dtype[float64]], standard_errors: ndarray[tuple[int, ...], dtype[float64]], r_squared: ndarray[tuple[int, ...], dtype[float64]], f_stat: ndarray[tuple[int, ...], dtype[float64]], cis: ndarray[tuple[int, ...], dtype[float64]])

Bases: object

Stores results for the CJIVE estimator.

beta

Estimated coefficients for the CJIVE model.

Type:

NDArray[np.float64]

standard_errors

Standard errors of the estimated coefficients.

Type:

NDArray[np.float64]

r_squared

R-squared value of the model.

Type:

float

f_stat

F-statistic of the model.

Type:

float

cis

Confidence intervals for the estimated coefficients.

Type:

NDArray[np.float64]

summary()

Prints a summary of the CJIVE results in a tabular format similar to statsmodels OLS.