Generate predictions from fitted AME models, including point estimates and predictive distributions.
Arguments
- object
Fitted AME model object
- newdata
Optional dyadic covariates for prediction: a single 3-D array (
n x n x p_dyad) whose slices match the dyadic covariates the model was fit with (same order; do not include the intercept or nodal-covariate slices). Nodal covariates cannot be changed at prediction time – their fitted contribution is reused. When omitted, the fitted design is used. Explicit ordinal response predictions average numeric category expectations over matched predictor and cutpoint draws. Newdata predictions require saved draws for enabled additive and latent effects; disabled effects and zero latent rank require no such draws.- type
Character; type of prediction:
"response": predicted values on response scale (default)
"link": predicted values on link scale
"distribution": full posterior predictive distribution
- n_samples
For type="distribution", number of posterior samples
- include_uncertainty
Logical; include joint parameter uncertainty (default TRUE). Requires aligned additive and latent draws saved through
posterior_options(save_ab = TRUE, save_UV = TRUE). With FALSE, only observation noise is simulated around the fitted mean predictor.- ...
Additional arguments (not used)
Value
Depending on type:
"response"/"link": Matrix of predictions
"distribution": Array of posterior predictive samples
Details
Without newdata, type = "response" returns the
stored YPM (see fitted.ame).
For MCMC Poisson models the response is the mean count of a cell,
\(\exp(\eta + \sigma^2 / 2)\), at the posterior mean \(\eta\) of its
linear predictor and the posterior mean \(\sigma^2\) of the residual
variance (the model is \(Y \sim \mathrm{Poisson}(\exp(z))\),
\(z \sim N(\eta, \sigma^2)\)). The stored YPM holds it, and
newdata predictions use the same form at the new linear predictor.
type = "distribution" draws counts from the posterior predictive
distribution instead.
Examples
# \donttest{
# Fit model
data(YX_nrm)
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- ame(YX_nrm$Y, Xdyad = YX_nrm$X, R = 2,
nscan = 100, burn = 10, odens = 1, verbose = FALSE, chains = 1)
# Point predictions
Y_pred <- predict(fit)
# Predictions on link scale
Y_link <- predict(fit, type = "link")
# }