Takes the posterior-mean (or point-estimate) prediction matrix
from a lame::ame() / lame::ame_als() / amen::ame() fit and
wraps it as a netify so the predictions can be summarized, plotted,
or compared to the observed netlet via compare_networks().
Usage
from_lame_fit(
fit,
value = c("fitted", "residual", "prob", "prob_lower", "prob_upper", "fitted_lower",
"fitted_upper"),
symmetric = NULL,
alpha = 0.05
)Arguments
- fit
A fitted object from
lame::ame(),lame::ame_als(),lame::lame(), oramen::ame(). Must expose a fitted-value matrix (e.g.,fit$EZ,fit$ZpostMean, orfitted(fit)). Forvaluein"prob_lower"/"prob_upper"/"fitted_lower"/"fitted_upper"the fit must additionally expose a per-draw array of fitted values. The slots searched, in order, are:fit$BOOT$EZandfit$BOOT$Y_hat(lame ALS parametric / block bootstrap), thenfit$EZ_draws,fit$EZps, andfit$Z_draws(Gibbs posterior draws), with shape[n, n, B]or[n, n, T, B].- value
One of
"fitted"(default — posterior-mean linear predictorEZ/ZpostMean),"residual"(observed - fitted),"prob"(logistic / probit -> probability scale, when the family supports it), or"prob_lower"/"prob_upper"/"fitted_lower"/"fitted_upper"(per-cellalpha/1-alphaquantiles across bootstrap or posterior draws). Whenlameexposes afitted()method for the object, that's preferred. Forvalue = "prob"with a binary family, link detection follows this priority: (1) any explicitlinkslot on the fit (orfit$control$link); (2) ALS class (any token containing "als") orfit$fit_method = "als"-> probit, matchinglame::ame_als(); (3)lameclass -> logit, matchinglame::lame()Gibbs default; (4)ame/amenclass (and nofit_method = "logit"override) -> probit, matchingamen::ame()Gibbs convention; (5) otherwise logit fallback.- symmetric
Logical. Override the inferred symmetry; default reads from the fit's stored
mode/Y.- alpha
Numeric in (0, 0.5). Tail probability for the
*_lower/*_upperquantiles. Default0.05-> 90% interval (lower = 0.025, upper = 0.975 when interpreted as a two-sided CI; here we use lower = alpha/2, upper = 1 - alpha/2).
Value
A cross-sectional netify object whose underlying matrix is the fitted-value (or residual) matrix at the same actor ordering.
Details
Useful for posterior-predictive checks: build the observed netlet,
run an AME fit, then from_lame_fit(fit) |> plot(style = "heatmap")
to visualize the fitted intensity matrix.
Examples
if (FALSE) { # \dontrun{
lm_in <- to_lame(net, fit_method = "als", bootstrap = 200)
fit <- lame::ame_als(Y = lm_in$Y, mode = "bipartite", family = "binary",
bootstrap = 200)
# round-trip predictions back into a netify for plotting
pred_net <- from_lame_fit(fit, value = "prob")
plot(pred_net, style = "heatmap")
} # }