rStats.js v1.3.0
    Preparing search index...

    Function coeftest

    • Tests of the coefficients of an lm or glm fit with a given covariance matrix. Equivalent to R's lmtest::coeftest().

      Each coefficient's estimate divided by its standard error (the square root of the covariance's diagonal), with a t test on df degrees of freedom or a z test. The default df is the residual degrees of freedom of an lm and Infinity (z tests) for a glm of every family, as lmtest (unlike glmSummary, which uses t tests where the dispersion is estimated). A covariance whose diagonal has a negative, NaN or infinite variance is an error (R gives NaN); only the diagonal is used (the matrix is not checked for symmetry, as R's). For a result of vcovHC or vcovCL (or the fit's own covariance) the standard errors come from the covariance in units of powers of 2, so they are right where the matrix holds Infinity or 0 (a response around 1e±300). That record belongs to the matrix object returned: a copy of it (vcov.map((r) => r.slice()), structuredClone, JSON) loses it and gives the values the copy holds (se 0, z Infinity and p 0 where it holds 0); pass the result or its original matrix instead.

      Parameters

      Returns CoeftestResult

      const fit = lm([1, 2, 3, 4, 5, 6], [1.1, 2.3, 2.8, 4.5, 4.9, 6.4]);
      const t = coeftest(fit, { vcov: (f) => vcovHC(f, { type: "HC1" }) });
      t.stdError; // [0.17608, 0.049777]
      t.pValue; // [0.72421, 0.0000324]