The object returned by glmer (not a copy of it).
Optionaloptions: GlmerPredictOptions
newdata, reForm, allowNewLevels, randomOnly, type, seFit and newoffset (see
GlmerPredictOptions).
const data = {
y: [2, 3, 6, 7, 8, 1, 0, 3, 2, 5, 4, 6, 9, 8, 13, 0, 2, 1, 4, 3],
x: [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
g: ["a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "d", "d", "d", "d", "d"],
};
const fit = glmer("y ~ x + (1 | g)", data, { family: "poisson" });
glmerPredict(fit, { newdata: { x: [6], g: ["c"] }, type: "response" }).fit; // [17.970]
glmerPredict(fit, { newdata: { x: [6], g: ["c"] }, reForm: false }).fit; // [2.1967]
Predictions of a generalized linear mixed model fitted by glmer, at the rows of the fit or at new data, with all, some or none of the random-effects terms, on the link or the response scale, optionally with their standard errors. Equivalent to
lme4::predict()in R.The rules are those of lmerPredict, with the offset: without
newdatathe fit's; with it, an offset given to glmer as a column name is read from that column ofnewdata, one given as an array is replaced bynewoffset(default 0: R ignores glmer'soffsetargument in prediction).type: "response"applies R's inverse link (at the fit's rows with all terms, the fitted means). The standard errors use the Fisher weights at the conditional mode, with R's warning that they are an approximation; on the response scale they are multiplied by |dμ/dη|.