maxlikmtInverseWaldLimits#

Purpose#

Computes confidence limits by inversion of the Wald statistic.

Format#

out = maxlikmtInverseWaldLimits(out0, c0)#
out = maxlikmtInverseWaldLimits(out0)
Parameters:
  • out0 (struct) – Instance of maxlikmtResults structure containing results of an estimation generated by a call to maxlikmt().

  • c1 (struct) –

    Optional input. Instance of a maxlikmtControl structure containing the following members:

    c1.bayesAlpha

    Exponent of the Dirichlet random variates used in the weighted bootstrap. Default = 1.4.

    c1.priorProc

    Pointer to a procedure for computing the prior. Assumes a uniform prior if not provided.

    c1.numSamples

    Number of re-samples in the weighted likelihood bootstrap.

    c1.BayesFname

    Filename for the simulated posterior parameters dataset. Defaults to a unique “BAYESxxxx” pattern.

    c1.maxBootTime

    Maximum time allowed for resampling.

    c1.Bounds

    Bounds on parameters, either 1x2 for all parameters or Kx2 for individual parameter bounds. Default = {-1e256, 1e256}.

    c1.algorithm

    Descent algorithm for optimization, includes BFGS, DFP, Newton, and BHHH.

    c1.switch

    Controls algorithm switching based on various performance metrics.

    c1.lineSearch

    Method for line search in optimization, includes augmented trust region method and others. Default varies based on constraints.

    c1.active

    Kx1 vector to control which parameters are active or fixed at start value.

    c1.numObs

    Number of observations, required if the log-likelihood function returns a scalar.

    c1.maxIters

    Maximum number of iterations for the optimization process. Default = 10000.

    c1.tol

    Convergence tolerance, optimization stops when all elements of the direction vector are below this value. Default = 1e-5.

    c1.weights

    Vector of weights for the objective function returning a vector. Default = 1.

    c1.covParType

    Determines the type of covariance matrix computed, QML or ML. Default = 1.

    c1.alpha

    Probability level for statistical tests. Default = .05.

    c1.feasibleTest

    If nonzero, parameters are tested for feasibility before computing the function in line search. Default = 1.

    c1.maxTries

    Maximum number of attempts in random search. Default = 100.

    c1.randRadius

    Radius of the random search, if attempted. Default = .001.

    c1.gradMethod

    Method for computing numerical gradient, includes central, forward, and backward difference.

    c1.hessMethod

    Method for computing numerical Hessian, similar options as gradient computation.

    c1.gradStep

    Increment size for computing numerical gradient, can be scalar or Kx1 vector.

    c1.hessStep

    Increment size for computing numerical Hessian, options similar to gradStep.

    c1.gradCheck

    If nonzero and analytical gradients/Hessian provided, numerical versions are computed for comparison.

    c1.state

    Seed for random number generator, ensuring reproducibility.

    c1.title

    Title of the run, for identification in output.

    c1.printIters

    If nonzero, iteration information is printed. Default = 0.

    c1.disableKey

    If nonzero, keyboard input is disabled during execution.

Returns:

out (struct) –

An instance of a maxlikmtResults structure. Contains the results of the optimization problem, including parameter estimates, function evaluations, and various statistical measures.

out.bayesLimits

Weighted likelihood Bayesian confidence limits, Kx2 matrix.

out.par

Instance of a PV structure containing the parameter estimates, placed in the member matrix out.par.

out.fct

Scalar, function evaluated at parameters in par.

out.returnDescription

String, description of return values.

out.covPar

KxK matrix, covariance matrix of parameters.

out.covParDescription

String, description of covPar.

out.numObs

Scalar, number of observations.

out.hessian

KxK matrix, Hessian evaluated at parameters in par.

out.xproduct

KxK matrix, cross-product of NxK matrix of first derivatives evaluated at parameters in par. Not available if log-likelihood function returns a scalar.

out.waldLimits

Kx2 matrix, Wald confidence limits.

out.inverseWaldLimits

