Skip to contents

Returns predictions from an ame_als or lame_als fit: the fitted linear predictor on the link scale (type = "link") or the response scale (type = "response", the default).

Usage

# S3 method for class 'ame_als'
predict(
  object,
  newdata = NULL,
  type = c("response", "link"),
  plug_in = NULL,
  ...
)

Arguments

object

an ame_als object.

newdata

optional dyadic covariate array matching object$X ([n_row, n_col, p, T]); a matrix or 3D array is coerced.

type

"response" (default) or "link".

plug_in

logical; for an empirical-Bayes fit, return the plug-in values (TRUE: the link at the fitted predictor, the posterior mean) or the predictive ones that integrate the link over the uncertainty of the predictor (FALSE). The default is TRUE for a Poisson fit and FALSE for a binary fit.

...

ignored.

Value

A matrix (cross-sectional) or list of matrices (longitudinal).

Details

With newdata = NULL the training-data fitted values are returned. Supplying newdata – a dyadic covariate array with the same actors and dimensions as the fitted design – substitutes the dyadic covariate contribution while holding the intercept, additive effects and multiplicative term fixed; it predicts counterfactual dyadic covariates for the same network, not out-of-sample actors.

For a binary fit the response-scale predictions are predictive probabilities: the response integrated over the posterior of the linear predictor, \(\Phi(m / \sqrt{1 + v})\) for a probit link, rather than applied at its mean (see Predictions in ame_als). For a Poisson fit they are the plug-in mean counts \(e^{m + v_e / 2}\), as the samplers report them: the posterior predictive mean of a count is not finite in this model (the inverse-gamma tail of \(v_e\), the inverse-Wishart tail of the scale of the factors for a cell the data do not inform), and the plug-in mean is finite everywhere. plug_in = FALSE returns, for a count, the mean that integrates the predictor, \(e^{m + (v + v_e) / 2}\), and plug_in = TRUE, for a binary fit, the link applied to the fitted predictor, which is what fit$fitted and simulate() hold. type = "link" returns the posterior mean \(m\) of the predictor. A normal fit's response is its predictor plus Gaussian noise: its predictions are the posterior mean of the predictor, with or without plug_in. Predictions for a design given in newdata add the coefficients' contribution to the same posterior.