# ConScore¶

## Purpose¶

Compute local score statistic and its probability for hypotheses involving parameters under constraints

## Format¶

{ SL, SLprob } = ConScore(H, G, grad, a, b, c, d, bounds, psi)
Parameters: H (KxK matrix) – Hessian of loglikelihood with respect to parameters. G (KxK matrix) – cross-product matrix of the first derivatives by observation. If not available set to H. grad (Kx1 vector) – gradient of loglikelihood with respect to parameters. a (MxK matrix) – linear equality constraint coefficients. b (Mx1 vector) – linear equality constraint constants. These arguments specify the linear equality constraints of the following type: $a * X = b$ where X is the Kx1 parameter vector. c (MxK matrix) – linear inequality constraint coefficients. d (Mx1 vector) – linear inequality constraint constants. These arguments specify the linear inequality constraints of the following type: .. math:: c * X >= d where X is the Kx1 parameter vector. bounds (Kx2 matrix) – bounds on parameters. The first column contains the lower bounds, and the second column the upper bounds. psi (matrix) – indices of the set of parameters in the hypothesis SL (scalar) – local score statistic of hypothesis. SLprob (scalar) – probability of SL.

## Examples¶

This example is from Silvapulle and Sen, Constrained Statistical Inference, page 181-3. It computes the local score statistic and probability for an ARCH model. It tests the null hypothesis of no arch effects against the alternative of arch effects subject to their being constrained to be positive. The Hessian, H, cross-product matrix, G, and the gradient vector, grad, are generated by an estimation using sqpSolvemt() where the model is an ARCH model with the arch parameters constrained to be zero.

// dataMatrix
struct DS d0;
d0 = reshape(dsCreate,2,1);

z = packr(lagn(251*ln(trimr(z0, 1, 0)./trimr(z0, 0, 1)), 0|1|2|3|4));
d0[1].dataMatrix = z[., 1];
d0[2].dataMatrix = z[., 2:5];

// Control structure
struct sqpsolvemtControl c0;
c0 = sqpSolveMTcontrolCreate;

/*
** Constraints setting arch parameter equal
** to zero for H(theta) = 0
*/
c0.A = zeros(3, 6) ~ eye(3);
c0.B = zeros(3, 1);

/*
** Causes cross-product of
** Jacobian to be computed which
** is needed for ConScore
*/
c0.covType = 2;

struct PV p0;
p0 = pvPack(pvCreate, .08999, "constant");
p0 = pvPack(p0, .25167|-.12599|.09164|.07517,
"phi");
p0 = pvPack(p0,3.22713, "omega");
p0 = pvPack(p0, 0|0|0, "arch");

struct sqpsolvemtOut out0;
out0 = sqpsolvemt(&lpr, p0, d0, c0);

// Set up constraints for H(theta) >= 0
bounds = { -1e256 1e256,
-1e256 1e256,
-1e256 1e256,
-1e256 1e256,
-1e256 1e256,
-1e256 1e256,
0 1e256,
0 1e256,
0 1e256 };
H = out0.hessian;
G = out0.xproduct;

// minus because -logl in log-likelihood

psi = { 7, 8, 9 };

{ SL, SLprob } = ConScore(H,G,grad,0,0,0,0,bounds,psi);


will assign the variables SL and SLprob as follows:

SL = 3.8605086
SLprob = 0.10410000


## Remarks¶

ConScore() computes the local score statistic for the hypothesis $$H(Θ) = 0$$ vs. $$H(Θ) ≥ 0$$, where $$Θ$$ is the vector of estimated parameters, and $$H()$$ is a constraint function of the parameters.

First, the model with $$H(Θ) = 0$$ is estimated, and the Hessian and optionally the cross-product of the derivatives is computed. Also, the gradient vector is computed.

Next, the constraint arguments are set to $$H(Θ) ≥ 0$$.