Kx2 matrix, confidence limits by inversion of Wald statistics. Available only if maxlikmtInverseWaldLimits`() has been called.

out.profileLimits

Kx2 matrix, profile likelihood confidence limits, by inversion of likelihood ratio statistics. Only available if maxlikmtProfileLimits() has been called.

out.bootLimits

Kx2 Matrix, bootstrap confidence limits. Available only if maxlikmtBoot() has been called.

out.gradient

Kx1 vector, gradient evaluated at the parameters in par.

out.numIterations

Scalar, number of iterations.

out.elapsedTime

Scalar, elapsed time of iterations.

out.alpha

Scalar, probability level of confidence limits. Default = .05.

out.title

String, title of run.

out.Lagrangeans

Kx2 matrix, Lagrangean coefficients of bounds constraints if any.

out.retcode

Return code indicating the outcome of the computation:

  • 0: Normal convergence

  • 1: Forced exit

  • 2: Maximum number of iterations exceeded

  • 3: Function calculation failed

  • 4: Gradient calculation failed

  • 5: Hessian calculation failed

  • 6: Line search failed

  • 7: Functional evaluation failed

  • 8: Error with initial gradient

  • 9: Error with constraints

  • 10: Second update failed

  • 11: Maximum time exceeded

  • 12: Error with weights

  • 13: Quadratic program failed

  • 14: Equality constraint Jacobian failed

  • 15: Inequality constraint Jacobian failed

  • 20: Hessian failed to invert

  • 34: Data set could not be opened

Example#

The following is a complete example demonstrating the use of maxlikmtInverseWaldLimits():

// Load maxlikmt library
library maxlikmt;

// Likelihood function
proc lpr(struct PV p, x, y, ind);
    local s2, b0, b, yh, u, res, g1, g2;

    // Declare 'mm' to be a modelResults struct
    // to hold the function and gradient values
    struct modelResults mm;

    // Extract parameters from PV struct
    b0 = pvUnpack(p, "b0");
    b = pvUnpack(p, "b");
    s2 = pvUnpack(p, "variance");

    // Computations shared between function and gradient
    yh = b0 + x * b;
    res = y - yh;
    u = y[.,1] ./= 0;

    // Compute function value
    if ind[1];
        mm.function = u.*lnpdfmvn(res, s2) + (1-u).*(ln(cdfnc(yh/sqrt(s2))));
    endif;

    // Compute gradient if second element
    // of 'ind' is nonzero
    if ind[2];
        yh = yh/sqrt(s2);
        g1 = ((res~x.*res)/s2)~((res.*res/s2)-1)/(2*s2);
        g2 = (-(ones(rows(x), 1)~x)/sqrt(s2))~(yh/(2*s2));
        g2 = (pdfn(yh)./cdfnc(yh)).*g2;
        mm.gradient = u.*g1 + (1-u).*g2;
    endif;

    retp(mm);

endp;

struct PV p0;
p0 = pvPack(pvCreate, 1, "b0");
p0 = pvPack(p0, 1|1|1, "b");
p0 = pvPack(p0, 1, "variance");

// Declare maxlikmtControl structure
struct maxlikmtControl c0;
c0 = maxlikmtControlCreate;

// Set title
c0.title = "Tobit Example";

// Set parameter bounds
c0.Bounds = {
    -10 10,
    -10 10,
    -10 10,
    -10 10,
    .1 10
};


// Load tobit data
z = loadd(getGAUSSHome("pkgs/maxlikmt/examples/maxlikmttobit.dat"));

// Separate x and y
y = z[., 1];
x = z[., 2:4];

// Declare instance of maxlikmtResults structure
struct maxlikmtResults out1;
out1 = maxlikmt(&lpr, p0, x, y, c0);

// Limits by inversion of likelihood ratio statistic
out1 = maxlikmtProfileLimits(&lpr, out1, x, y, c0);

// Limits by inversion of Wald statistic
out1 = maxlikmtInverseWaldLimits(out1, c0);

// Print results
call maxlikmtPrt(out1);