This function allows to produce predictions specifying those variables that define the margins of the hypertable to be predicted (argument D). Predictions are obtained for each combination of values of the specified variables that is present in the data set used to fit the model. See vignettes for more details.
For a rank-reduced fit, predict(fit, D="locale:cultivar",
observed=TRUE) constructs sparse averages directly from retained observed
combinations, without generating the locale-by-cultivar Cartesian product.
Returned rows are ordered by first appearance unless levels specifies
their order. Missing-response rows excluded from the fit cannot create
prediction rows. An observed marginal prediction, such as
D="locale", averages the fitted fixed predictor using the observed
records in each locale; it is not an equally weighted or cultivar-adjusted
comparison. Estimability is checked before covariance computation.
Manual random contributions are added in the same public coefficient
coordinates as explicit contrasts, so their prediction-error, sampling
covariance and pairwise calculations follow the usual Henderson path.
When include=TRUE alone has random-level restrictions, omitted
coefficient contributions are zeroed without renormalizing the empirical
group weights. Use include=TRUE, average=TRUE for equally weighted
selected co-occurring indicator levels.
For categorical structured random terms, the fitted covariance-coordinate
and main-effect levels define the genetic prediction weights, even when a
cell has no observations. The levels argument can additionally request
fitted levels present only in Gu. Unsupported random designs that
cannot be mapped for all prediction rows produce a warning; an explicit
D matrix can be used for these designs.
Numeric fixed terms, including factor-by-covariate interactions, are
evaluated using the fitted fixed formula and contrasts. Unless overridden,
each numeric variable is set to its mean in the retained fitting data.
Factor levels are equally weighted when averaged. Thus an averaged
Env:cov term with one slope per environment uses
mean(cov)/nlevels(Env) for each slope, not 1/nlevels(Env).
Write \(D=[L_b,L_u]\). The target is \(t=L_b\beta+L_u u\) and its
predictor is \(\hat t=L_b\hat\beta+L_u\hat u\). The existing
prediction PEV and VarU matrices are for the linear
combinations represented by the final returned D, after applying
Dtable and levels, not copies of model-level effect variances.
Each covariance matrix has one row and column per requested prediction.
The existing
vcov, optional PEV, and squared std.error refer to
\(\operatorname{Var}(t-\hat t)\), not generally to
\(\operatorname{Var}(\hat t)\). They are computed from
$$\operatorname{Var}(t-\hat t)=D C_0^{-1}D',$$
where \(C_0\) is the original-scale Henderson coefficient matrix defined
in postVarU. The stored system C is solved against
contrast transposes and the result multiplied by Cscale. Arbitrary
contrasts work regardless of computeCi; no stored Ci is used.
With \(Q=(C_0^{-1})_{uu}\) and \(B=(C_0^{-1})_{bb}\), the new outputs are
$$\mathrm{VarU}=L_u(G-Q)L_u',$$
$$\mathrm{sampling.vcov}=L_b B L_b'+L_u(G-Q)L_u'.$$
The BLUE and BLUP have zero sampling cross-covariance, whereas the
fixed/random blocks of the inverse Henderson matrix describe error
covariance and generally are not zero. In particular, subtracting the full
target PEV from \(L_uGL_u'\) is incorrect if fixed effects are included.
A fixed-only prediction has zero VarU, but generally nonzero
sampling.vcov and PEV. Random-only predictions satisfy
\(L_uGL_u'=\mathrm{PEV}+\mathrm{VarU}\).
The implementation batches full, random-only and fixed-only contrasts into
one Henderson factorization. Prior products use the term structure
\(G_k=\Sigma_k\otimes A_k\) and sparse relationship-precision solves.
Neither the observation covariance \(V\) nor its inverse is constructed.
Additional matrices require quadratic storage in the number of predictions.
Rotation and factor-score mappings operate in public effect coordinates.
New fits retain relationship precisions; older ordinary fits attempt model
input reconstruction as described in postVarU.
All covariance outputs use the fitted variance components as fixed,
omitting their estimation uncertainty. They are exact for known components
and plug-in approximations for estimated components, for both ML and REML.
SEDs, pairwise tests and std.error retain their PEV-based meaning;
enabling VarU does not change those calculations. Direct and matrix-free
solveOnly fits lack the stored coefficient system required here.