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

    Function lmerPredict

    • Predictions of a linear mixed model fitted by lmer, at the rows of the fit or at new data, with all, some or none of the random-effects terms, optionally with their standard errors. Equivalent to lme4::predict() in R.

      The prediction of a row is x'β̂ + Σ z'b̂ over the selected terms, x built from the row as the fit built its fixed-effects matrix (its terms, contrasts, factor levels and dropped columns) and b̂ the conditional mode of the row's level. A missing value in a variable gives NaN for its row; a factor level of the fixed part that the fit did not have is the RangeError factor <name> has new level <value> (R: non-conformable arguments). The standard errors are those of the conditional covariance σ² A K⁻¹ A' of (b, β) at θ̂ (Henderson's equations), computed correctly also where lme4's are wrong (crossed grouping factors, some reForm subsets).

      Parameters

      Returns MixedPrediction

      const data = {
      y: [9.8, 10.4, 10.1, 12.3, 12.9, 12.0, 8.1, 7.6, 8.4],
      g: ["a", "a", "a", "b", "b", "b", "c", "c", "c"],
      };
      const fit = lmer("y ~ 1 + (1 | g)", data);
      lmerPredict(fit, { newdata: { g: ["a", "c"] } }).fit; // [10.101, 8.0565]
      lmerPredict(fit, { reForm: false }).fit[0]; // 10.178