delicatessen.estimating_equations.basic.ee_mean_variance

ee_mean_variance(theta, y)
Estimating equations for the mean and variance. The estimating equations for the mean and

variance are

\[\begin{split}\sum_{i=1}^n \begin{bmatrix} Y_i - \theta_1 = 0 \\ (Y_i - \theta_1)^2 - \theta_2 \end{bmatrix} = 0\end{split}\]

Unlike ee_mean, theta consists of 2 parameters. The output covariance matrix will also provide estimates for each of the theta values.

Parameters
  • theta (ndarray, list, vector) – Theta in this case consists of two values. Therefore, initial values like the form of [0, 0] should be provided.

  • y (ndarray, list, vector) – 1-dimensional vector of n observed values. No missing data should be included (missing data may cause unexpected behavior when attempting to calculate the mean).

Returns

Returns a 2-by-n NumPy array evaluated for the input theta and y.

Return type

array

Examples

Construction of a estimating equation(s) with ee_mean_variance should be done similar to the following

>>> from delicatessen import MEstimator
>>> from delicatessen.estimating_equations import ee_mean_variance

Some generic data to estimate the mean for

>>> y_dat = [1, 2, 4, 1, 2, 3, 1, 5, 2]

Defining psi, or the stacked estimating equations

>>> def psi(theta):
>>>     return ee_mean_variance(theta=theta, y=y_dat)

Calling the M-estimator (note that init has 2 values)

>>> estr = MEstimator(stacked_equations=psi, init=[0, 0, ])
>>> estr.estimate()

Inspecting the parameter estimates, the variance, and the asymptotic variance

>>> estr.theta
>>> estr.variance
>>> estr.asymptotic_variance

For this estimating equation, estr.theta[1] and estr.asymptotic_variance[0][0] are expected to be equal.

References

Boos DD, & Stefanski LA. (2013). M-estimation (estimating equations). In Essential Statistical Inference (pp. 297-337). Springer, New York, NY.