Skip to contents

Fits an additive and multiplicative effects (AME) model to a single cross-sectional network by iterative block coordinate descent, producing fast estimates with standard errors and no MCMC. For normal, binary and Poisson data the estimator is an empirical-Bayes / variational estimator of the model that ame samples (see Empirical-Bayes estimator in Details); its vcov() and confint() are Laplace approximations, and every reported variance component, actor effect, latent position and product cell carries a standard error.

The estimation algorithm adapts the iterative block coordinate descent estimator of the Social Influence Regression (SIR) model of Hoff & Minhas (the algorithm implemented in sir::sir_alsfit() and nicknamed "ALS" in that package) to the AME model. It is a port and adaptation, not original lame methodology.

Usage

ame_als(
  Y,
  Xdyad = NULL,
  Xrow = NULL,
  Xcol = NULL,
  R = 0,
  family = "normal",
  mode = c("unipartite", "bipartite"),
  symmetric = FALSE,
  max_iter = 200,
  tol = 1e-06,
  link = c("probit", "logit"),
  linear_solver = c("eigen", "qr", "auto"),
  multistart = c("none", "cheap", "full"),
  bootstrap = 0L,
  bootstrap_type = c("parametric", "block"),
  bootstrap_block_length = 1L,
  bootstrap_seed = NULL,
  verbose = TRUE,
  seed = 6886,
  dcor = !symmetric,
  prior = NULL
)

Arguments

Y

a square (unipartite) or rectangular (bipartite) relational matrix. A cross-sectional netify object is also accepted and converted with netify::to_lame(); when family or mode is omitted, the value inferred by netify is used.

Xdyad

an n_row x n_col matrix or n_row x n_col x pd array of dyadic covariates, or NULL. A 2-D matrix is wrapped as a single slice named after the argument expression, so Xdyad = distance yields the coefficient distance_dyad, the same name ame gives it.

Xrow

an n_row x pr matrix of row/sender covariates, or NULL. In a symmetric model (symmetric = TRUE) each node covariate enters a dyad through both of its actors.

Xcol

an n_col x pc matrix of column/receiver covariates, or NULL. In a symmetric model a node covariate may be given in Xrow, in Xcol or in both, and each distinct covariate enters once, as <name>_node.

R

integer dimension of the multiplicative effects (default 0). The covariate coefficients are conditional on this choice. The multiplicative term \(u_i'v_j\) is a flexible high-variance regressor that can correlate with the dyadic covariates, so the estimated beta can shift – and occasionally change sign – as R increases. Comparing against an R = 0 fit is a useful check on whether the covariate story is being driven by the latent rank.

family

one of "normal", "binary", or "poisson". The ordinal family is MCMC-only.

mode

"unipartite" (square) or "bipartite" (rectangular).

symmetric

logical; fit a symmetric (undirected) model. Unipartite only. Every dyadic covariate slice must be symmetric: an asymmetric one is an error of class lame_symmetric_xdyad that names the slice (and, for a panel, its first period), as in ame and lame.

max_iter

maximum number of block coordinate descent iterations (default 200), and maximum number of outer reweighting steps for IRLS. A fit that does not settle within it follows the rank rule of Choosing the rank in ame_als (a retired column, or a warning of class "lame_als_unsettled"); with max_iter below 200 a stop at the limit is not retired but continued, then returned at its last iterate with that warning. A reweighting step runs at most five sweeps (it refreshes the weights, the Laplace correction and the variance updates after them). The variational stage runs at most 20 * max_iter iterations (2 * max_iter with options(lame.eb_scale = "plugin")). A fit whose iteration does not settle retires its weakest latent column and fits the next rank down when that fit's lower bound is at least as high (see A rank the data do not support); a max_iter below 200 disables that for an iteration that merely ran out of it.

tol

convergence tolerance on the relative change in residual sum of squares (default 1e-6). IRLS additionally requires the largest penalized likelihood score, scaled by the square root of its Fisher information plus penalty curvature, and the largest absolute log variance update to be at most sqrt(tol).

link of a binary fit: "probit" (default; matches ame/lame) or "logit". poisson always uses the log link; ignored otherwise.

linear_solver

solver for the regression block: "eigen" (default) eigendecomposes the normal equations; "qr" uses a QR factorisation of the observed design, which is more stable for ill-conditioned covariates; "auto" picks "qr" when the design is ill-conditioned but full rank. All give the same answer for well-conditioned designs.

multistart

for R > 0 (a non-convex objective), "none" (default) fits from a single deterministic start; "cheap" (4 starts) and "full" (8 starts) also try random low-rank starts and keep the converged start with the lowest value of the criterion, evaluated at that start's own scales: the Laplace marginal likelihood of the start, minus twice its logarithm ("Laplace marginal likelihood"; see Choosing the rank), which integrates the effects and the factors and does not move with the scale of a factor column the data do not use (with the default variational stage every start is refined, and starts of different modes end at the same variational fit, so they neither differ in multistart_distance nor warn). When a converged start has no marginal likelihood the starts are rated by the empirical-Bayes objective, the penalised deviance plus the penalty of the actor effects, the log determinant of their information and the hyperprior of their covariance ("empirical-Bayes objective"). The raw deviance is not compared: it always favours the least-shrunk optimum, the one with the largest scales. The criterion (multistart_criterion), its value for each start (multistart_sse; the objective includes the hyperprior, which objective leaves out), each start's observed-data deviance at its posterior mode (multistart_deviance; deviance is that of the reported fit), its distance from the kept start (multistart_distance) and its convergence are recorded. The distance is the squared difference of the two fitted linear predictors, weighted by the mean of the two IRLS weights and summed over the observed cells: an approximation of the change in the deviance between the two fits. When a converged start is more than one deviance unit away from the kept one, the best such start is refined as the kept start was and its reported coefficients are compared with the kept fit's: the fit warns of materially different local optima (class "lame_als_multistart"), saying how many standard errors apart they are, only when some coefficient differs by more than 0.1 of its standard error (or the alternative could not be refined). Starts at different modes usually refine to the same reported fit, and then the fit does not warn. Starts that end at the same fitted values can still differ in the penalised objective, which depends on the scales of the factors, and those settle more slowly than the fitted values (the Laplace marginal likelihood differs far less); that difference does not warn. Every multistart fit also keeps the coefficients each start reports (multistart_coefficients) and the distance of each start's multiplicative surface from the kept start's (multistart_product_distance), so that the spread of the estimates across the starts can be read from the fit. Reproducible given seed; the global RNG stream is left unchanged.

bootstrap

integer: if > 0, additionally run bootstrap replicates of the parametric or block bootstrap (via ame_als_bootstrap) after the fit and attach the result as fit$bootstrap. The downstream accessors (vcov.ame_als, confint.ame_als, summary, print) then report the bootstrap standard errors and intervals of the coefficients; a quantity the bootstrap gives none for keeps its analytic error, and fit$bootstrap$se_source names it with the reason. At least 30 replicates are needed: a smaller positive number is an error of class "lame_als_bootstrap_replicates" raised before anything is fitted. A bootstrap that cannot run on the fitted model (too few valid replicates, for example) leaves the fit with its analytic standard errors and a message (class "lame_als_bootstrap_not_run"); fit$meta$bootstrap_not_run records the reason. Default 0 (no bootstrap): every fit already carries analytic standard errors.

bootstrap_type

character: "parametric" (default) or "block" – the bootstrap scheme to use when bootstrap > 0. The block scheme gives no replicate standard error for the parameters that resampling time slices cannot vary (the node-covariate coefficients and the variance components of the actor effects, among others), which keep their analytic errors; on a panel too short for ten blocks it runs the parametric scheme, with a message. See ame_als_bootstrap.

bootstrap_block_length

integer: block length for the block bootstrap; only used when bootstrap_type = "block".

bootstrap_seed

optional integer seed for the bootstrap (the point fit uses seed).

verbose

logical; print progress (default TRUE).

seed

random seed (default 6886) for the random starts of multistart = "cheap" / "full"; the caller's random number state is restored afterwards. The block coordinate descent itself is deterministic, so with multistart = "none" the point estimate does not depend on it.

dcor

logical; whether a directed binary probit, Poisson or normal fit models the dyadic correlation of the latent errors of the two cells of a dyad, as ame and lame do with their dcor = TRUE. The default is !symmetric, the default of the samplers. For a binary fit the correlation is part of the model that is fitted: the two cells of a dyad are one bivariate probit observation, fit$VC["rho"] is the correlation of that model, and the factors, the standard errors and the predictions are those of the model (see Dyadic correlation in Details). dcor = FALSE fits independent cells and reports the correlation of the pairs of cells at the fitted predictor. A directed count fit takes the pairs at its fitted state (see Dyadic correlation of counts in Details), and a directed normal fit takes the two cells of a dyad as one bivariate normal observation, in closed form (see Dyadic correlation of normal data in Details; it costs 1.3 to 1.6 times the independent-cell fit). A fit that has no pair likelihood (undirected and bipartite networks) keeps its own estimate of rho; an explicit dcor = TRUE with the logit link is an error, because the latent correlation is that of normal errors. The fast route holds the correlation off the boundary with a prior of density proportional to \(1 - \rho^2\); the samplers' prior is flat. The pair likelihood of a binary or count fit costs 1 to 2.5 times the independent-cell fit for one period and 2 to 4.5 times for four, in proportion to the number of dyads and periods; dcor = FALSE is the fast path for very large networks. A directed normal network whose reciprocal pairs are all exactly equal (an undirected network given as a directed one) has an improper posterior for the correlation under the fast route's prior, and is refused as ame refuses it (class "lame_improper_normal_reciprocity"): fit it with symmetric = TRUE, or with dcor = FALSE.

prior

NULL or a named list of priors. The estimators read one key, s20, the scale of the inverse-gamma prior of the variance of the noise of a Poisson or a normal fit (one degree of freedom on s20; by default a normal response has the variance of the observed responses, the prior ame and lame draw it under, and a count has no scale on the variance (zero degrees of freedom, so no value pulls it). The other keys of the samplers' prior list have no counterpart in the estimators; they are reported and ignored. The prior of the multiplicative effects of a directed network is the samplers' default (ame, Suv0 and kappa0).

Value

An object of class "ame_als": a list with the point estimates. When R > 0 the fitted multiplicative surface is exposed as UVPM (U L U'} for symmetric fits, which also carry it as \code{ULUPM}; \code{U V' otherwise), matching the slot names on MCMC fits. estimates mu, beta, a, b, U, V (L for symmetric models), the linear predictor EZ, response-scale fitted values, working-scale residuals, convergence information, and the variance-component vector VC. Every fit also carries the uncertainty of every reported estimate: a_sd and b_sd, the posterior sds of the reported actor effects; U_sd and V_sd, of the reported positions, with the directions that leave the product unchanged left out (and L_sd of the eigenvalues of a symmetric fit); UVPM_sd (and ULUPM_sd), of each cell of the reported product, all by the delta method under the joint Laplace covariance of the coefficients, effects and factors carried through the identified report; and VC_se with the 95\ components (the inverse Fisher information of the marginal likelihood of the effect covariance, the inverse-gamma posterior of a normal noise variance less the effective number of mean parameters, the marginal-likelihood profile of a count noise variance and the pair likelihood of rho; intervals on the log scale for variances (centred at the median for the effect variances, whose values are posterior means), the Fisher z scale for rho and score-type, inside its bound, for cab; NA where a component is fixed by the model or not identified). R is the rank of the fit; where the data did not support the rank asked for and columns were retired, R_requested (present only then) is the rank that was asked for (see A rank the data do not support). For IRLS, irls_iterations counts accepted outer reweighting steps; iterations counts the reweighting steps of the final solve. irls_diagnostics records the score and variance checks, their threshold, the stopping reason, and each accepted step's improvement under a common factor penalty. A changing empirical factor variance means successive penalized objective values need not decrease; a step is also accepted when it lowers the residual of the estimating equations that the checks evaluate. A fit that does not pass the checks within max_iter follows the rank rule of Choosing the rank. A part of the fit that could not be computed (an evidence, a covariance term) is named, with its first error, in numerical_failures and in a warning of class "lame_als_numerical_fallback"; a step that took an exact alternative or a valid default is counted in exact_fallbacks. Neither field is present when nothing happened. eb is a list: sab, the fitted covariance of the actor effects (a \(2 \times 2\) matrix; an undirected fit has one variance and repeats it on the diagonal), Sab0 and eta0, the scale and degrees of freedom of its inverse-Wishart prior, gamma, the coefficients of the node covariates in the prior mean of the effects, sab_change, the relative change of sab in the last update, sig2_u and sig2_v, the fitted scales of the factor columns (one value per column and side; the isotropic scale of a directed fit repeated, the unit receiver scale of a bipartite fit, one scale per column of an undirected fit), mu_int, a_raw and b_raw, the intercept and the effects as the posterior is built from them (the effects are not re-centred), log_marginal, the Laplace log marginal likelihood at the posterior mode (see Choosing the rank in Details), vcov and vcov_cond, the Laplace covariance of the coefficients (intercept, dyadic and node-covariate) jointly with the effects and the latent factors and conditional on the factors, se, the square roots of the diagonal of vcov, se_method and vcov_error, the reason when the covariance could not be computed (the fit is then an error of class "lame_als_vcov"), population, the population intercept and its covariance beside the reported intercept, for a fit with a latent product report_fold, the fitted state of the intercept, effects and positions (state) beside the reported values (report) and the means of the product that moved (const, a_row, b_col), estimator, which estimator produced the reported values ("variational", the default, or "laplace", the posterior mode alone), variational, the record of the variational iteration (converged, termination, iterations, residual, the largest step a full update would still take, and gain, the objective's gain at the last step; step, the step length; tolerance; elbo, the evidence lower bound at the plug-in scales, with ell, kl_actors and kl_factors; information, the training events, the loadings and the events per loading of a binary or count fit with a latent rank, with signal, the double-centred fitted product squared and weighted by the fisher weight of each observed cell, signal_per_loading and threshold, 2.1, below which the data barely determine the product (a normal fit: signal, the squared norm of the double-centred fitted product summed over the periods, loadings, per_loading, the signal in noise variances per loading, and threshold); scale, the rule that set the scale of the prior of the factors ("cavity" or "plugin"), the scale s (the mean over the columns of a bipartite or undirected fit), the correlation rho of the sender and receiver position of an actor (directed) and sd_log, the standard deviation of the log scale that vcov() carries; start, mode_log_marginal; uncertainty_terms, which refits gave each refit term of the standard errors, scale (the factor-prior scale) and components (the variance components of a binary fit): "first try", "retry" (half the step, four times the iteration budget), "dropped" (left out, with the warning "lame_als_numerical_fallback") or "not run" (latent factors that fit observed cells with probability 1)), factor_posterior, the covariances of the posterior of the factor rows (arrays Sig and Om, or Sig and the factor F with its signs sg for an undirected fit; the cavity covariances, with the covariances of the fixed point of the updates beside them as Sig_mf and Om_mf) and the prior of the fit, suv, the fitted \(2R \times 2R\) covariance of the factor rows of a directed network, laplace, the parts of log_marginal, and, for a directed binary probit fit with a dyadic correlation, pair: the correlation rho, its posterior standard deviation sd, the score and curvature of the expected log likelihood in it, the number of dyads with both cells observed n_pairs, the nodes a side of the quadrature quad (zero for a normal pair, which has none), the rules the quadrature was refined to after a stall refined (empty where it was not) and the expected cross weights of the pairs; retirement, present only when columns were retired: a list with the requested_rank, the effective_rank (the columns reported), the fitted_rank and its empty_columns (columns without product dropped from the report, whose fitted state is kept in dropped), whether the fit of the effective rank settled, and steps, one record per retired column (the rank it was retired at, its column, its strength and share of the strongest column, and the stage, termination and iterations of the iteration that did not settle, and the reason: "lower bound", the next rank down scored at least as high, or "not formed", the rank scored higher but its estimates could not be formed, or "bootstrap", the rank scored higher but the call asks for a bootstrap, which needs a settled fit, or "no product", the columns of a settled rank carry no product and are dropped from the report with no refit, refit = FALSE); unsettled, present only when the fit is the last iterate of a rank that did not settle: its rank, iterations, stage, termination, and the lower bounds of that rank (elbo) and of the next rank down (elbo_lower, NA when that rank has none), and lower = "none" when no lower rank was compared; for a normal fit, ve, the variance of the noise (also VC["ve"] and fit$s2) and ve_prior, the degrees of freedom and the scale of its prior; and, for a Poisson fit, ve, the variance of the lognormal noise of the count (also VC["ve"], fit$s2 and fit$pois_latent_var), and ve_search, the search that found it: ve, objective (the Laplace log marginal likelihood plus the log prior density of ve at the maximum), curve (a data frame of the values tried: ve, objective, whether the mode there solved its equations and its iterations) and evaluations. A fit with multistart = "cheap" or "full" (and R > 0) also records, for each start, multistart_converged, multistart_criterion and multistart_sse (the value of that criterion), the kept start multistart_selected, multistart_deviance and multistart_distance (the distance of the fitted predictor from the kept start's, in deviance units), multistart_coefficients, a starts by coefficients matrix of what each start reports (intercept, dyadic and node-covariate coefficients, with the names and on the scale of coef(fit)) whose row for the kept start is coef(fit), and multistart_product_distance, the Frobenius norm of the difference between the UVPM each start reports and the kept start's, over the norm of the kept start's: zero for the kept start. A kept UVPM of no size, when the factors of the starts shrink to nothing, is measured against sqrt(.Machine$double.eps), so that starts that agree there are at distance zero. The surfaces themselves are not stored. When a converged start ended more than one deviance unit from the kept one, multistart_alternative holds the best such start (start), its distance and criterion excess (distance, excess), the coefficients it reports once refined (coefficients), their difference from coef(fit) in the kept fit's standard errors (se_difference, max_se_difference), the tolerance (0.1) and whether the fit warned (warned). The variance-component vector has five descriptive entries:

va, vb

variances of the sender and receiver additive effects: the fitted variances of the effects themselves (fit$eb$sab), the quantity ame / lame report. The empirical variances of the reported effects are kept as vc_raw.

cab

fitted covariance of the sender and receiver effects (NA for symmetric or bipartite models).

rho

dyadic reciprocity, distinct from the sender/receiver correlation cor(a, b). For a directed binary probit fit with dcor = TRUE it is the correlation of the fitted model (Dyadic correlation), and rho_estimation holds its posterior standard deviation and method = "variational pair likelihood". For a directed binary fit with dcor = FALSE, this is the Gaussian copula correlation estimated from the paired binary likelihood at the reported marginal probabilities. With a probit link it is the latent error correlation. The working-residual correlation is retained as rho_working; rho_estimation records the number of reciprocal pairs, likelihood, and boundary or unidentified state. Without informative reciprocal pairs rho is NA and conditional network simulation is refused. A directed count fit with dcor = FALSE estimates the latent correlation from the weighted count covariance identity \(\mathrm{cov}(Y_{ij}/\mu_{ij}-1,Y_{ji}/\mu_{ji}-1) = e^{\rho v_e}-1\) (independent Poisson noise contributes to the marginal variances but not this covariance); with dcor = TRUE it estimates the correlation from the pairs, see Dyadic correlation of counts. With zero latent variance, correlation is unidentified and independent count simulation remains valid. A normal fit with dcor = FALSE uses the reciprocal residual correlation.

ve

residual variance on the model's own scale, the quantity of the MCMC posterior-mean s2. For a normal fit it is the fitted variance of the noise (see Normal data). For a binary fit the probit/logit model fixes the latent error variance at 1 by identification, so ve is reported as 1; the working-scale GLM dispersion (about 1 under correct specification) is kept separately as ve_working. For a poisson fit ve is the variance of the lognormal latent layer of the model ame / lame fit (\(y \sim \mathrm{Pois}(e^{z})\), \(z \sim N(\eta, v_e)\)), estimated by maximising the Laplace marginal likelihood (see Counts).

These are estimates, not summaries of posterior draws. Their standard errors and 95\ vcov.ame_als gives the covariance of the regression coefficients and ame_als_bootstrap bootstrap uncertainty.

Details

Sparse and dense binary networks. A binary network whose observed density \(d\) (the share of observed cells that are ties, the diagonal of a one-mode network left out, pooled over the periods of a panel) has \(\min(d, 1 - d) < 0.20\) is fitted by the fast route with a warning (class "lame_fast_binary_density"): there its slopes are pulled toward zero, its intercept is biased and its intervals cover less often than stated, and the sampler (ame) is the better choice.

The AME decomposition $$z_{ij} = \mu + \beta' x_{ij} + a_i + b_j + u_i' v_j + \epsilon_{ij}$$ is conditionally linear: it is a linear regression in \((\mu, \beta, a, b)\) for fixed multiplicative factors \((U, V)\), and the optimal rank-R \((U, V)\) for fixed \((\mu, \beta, a, b)\) is the truncated SVD of the residual matrix. The estimator therefore cycles, until the residual sum of squares stabilises, through three blocks — each a monotone (objective-non-increasing) update: a joint least-squares solve for the intercept \(\mu\) and regression coefficients \(\beta\) (an exactly rank-deficient design is refused with an error of class "lame_design_rank" that names the aliased columns); an exact solve of the additive effects \((a, b)\) (Gauss-Seidel sweeps started from the direct solution of their normal equations, and an exact eigen solve wherever the sweeps do not reach the normal equations, as on a weakly connected observed-dyad graph; a residual above the tolerance after the exact solve stops the fit with an error of class "lame_als_numerical"); and a weighted low-rank update for the multiplicative factors \((U, V)\) via SVD (eigen-decomposition when symmetric = TRUE). The weighting makes the multiplicative step correct for unbalanced longitudinal panels (dyads observed at unequal numbers of time points); severely unbalanced panels converge in more iterations. A fit that does not settle is handled by the rank rule of Choosing the rank below: its weakest column is retired, or it is continued from its last iterate and, when it still does not settle, that iterate is returned with a warning of class "lame_als_unsettled" whose message gives the state it stopped in (iteration limit, or no step that lowers the objective) and the remedy.

A normal response is fitted by the empirical-Bayes estimator of Normal data (the Gaussian empirical-Bayes estimator) below. For "binary" and "poisson", the estimator uses an IRLS working-response path, so coefficients are on the requested link scale (binary probit/logit, Poisson log). For R > 0 the multiplicative factor block of the IRLS families solves a penalized (MAP) sub-problem: each factor row carries the ridge implied by the AME prior \([u_i, v_i] \sim N(0, \Sigma_{uv})\), with the per-column prior scale estimated by an EM step (the analog of the MCMC \(\Sigma_{uv}\) draw). This is what makes the estimate well-defined: the unpenalized rank-R binary MLE does not exist under quasi-separation, and fitting it directly inflates every coefficient (a runaway that grows with R, with the latent variance diverging). With the penalty the latent variance does not run away.

Empirical-Bayes estimator. A binary, Poisson or normal fit treats the sender and receiver effects as the MCMC ame / lame do, as draws from a Gaussian prior \((a_i, b_i) \sim N(0, \Sigma_{ab})\) (an undirected fit has one effect per actor and a scalar variance, a bipartite fit independent sender and receiver variances), instead of as free fixed effects, and estimates the model by empirical Bayes in two stages. The first is the posterior mode with a Laplace correction, in three parts. (1) The IRLS working problem carries the penalty \(\sum_i \alpha_i' \Sigma_{ab}^{-1} \alpha_i\), where \(\alpha_i\) is the actor's effects less the part its node covariates explain (the node-covariate coefficients are fixed effects of the prior mean, as in the MCMC model); the factor block is the penalised ridge above, whose scales are updated by EM from the posterior second moments of the factors, an undirected fit's too, except that a bipartite fit holds its receiver factor at unit scale, the prior of its variational stage below, and updates only the sender scales (with both scales free the product can move along \(U c\), \(V / c\) at almost no cost and the mode drifts). At every reweighting step the intercept, the coefficients and all the effects are solved jointly and exactly from dyad-level sums, in one dense system with no centring step. (2) \(\Sigma_{ab}\) is updated by an EM step from the effects and their Laplace covariance, under the inverse-Wishart prior that lame() puts on it for binary data, so that the penalty is the MCMC prior, except that a directed network gives it the weight of one actor (the sampler's weight, with its diagonal scale, pulls the covariance of the sender and receiver effects toward zero); without a prior the update drives the variance to zero on sparse networks and with a latent term. (3) The coefficients solve the Laplace-marginal estimating equations instead of the penalised-fit ones: the score of every cell loses half the derivative of the log determinant of the effects' information (the integral over the effects). The latent factors get the same cell correction, so one objective, the penalised deviance plus that log determinant, is descended. This stage is what fit$irls_diagnostics certifies and what the marginal likelihood fit$eb$log_marginal (see Choosing the rank) is evaluated at. The mode of a binary directed one-mode fit at a latent rank starts from the rank-0 mode, with its factors at the leading singular pairs of that mode's working residual averaged over the periods with the reweighting weights (the other starts of multistart keep their random factors and start from the same rank-0 mode); a start from the rank scores with the factor ridge at the prior scale shrinks a product of moderate strength to zero, which the alternating update does not leave.

Variational posterior (the values an empirical-Bayes fit reports). The mode is the starting point of the second stage, not its result. The mode of a latent factor that the data barely identify lies at the edge of a broad posterior and is too large (it fits noise), which inflates the coefficient of a covariate that follows the product and, one rank above the generating one, the slope. The reported values (a, b, U, V, UVPM, the coefficients and the variance components) are those of a Gaussian variational posterior of the sender and receiver effects and of the factors, independent across actors and between the sender and the receiver side of the factors; the coefficients and the variance components remain empirical-Bayes point estimates. Under this posterior the predictor of a cell has a mean, the fitted predictor, and a variance, that of the effects plus that of the product, \(\hat u_i' \Omega_j \hat u_i + \hat v_j' \Sigma_i \hat v_j + \mathrm{tr}(\Sigma_i \Omega_j)\) (\(\Sigma_i\) and \(\Omega_j\) are the posterior covariances of a sender's and a receiver's factor row), and the score and the information of the likelihood are expected over that Gaussian (nine-point Gauss-Hermite quadrature) instead of taken at its mean. Every equation of the fit uses the expected score and information, and the system of a factor row adds the second moment of the other side (mean product plus covariance). The means and these covariances are the stationary point of one objective, the expected log likelihood less the Kullback-Leibler divergence to the prior, at the scale of the prior of the factors; the step of the iteration is halved when the objective would fall, which leaves the fixed point unchanged. A fit without a latent rank is variational too (the effects only). fit$eb$estimator says which estimator produced the values ("variational", or "laplace" for the mode alone), fit$eb$variational records the iteration (convergence, stop reason, number of iterations, the largest step a full update would still take, the lower bound and its parts, and the scale of the prior of the factors) and fit$eb$factor_posterior the covariances. A fit whose mode or whose iteration stops short of its fixed point follows the rank rule below: a column is retired, or the last iterate of the rank is returned with a warning of class "lame_als_unsettled" that says which stage stopped and why (fit$eb$unsettled); it is never replaced by the mode.

The scale of the prior of the factors. The rows of the factors have a Gaussian prior whose covariance the data inform weakly where there are few events per loading. The fit estimates it by the variational update of the inverse-Wishart prior ame() and lame() put on it (kappa0 degrees of freedom and scale matrix kappa0 * Suv0, the data-scaled default of ame), the inverse of the posterior mean precision, \((\Psi + SE) / (\mathrm{df} + n)\), with \(SE\) the second moments of the stacked sender and receiver rows. What second moments to use decides the result. The mean-field covariance of a row counts the uncertainty of the other side twice (the second moment of the other side in its system is the mean product plus the covariance) and is below the covariance of the exact posterior; the update evaluated there drives the scale to the floor of its hyperprior wherever the data are weak, and the product and the coefficients that follow it with it. Against an exact Gibbs sampler of the same model run at the same scale (fixed hyperparameters, 8 networks of 32 to 100 actors), the second moments of the rows were 4 to 19 percent below the sampler's at the mean-field covariances (on average 9.5). The default evaluates the update at the cavity covariances, \(\Sigma_i = (\Lambda + \sum_j \nu_{ij} \hat v_j \hat v_j')^{-1}\), where \(\nu_{ij}\) is the cavity weight of the cell, the curvature of the log likelihood integrated over its Gaussian predictor (the information the cell adds about the row once the rest of the predictor is integrated out), and these were from 9 percent below to 5 percent above the sampler's (on average 3 below); they are the covariances fit$eb$factor_posterior reports (the covariances of the fixed point of the updates, from which the lower bound and a refit start, are kept beside them as Sig_mf and Om_mf). The covariance of the stacked rows of a directed network is isotropic, one scale and one correlation between the sender and receiver position of an actor (the sampler's prior is a full \(2R \times 2R\) matrix: the scale carries one dimension of its uncertainty, see below); a bipartite fit has the priors of its sampler, the receiver factor at unit scale and, for the sender columns, the scales of \(P = U G V'\) with standard normal \(G\): the sender rows seen by the likelihood have covariance \(G'G\), a Wishart matrix with \(R\) degrees of freedom, and the scales of the columns are its ordered eigenvalues, which repel each other (the density of the eigenvalues carries the product of their differences), so a column the data say nothing about falls to the small eigenvalues of that matrix rather than staying at the scale of the prior (a binary bipartite fit reads the sender scales at the covariance of a row given drawn receivers, \((\Lambda + \sum_j \nu_{ij} (\hat v_j \hat v_j' + \Omega_j))^{-1}\): at the cavity covariances such a column kept the variance of its prior, which the probit latent scale takes as noise, and the coefficients grew with it); and an undirected fit the prior of its sampler on each column (\(U L U'\) with \(L_r \sim N(0, 1)\) and column precision \(\psi_r\) (gamma, shape 1, rate 1/2), so that a column of the factor seen by the likelihood has variance \(|L_r| / \psi_r\)). The scale is recorded in fit$eb$variational$scale (the rule, the scale, the correlation of a directed fit, and the standard deviation of its logarithm). options(lame.eb_scale = "plugin") selects the update at the mean-field covariances with a full \(2R \times 2R\) covariance and the closed-form rescaling of the factors that it needs. The option, and options(lame.eb_scale_uncertainty) below, also govern the static factors of a normal, binary or Poisson dynamic fit (lame(method = "als")), not the persistence of its moving positions.

Dyadic correlation. A directed binary probit fit with the empirical-Bayes estimator and dcor = TRUE (the default for directed networks) takes the two cells of a dyad as one observation: the latent errors of \(y_{ij}\) and \(y_{ji}\) are bivariate normal with correlation \(\rho\), and the likelihood of the pair is the bivariate normal probability \(\Phi_2(s_1 \eta_{ij}, s_2 \eta_{ji}; s_1 s_2 \rho)\), \(s = 2y - 1\). The variational posterior is taken in that model. The expected log likelihood of a pair, its score and its information (a \(2 \times 2\) matrix: the cells of a dyad are not independent given the predictors) are computed under the Gaussian posterior of the two predictors, which are correlated through the effects of the two actors, by a Gauss-Hermite rule of five nodes a side. The equations of the coefficients and of the actor effects carry the cross information of the pairs, the rows of the factors see the exact score of the pair, the cavity weights that set the scale of the factors are those of the pair probability integrated over the predictors (a bivariate normal probability in closed form), and \(\rho\) is estimated with the other hyperparameters: at every iteration it moves to the posterior mean of the quadratic approximation of the expected log likelihood in \(\rho\) under the fast route's prior, \(2\,\mathrm{Beta}(2, 2) - 1\) (density proportional to \(1 - \rho^2\)). The value is fit$VC["rho"], its posterior standard deviation and the method are in fit$rho_estimation, and the record of the pair model (the correlation, its score and curvature, the number of pairs, the quadrature) is fit$eb$pair. Against the sampler (80 simulated networks of 60 and 100 actors, one and four periods, ranks 0 and 2, with correlations of 0, 0.3, 0.6 and 0.8) the correlation is within 0.02 of the sampler's posterior mean on average and within one posterior standard deviation (0.04 to 0.1) in 79 of the 80 networks, where the post hoc correlation of the independent-cell fit is 0.02 to 0.08 too high; the slope of a covariate is within 0.2 sampler standard deviations of the sampler's on average, and its standard error 1.01 to 1.02 times the sampler's standard deviation, with or without the pair model. The factors of an independent-cell fit absorb reciprocity, which the pair model attributes to \(\rho\). The cost is the pair quadrature, in proportion to the number of dyads and periods: 1 to 2.5 times the independent-cell fit for one period (60 to 150 actors, ranks 0 and 2) and 2 to 4.5 times for four.

Counts (Poisson). A Poisson fit is the same estimator for the model that ame and lame sample: a count is \(y_{ij} \sim \mathrm{Poisson}(e^{z_{ij}})\) with \(z_{ij} = \eta_{ij} + e_{ij}\) and \(e_{ij} \sim N(0, v_e)\), where \(\eta\) is the predictor of the sections above (coefficients, sender and receiver effects, latent product). An actor without a count on a side keeps a finite effect, shrunk towards the prior mean as in the sampler. The effects have the Gaussian prior of the binary fit, with the scale and the degrees of freedom that ame() and lame() give counts: the variance across actors of the centred log row and column rates (a half-count pseudo-observation keeps an empty actor finite) and \(\mathrm{round}(4 + 3 n / 100)\) degrees of freedom, \(n\) the number of actors; the factors have the priors of the binary fit. The variance of the noise \(v_e\) is a hyperparameter, estimated as the covariance of the effects is, by type-II maximum likelihood: it is the value that maximises the Laplace marginal likelihood of the model (fit$eb$log_marginal, the mode of the effects and the factors solved at that value) plus the log density of its prior: none by default, since the likelihood of a count network barely informs \(v_e\) and a scale would pull it, or, when prior$s20 is given, the inverse-gamma of one degree of freedom on that scale that ame() and lame() give it. It is fit$VC["ve"] and fit$eb$ve, and the objective it was found on is fit$eb$ve_search$curve. The objective also charges the cells for the part of the posterior variance of the latent product that the Laplace approximation omits (the products of the covariances of the factors, which are the whole of that variance where the data inform the product weakly), held at its value at the maximum; without it the factors take up part of the noise and \(v_e\) falls short by about that variance. The stationarity condition of the maximum is the EM step of the full conditional of \(v_e\), \(\sum E[e^2] / (N - 2)\) by default and \((s_{20} + \sum E[e^2]) / (N - 1)\) under prior$s20 (the sum running over the observed cells, the dyads once for an undirected network, of the second moment of the noise given the count), with the second moment taken, to the order of the Laplace approximation, under the posterior of the predictor of the cell given all the parameters; the step at the mode alone, or under the mean-field posterior of the predictor, which is shrunk where the data inform the latent product weakly, is too large (a count network with fewer than three nonzero counts per loading: 1.3 to 4.6 posterior standard deviations above the sampler's, where the maximum of the marginal likelihood is within 1). A count network without noise beyond the Poisson has a small positive estimate: the log density of the default prior, \(\log v_e\), holds the maximum off zero (on ten plain Poisson networks of 30 actors the estimate was 0.006 to 0.045), and the search does not go below \(10^{-6}\). The maximum is found by continuation on \(\log v_e\): the mode is solved at 0.05, where every column of the latent product is alive, and then at larger values until the objective falls, then at the vertex of the parabola through the three points about its maximum, each warm from the nearest solved mode (typically 8 to 10 modes, 5 to 30 reweighting steps each); a mode solved cold at a large \(v_e\) loses a weakly supported column and keeps it lost at every smaller value, on a lower branch of the marginal likelihood. The variational stage holds \(v_e\) at the maximum, and a column the mode lost is restarted from the score of the cells before it iterates. The cell has everything the binary cell has. Its noise is integrated out, so that the log likelihood, the score and the information of a count at the predictor \(\eta\) are those of the Poisson-lognormal distribution (the information is positive: the log likelihood is concave in \(\eta\)); they are the cumulants of the posterior of the noise given the count, computed by an adaptive Gauss-Hermite rule centred at its mode (14 to 64 nodes, by the size of \(v_e\)), with the derivative of the information that the Laplace correction needs. The variational stage takes the expectation of the cell over the Gaussian posterior of the predictor with the rule of the binary fit (nine nodes where the predictor is uncertain, fewer where its variance is below 0.3), and the cavity weight of a cell is the information of the Poisson-lognormal cell whose noise variance is \(v_e\) plus the variance of the predictor. The linear predictor EZ is on the latent log scale of the model (there is no shift by half the noise variance), the mean of a count is \(e^{\eta + v_e / 2}\), which is what fit$fitted, fit$YPM, fitted() and predict() hold (the plug-in mean, as the samplers report it; the posterior predictive mean of a count is not finite in this model, and plug_in = FALSE returns the value the integration over the predictor gives, \(e^{m + (v + v_e) / 2}\)). A network without a count above zero has no finite log rate and is refused (class "lame_als_separation"). The coefficients carry the samplers' Zellner prior, as those of a binary fit do, so a covariate that the counts do not bound (one of one sign that is non-zero only where every count is zero) gets a finite coefficient and a standard error from the prior, and the fit warns (class "lame_als_separation") and records it in fit$eb$coef_separation. Rank evidence (fit$eb$log_marginal) is the Laplace value of the Poisson-lognormal model.

Dyadic correlation of counts. A directed count network with dcor = TRUE (the default for directed networks, as in ame and lame) takes the two counts of a dyad as one observation at the fitted state: the noises \((e_{ij}, e_{ji})\) are bivariate normal with variance \(v_e\) and correlation \(\rho\), and the pair has the bivariate Poisson-lognormal probability. The effects, the factors and \(v_e\) are fitted with independent cells (they agree with the sampler's, see below); the pair stage then gives (1) \(\rho\), the posterior mean, under the prior the samplers share, of the profile of the pair probability at the fitted predictors, reported as fit$VC["rho"] with its standard deviation in fit$rho_estimation, and (2) the information of the pairs: the pair probability integrated over the Gaussian posterior of the two predictors is the pair probability with the noise covariance plus their covariance, and its curvature in the two means (two diagonal weights and a cross weight, negative for a positive correlation) enters the covariance of the coefficients, so that the standard error of a covariate that is the same in the two cells of a dyad is not understated (fit$eb$pair records the correlation, its precision, the number of pairs and the cross weights). The pair stage costs 13 to 22 evaluations of the pair probability of every dyad; dcor = FALSE leaves it out and keeps the post hoc moment estimate of the correlation of the latent errors (fit$rho_working holds it in either case). Undirected and bipartite networks have no pair of cells.

Evidence for counts. Against the sampler (29 simulated count networks of 30 to 50 actors, one and four periods; directed, bipartite and undirected, ranks 0 to 3, mean counts 0.3 to 31, noise variances 0.05 to 2, empty actors, node covariates and reciprocity 0 to 0.8; ame() / lame(), 30,000 scans after the burn-in) the slopes are within 0.35 posterior standard deviations of the posterior means (median 0.05) and the intercepts within 0.38, the standard errors are 0.99 to 1.09 times the posterior standard deviations of the slopes (mean 1.04) and 0.97 to 1.02 times those of the intercept of a cross-section, va and vb are within 0.3 posterior standard deviations and ve within 0.5 (median 0.07), the actor effects differ from the posterior means by a median 0.029 of their standard deviation, and the correlation of a directed network is within 0.027 of the sampler's (median 0.010 and at most 1.2 of its posterior standard deviations). Without the pair stage the standard error of a slope was 0.77 to 0.87 of the sampler's for dense counts with a covariate that is the same in both cells of a dyad and a reciprocity of 0.6 to 0.8. On 1,500 simulated networks (25 designs of 60: 30 to 60 actors, mean counts 0.1 to 20, noise variances 0.1 to 1.5, ranks 0 to 3, directed, bipartite and undirected, one and four periods, reciprocal designs with a symmetric covariate, and ranks above the generating one) the fit converged in every network, the slope had a bias of 0.6 percent on average (4.7 at most, with 30 actors, mean count 0.1 and noise variance 1.5) and its 95 percent interval covered the truth in 95.5 percent of the networks (88 to 100 by design). The central 50 and 90 percent predictive intervals of 17,150 held-out cells (10 percent of the cells of 70 networks of seven designs) covered 51 to 54 and 90 to 91 percent of the observed counts, with no departure of the randomised probability integral transform from uniformity except at rank 3 with 3.0 nonzero counts per loading (Kolmogorov-Smirnov p = 0.007). The lowest rank within one unit of the largest Laplace value was the generating rank in 142 of 144 networks of 50 actors, and the rank of the largest value in 143 (each rank is compared at the noise variance that maximises its own marginal likelihood).

Counts with little information about the latent product. With fewer than about three nonzero counts per factor loading (fit$eb$variational$information["per_loading"]) the variational posterior shrinks the product. Below 2.1 units of the information-weighted signal per loading (fit$eb$variational$information["signal_per_loading"]) the data barely determine the product; the fit reports it with its standard errors, and print() states the statistic and the threshold (see Choosing the rank of a normal fit). The noise variance does not take up what the shrunk product leaves: on 22 networks of 40 and 50 actors at ranks 2 and 3 (1.1 to 6.6 nonzero counts per loading) ve is within 0.41 posterior standard deviations of the sampler's (mean 0.18; the step of the variational iteration itself was above it by 1.3 to 4.6, 2.6 on average, below three nonzero counts per loading), on 60 networks of 50 actors at rank 3 and 2.8 nonzero counts per loading it averaged 0.412 for a truth of 0.40 (0.406 at 4.2), and at a rank above the generating rank it is within 0.6 posterior standard deviations of the sampler's (32 networks; 4 percent below it on average). The variational posterior shrinks a product the data determine a little more than the sampler does: its norm is 0.95 to 0.98 of the norm of the sampler's posterior mean product (lame(), whose prior of the factors is the fit's) from 2.6 nonzero counts per loading and 0.80 to 0.90 up to 2.1 (against ame(), whose prior of the factors is tighter: 0.89 to 0.98 and 0.65 to 0.85); it is as close to the generating product as the sampler's posterior mean is (root mean squared difference 0.99 times the sampler's on average, 0.92 to 1.06 on the 22 networks), the mean of the predictor of a cell differs from the sampler's by 0.15 of the sampler's posterior standard deviation (root mean square over the cells, averaged over the networks; at most 0.23), and its variance is 0.92 of the sampler's (0.74 to 1.03). With about one nonzero count per loading or fewer the iteration still settles: on 54 networks of 40 actors at ranks 1 to 3 with 0.3 to 3.6 nonzero counts per loading every fit converges, none collapses a column of its product, and one, at rank 3 with 0.6 nonzero counts per loading, retires a column (see A rank the data do not support); ve averages 0.39, 0.35 and 0.39 at ranks 1, 2 and 3 for a truth of 0.40. The product correlates with the truth at 0.83 on average at rank 3 and 2.8 nonzero counts per loading.

Normal data (the Gaussian empirical-Bayes estimator). A normal fit is the same estimator for the model that ame and lame sample, \(y_{ij} = \mu + \beta' x_{ij} + a_i + b_j + u_i' v_j + e_{ij}\) with \(e_{ij} \sim N(0, s^2)\), and it is the estimator of the binary and count fits with the one cell in which everything is exact. The cell of a normal response has the working response \(y\) itself, the weight \(1 / s^2\) and the score \((y - \eta) / s^2\); its information does not depend on the predictor, so the Laplace correction of the coefficients vanishes and the Laplace approximation of the coefficients and the effects is not an approximation: at R = 0 the fit is the posterior mean (the best linear unbiased prediction) of the linear Gaussian model at the fitted hyperparameters, and vcov() is its generalised least squares covariance (checked against an independent computation to 1e-6 in the tests). The effects have the Gaussian prior \((a_i, b_i) \sim N(0, \Sigma_{ab})\) and the inverse-Wishart prior on \(\Sigma_{ab}\) that ame() and lame() give a normal response (the scale is the mean variance of the row and the column means of the centred response, \(\mathrm{round}(4 + 3 n / 100)\) degrees of freedom), the coefficients are flat, and the node covariates are fixed effects of the prior mean of the effects. The variance of the noise \(s^2\) is a hyperparameter with the sampler's inverse-gamma prior of one degree of freedom on the scale prior$s20, by default the variance of the observed responses. \(s^2\) and \(\Sigma_{ab}\) are the fixed points of the EM images that the samplers draw from (the posterior mean of the inverse-gamma and inverse-Wishart full conditionals), formed from the posterior second moments, so that they are net of the degrees of freedom the effects and the factors use: \(s^2 = (s_{20} + \sum E[e^2]) / (N - 1)\) with \(E[e^2] = (y - m)^2 + v\) (\(m\) and \(v\) the mean and variance of the predictor of the cell under the posterior). The factors of a latent rank are the variational posterior of the binary fit, with its cavity rule for the scale of their prior and the priors of the samplers (a directed network the shared prior of ame() and lame(), whose scale is that of the effects). The fitted values are the posterior means of the predictor; the response is Gaussian, so they are also the predictive means.

Dyadic correlation of normal data. A directed normal network with dcor = TRUE (the default) takes the two cells of a dyad as one bivariate normal observation with covariance \(s^2 [[1, \rho], [\rho, 1]]\). Everything is in closed form: the information of a pair is the constant matrix \([[1, -\rho], [-\rho, 1]] / (s^2 (1 - \rho^2))\), whose cross weight enters the equations of the coefficients and of the effects (the estimates are generalised least squares), the rows of the factors see the exact score of the pair, the cavity weights of the factor scale are those of the pair density integrated over the predictors, and \(\rho\) takes its posterior mean under the fast route's prior (density proportional to \(1 - \rho^2\)), computed on a fine grid from the sufficient statistics of the pairs and not by a quadratic approximation. The variance of the noise is estimated from the whitened pairs. The value is fit$rho (fit$VC["rho"]), its posterior standard deviation and method are in fit$rho_estimation, and the record of the pair model in fit$eb$pair. dcor = FALSE fits independent cells and reports the correlation of the residuals of the pairs as before; undirected and bipartite networks have no pairs.

Standard errors of normal fits. vcov() is the Laplace covariance of the coefficients jointly with the effects and the factors, built from the information of the Gaussian cell: the weight \(1 / s^2\) and the cross weight of the pairs, not the cavity weight that sets the scale of the factors. The information of a Gaussian cell is the same whatever the predictor, so integrating the variance of the predictor into the weight counts it twice: with the cavity weights the standard errors of the dyadic coefficients were 1.05 to 1.13 times the sampler's posterior standard deviations at ranks 1 to 3, with the information of the cell 0.97 to 1.02. Node-covariate and intercept coefficients are covered too, and the part of the uncertainty that comes from the scale of the prior of the factors is added as for the other families. Beyond the designs above the intervals keep their level: on 1,000 simulated normal panels (200 a cell: 40 actors with 8 and 12 periods at ranks 0 and 2, and 120 actors with 4 periods at rank 2; a dyadic covariate, a row and a column covariate, dyadic correlation 0.3) the 95 percent Laplace intervals covered the dyadic coefficient in 0.943 of the panels (cells 0.915 to 0.965), the row and column covariates in 0.959 and 0.956 (0.935 to 0.975) and the intercept in 0.950 (0.935 to 0.955); the Monte Carlo standard error of a pooled figure is 0.007 and of a cell 0.015 to 0.020.

Choosing the rank of a normal fit. fit$eb$log_marginal is the Laplace approximation to the log marginal likelihood of the independent-cell model at the posterior mode, solved from the variational state with the variance of the noise held at its fitted value and to a scaled score of 0.01 (the log marginal likelihood moves by at most \(m s^2 / 2\) from the mode, 0.05 for the 1,000 effects and factor entries of 170 actors at rank 2); it is exact at R = 0, and it is the value of Choosing the rank. The mode is the one fit$irls_diagnostics certifies. fit$eb$variational$information measures the signal of the fitted product in noise variances per loading (for a binary or count fit, signal_per_loading: the product weighted by the information of each cell, which is the same quantity with the fisher weight of the cell in place of 1 / ve). Below 2.1, in every family, the data do not determine a product of that rank: the sampler's posterior mean product is shrunk towards zero and the variational mean is not, so its size is not the posterior's. A static fit reports such a product with the standard errors of its cells and positions (fit$UVPM_sd, fit$U_sd; below the threshold the position sds of a directed or bipartite fit are at least the variational sd of each row with the spread the row takes from the uncertainty of the other side added, and an undirected fit, whose eigenvalue signs and eigenvector directions the data then do not determine, reports the interval fit$L_ci of each eigenvalue whose share of the statistic (split over the columns by squared eigenvalue) is below the threshold on both signs and its position sds of at least the error of a direction uniform over the centred unit vectors and product cell sds that carry that direction and the undetermined sign, whichever side of the threshold the fit as a whole is), which print() and summary() note. Their 95\ the centred product in 94 to 98\ networks of 25 to 60 actors, 100 to 200 networks each). The dynamic estimator of a normal panel (lame(method = "als") with dynamic_ab, dynamic_beta or dynamic_uv) records the same statistic in fit$eb$information and withholds the product: fit$U, fit$V, fit$UVPM and the positions are NA and fit$eb$product_withheld records why, with the same threshold for static factors and 1.3 per loading of a period for moving positions (the products of every period: fit$UVPM, fit$Omat, fit$Oarr and the positions with their standard deviations); it has no rank evidence, so its record has none.

Scale of a normal response. The iteration works in the units of the response: its tolerance is relative to the standard deviation of the response and the floors of the variances are relative to its variance. The priors of the factors are the samplers' and, like them, written in the unit of the response (R/normal_scale.R): the rows of a directed network have the typical size of the additive effects (the square root of the mean variance of the row and column means of the centred response) as the scale of their prior, the interaction matrix of a bipartite network and the weights of an undirected one have the variance of the response as the variance of theirs. So the fit of c * y is the fit of y in other units: on simulated networks of every kind at ranks 0 and 2 the coefficients, the variance components, the effects and the product of c * y are c (or c^2) times those of y to 1e-13 for c of 1e-3 and 1e3, an undirected panel without factors to 5e-5 (its stop rule), and the standard errors, which carry two refits of the scale of the factors, to 1e-3. A response without variation is refused with the remedy (class "lame_als_data"); one with a standard deviation outside 1e-6 to 1e8, beyond the conditioning of the compiled updates, is fitted in units of its standard deviation and returned in its own units (fit$meta$response_scale records the divisor).

Validation of normal fits. Against the samplers' posterior means (55 simulated networks of 30 to 50 actors a side, directed, undirected and bipartite, ranks 0 to 3, 38 against ame and 17 against lame fits, 12 of one period and 5 of four periods, of 20,000 scans after 3,000 of burn-in), the 245 coefficients lie within 0.28 posterior standard deviations (mean 0.04), the Laplace standard errors are 0.91 to 1.05 times the posterior standard deviations (mean 1.00; the intercept of a fit with a latent product is reported as the samplers report it, see Details: on 44 further networks of this design, 36 against ame and 8 against lame fits of four periods, it lies within 0.07 posterior standard deviations of the sampler's with a standard error 0.99 to 1.05 times the posterior standard deviation, and on 12 networks whose positions have means of 0.5 and -0.5 within 0.05 with a standard error 0.99 to 1.14 times it), the variance of the noise is within 0.95 posterior standard deviations, the variances of the sender and receiver effects within 0.16 and the dyadic correlation within 0.45. On 103 simulated networks of 40 actors a side (the 55 above with 48 more of weak and moderate signal; 89 with a latent rank, 1 to 3, directed, undirected and bipartite; against ame and lame fits of 20,000 scans) the norm of the double-centred product is 0.993 to 1.146 of the sampler's posterior mean product where the fit has at least 2.1 noise variances of signal per loading (39 networks; correlation of the products 0.984 to 1.000). Below (50 networks) the undirected fits are 1.37 to 6.9 times the sampler's (0.31 to 1.73 per loading), the directed and bipartite ones 1.08 to 5.0 below 0.7 per loading and 1.01 to 1.25 from 0.7: the sampler's posterior mean is shrunk towards zero and the mean field is not. Every network from 1.99 per loading has a norm within 0.9 to 1.15 of the sampler's, and the largest that does not is at 1.73 (pooled with binary and count networks, the threshold is 2.1). Evaluating the update of the scale of the prior at the posterior mean of the inverse-Wishart (options(lame.eb_scale_stat = "mean")) or at the mean-field second moments does not close the gap (median 2.25 and 1.74 times the sampler's below one per loading, against 2.14). The coefficients of the fits below 2.1 lie within 0.30 posterior standard deviations of the sampler's, with standard errors 0.93 to 1.05 times its posterior standard deviations. On 47 Poisson-lognormal networks of 40 actors a side with a latent product (directed, undirected and bipartite, ranks 1 and 2, against ame fits of 20,000 scans) the nonzero counts per loading do not measure the information about the product: a fit with 13 nonzero counts per loading had 7.5 times the norm of the sampler's product. The information-weighted signal does: below 2.1 the count products are up to 7.5 times the sampler's (median 1.87), and these fall below the threshold; from 2.1 the norm is 0.94 to 1.12 times the sampler's (20 networks). In repeated sampling (21 designs of 100 to 200 networks, 4,100 networks and 19,700 coefficient fits: every kind, ranks 0 to 3, 20 to 80 actors, one and four periods, 20 percent missing cells, a rank above the generating one and a weak product) the 95 percent Laplace intervals cover 95.2 percent (dyadic coefficients 95.1, node covariates 95.9, intercept 94.3; designs from 94.1 to 96.7). The rank with the largest fit$eb$log_marginal is the generating rank in all of the networks (252 networks of 40 actors, generating ranks 0 to 2) with at least 8 noise variances of signal per loading, in 95 percent from 4 to 8, 89 percent from 2 to 4, 50 percent from 1 to 2, and in none below 1, where it picks a smaller rank; it picked a larger rank than the generating one in one network (a rank-0 network). Of 300 random designs (10 to 60 actors, one and three periods, up to 30 percent missing cells, fitted ranks 0 to 3 against generating ranks 0 to 2), all 300 fit: the two that the iteration did not settle at rank 3 (undirected panels of 14 and 10 actors over generating ranks of 0 and 1, a limit cycle of the scales of the columns) retire two columns (the rank-1 fit) and converge at rank 3 under the priors in the unit of the response.

Speed. The quadratures of the empirical-Bayes fit (the expected working problem of a cell and of a pair of cells, the cavity weights, the bivariate normal probability of the pair likelihood, the log-domain integral for its small values) and the sums over the panel that its equations need run in compiled code; the reference implementations are kept in R and agree with the kernels to rounding (typically 1e-12, and 1e-9 at worst on realistic predictors). The kernels split their cells and pairs over OpenMP threads where the platform has them: options(lame.als_threads = k) sets the number of threads (default 1), and the estimates do not depend on it. Do not combine threads with forked workers such as parallel::mclapply(). The dense solves of the effect step (a Cholesky inverse of the stacked sender and receiver effects, 600 by 600 at 300 actors) are the cost of a large panel and run in the BLAS of the R installation, whose speed sets that cost.

Standard errors. vcov() and confint() return the Laplace approximation to the covariance of the coefficients: the inverse penalised information of all the parameters (coefficients, effects and factors) at the cavity weights (for a normal fit the information of the Gaussian cell, Standard errors of normal fits), with the second moments of the factors in the curvature of the other side, plus the part of the uncertainty that comes from the scale of the prior of the factors. The logarithm of the scale has, to the second order, a normal posterior whose precision is the information of the data about it (the derivative of the log marginal likelihood in the log scale, \((\mathrm{tr}(\Sigma^{-1} SE) - n p) / 2\) at the cavity second moments, from two refits at the scale times \(e^{\pm 0.15}\)) plus that of the hyperprior; the coefficients move with it by \(J = d\theta / d \log s\), and the covariance gains \(J J' / c\). This is one dimension of the uncertainty of the scale (the sampler's covariance of the rows is a full matrix, with 10 free parameters at \(R = 2\)); options(lame.eb_scale_uncertainty = FALSE) leaves it out.

A binary fit's standard errors also carry the uncertainty of its variance components \(\phi\) (the covariance of the actor effects and, when it is estimated, the dyadic correlation): the coefficients are those at the estimated \(\phi\), so the covariance gains \(J \Sigma_\phi J'\) with \(J = d\theta / d\phi\) from refits at each component moved by \(\pm 0.15\) of its size with \(\phi\) held, and \(\Sigma_\phi\) the inverse of the curvature of the bound in \(\phi\) (the correlation's own variance that of its posterior); options(lame.eb_scale_uncertainty = FALSE) leaves this out as well. When the refits of either term fail (one does not converge, or the curvature is not positive), they are run once more at half the step with four times the iteration budget; a term whose second refits fail too is left out, with the warning of class "lame_als_numerical_fallback". Which of these gave each term is recorded in fit$eb$variational$uncertainty_terms.

A rank the data do not support. A sparse count network at a rank above what it supports (or a network with no signal at all) leaves the iteration at that rank with no stationary point the data determine: a column the data barely inform keeps a live scale, its rows are fitted at the scale of the prior and their second moments are the prior's, so that the posterior mode drifts (the largest score of the stationarity certificate rises with every accepted step) or the variational iteration stops improving at a residual of a few thousandths, or enters a limit cycle in the scales of the columns. Such a fit is not refused. The five-node rule of the pair likelihood of a directed binary network integrates a dyad to less than the gain of a step near the fixed point where the rows are weakly informed, which is a limit of the quadrature as often as of the data: a stall of the pair rule is first refined, to seven and then to nine nodes a side, from the state it reached (fit$eb$pair$refined). An iteration that is still not settled retires its weakest column, the one with the smallest norm of the product \(\|u_k\| \|v_k\|\) (the smallest \(|l_k|\) of an undirected fit), when the fit of the next rank down, which starts from the other columns, has a variational lower bound at least as high; this repeats while the iteration does not settle. A rank whose lower bound is above that of the next rank down keeps its columns: when its coefficients, standard errors, positions and fitted values can all be formed and are finite at its last iterate, that iterate is the fit, with a warning of class "lame_als_unsettled" that names the stage that stopped (the posterior mode or the variational refinement) and why (the iteration limit, or no improving step) and, after an iteration limit, says that a larger max_iter continues the fit. A binary fit whose latent factors fit observed cells with probability 1 that the rest of its predictor does not is separated there (the count is fit$eb$unsettled$separated): the warning says so and points to a lower rank or the sampler. fit$eb$unsettled records it, fit$converged is FALSE, and the Laplace evidence fit$eb$log_marginal, defined at a settled mode (for a normal fit, at the settled noise variance of the variational stage), is NA when the posterior mode did not settle or the family is normal. When some of them cannot be formed, or the call asks for a bootstrap (bootstrap > 0, which needs a settled fit), the fit of the next rank down, already computed, is returned (and the rule goes on from it), with a retirement message that says the rank did not converge. The fit is the one of the rank it reached: fit$R is that rank, fit$R_requested the rank asked for, fit$eb$retirement the record, and the evidence, the standard errors and the factors are those of the effective rank; the fit says so with a warning of class "lame_als_retirement" when it is made, and print() and summary() say what was retired. A fit that still does not settle with no column left, or that ran out of a max_iter below the default of 200 (a bound the caller chose: the iteration may only need more steps, so it is not reduced in rank), is continued from its last iterate: an unsettled posterior mode with its reweighting map relaxed, halving the relaxation until it settles (fit$irls_diagnostics$relaxed), and a refinement stopped at its iteration limit with five times its budget (fit$eb$variational$extended). One that still does not settle is returned at its last iterate with the warning "lame_als_unsettled" and the record fit$eb$unsettled (lower = "none"); it is refused (class "lame_als_convergence") only when its estimates and standard errors cannot be formed there. A count network of 40 actors at rank 3 settles by retiring a column (rank 2).

A rank that settles with columns that carry no product (every cell of \(u_k v_k'\) below \(10^{-4}\) on the scale of the linear predictor, or \(10^{-4}\) standard deviations of the response for a normal fit, whose product is in the units of the response) is not refitted: its estimates, standard errors and variance components are those of the rank asked for, which carry the uncertainty of a product at the scale of its prior, as a variance component estimated at zero does. Only the report changes: the empty columns leave fit$U, fit$V and their standard errors (with no column left, fit$UVPM too), fit$R counts the columns kept, fit$eb$retirement records them with the reason "no product", and the warning of class "lame_als_retirement" says so. A column of a two-mode fit that carries no product for 20 accepted variational iterations is held at zero with its scale fixed, so that its rank settles.

A fit that keeps fewer multiplicative dimensions than were requested (fit$R below fit$R_requested) says so with a warning of class "lame_als_retirement", which print() and summary() repeat: how many dimensions were requested and kept, and why. For a binary fit it adds that a multiplicative structure too weak for the fast route to resolve may remain, which the standard errors do not account for, and that method = "mcmc" resolves weaker structure: on binary panels of 50 actors and 4 periods the fast route kept a product of the strength of the package's example data in none of 30 panels, and both dimensions of one of twice that strength or more in 89 of 90 (the other kept one). Normal and count fits keep weak products.

Predictions. The response of a normal fit is its linear predictor plus Gaussian noise, so fitted() and predict() return the posterior mean of the predictor (fit$fitted), which is the mean of the response; the rest of this paragraph is about binary and count fits. fitted() and predict() of a binary empirical-Bayes fit return predictive probabilities: the link integrated over the posterior of the linear predictor rather than applied at its mean. The predictor of a cell is uncertain, so the plug-in probability of a held-out event can be orders of magnitude too small. A Poisson fit returns the plug-in mean count \(e^{\eta + v_e / 2}\) by default, as the samplers do: the posterior predictive mean of a count is not finite in this model (the inverse-gamma tail of \(v_e\), and the inverse-Wishart tail of the scale of the factors for a cell the data do not inform), so the value of the integrated mean \(e^{m + (v + v_e) / 2}\) would be a property of the quadrature and of the prior; it stays available as plug_in = FALSE, and the predictive law of a held-out count (its quantiles and event probabilities, which are finite) is what the held-out scores use. The predictor is \(N(m, v)\): \(m\) is the fitted predictor, the posterior mean; \(v\) is the variance \(g' S g\) of the cell's additive predictor (the coefficients and the two effects, with \(g\) its gradient and \(S\) the inverse of their penalised information at the expected weights) plus the variance of the product. The probability is \(\Phi(m / \sqrt{1 + v})\) for a probit link and \(\mathrm{plogis}(m / \sqrt{1 + \pi v / 8})\) for a logit link. plug_in = TRUE returns the link applied to the fitted predictor (what fit$fitted holds and simulate() uses). Forming the covariance costs one dense inverse, of the size of the one behind vcov(), per call.

Choosing the rank. fit$eb$log_marginal is the Laplace approximation to the log marginal likelihood of the data with the effects and factors integrated, at the posterior mode that the variational stage starts from (for a normal fit the mode at the fitted variance of the noise, Choosing the rank of a normal fit), with that mode's coefficients and scales: the deviance and the penalties of the effects and the factors, with the log determinant of the information of all of them, on the scale of the likelihood (an undirected network counts each dyad once; the hyperpriors of the scales are left out). The deviance falls with the rank; this does not, so the difference between two ranks fitted to the same data is an approximate log Bayes factor. The sign and label multiplicity of the factors is not counted, which favours the lower rank. The variational lower bound, fit$eb$variational$elbo, is not the value to use for this: a Gaussian posterior cannot hold the broad posterior of positions that the data barely identify, and the bound's slack grows with the rank. The value is the evidence of the independent-cell model at the posterior mode: a fit with a dyadic correlation (Dyadic correlation) reports the same log_marginal as the fit with dcor = FALSE.

Where the Laplace value cannot pick the rank, the held-out predictive log score can: mask a share of the observed cells (15 percent), refit at each rank, and score the masked cells with fitted() (the integrated predictive; a variational fit's predictive is not shrunk to the plug-in probability, and its surplus columns are not shrunk away, so the score falls above the generating rank).

The joint solve is dense, so the cost grows with the cube of the number of actors. An actor without a tie (or without a non-tie) on a side keeps a finite, shrunken effect and stays in the fit, so there is no fit$not_estimated. A fit with a latent product reports its intercept, effects and positions in the identified form the samplers store: U and V are centred over the actors, and the row, column and grand means the product loses go to a, b and the intercept, which leaves the linear predictor unchanged. The standard error of the intercept is that of this functional of the joint posterior, and fit$eb$population keeps the population intercept (the level of a dyad between two actors with zero effects and positions, at the means of the node covariates) with its covariance. The effects a and b of ame_als() are not re-centred otherwise, as in ame(), and have mean zero a priori. lame_als() reports them at mean zero over the observed actors, as lame() does, and its intercept takes their means as well. va, cab and vb are the fitted covariance of the effects, the EM estimate of \(\Sigma_{ab}\), not descriptive summaries of the estimated effects.

Accuracy. On seven designs of binary networks the fast route fits (mean densities 0.41 to 0.44; directed and undirected, 25 to 60 actors, one and four periods, ranks 0 to 2, a weak product and correlated sender and receiver effects; 200 to 400 networks each) the 95 percent Laplace intervals covered the dyadic coefficient in 0.905 to 0.975 of the networks and the intercept in 0.940 to 0.975. The independent-cell fit (dcor = FALSE) has no dyadic correlation; the pair model (Dyadic correlation) is the default for a directed network.

The "ordinal" family is not supported by ALS and raises an informative error; use ame or lame for that likelihood.

Row/column (node) covariates. A node covariate broadcasts to a per-actor constant, which is collinear with the additive sender/receiver effect, so its coefficient is not identified by the objective alone. It is identified here by an explicit constraint: the additive effects are taken orthogonal to the node covariates, and beta_row/beta_col are the corresponding between-actor regression coefficients (the additive effects then carry only the residual heterogeneity). This is the standard estimand under the assumption that the additive effects are uncorrelated with the node covariates; if that assumption is doubtful the coefficient absorbs the covariate-correlated part of the additive heterogeneity. Time-varying node covariates are summarised by their per-actor mean; if a node covariate varies within actor over time the discarded within-actor variation triggers a warning.

Missing covariates. As in ame and lame, a cell whose dyadic covariate, sender covariate or receiver covariate is missing in its period is unobserved: it is set to NA in Y before the fit, a message gives the number of cells, and the coefficients are estimated from the complete cells. A missing value is not modelled as 0, which biases the coefficient of a covariate that is not centred. A missing value on the diagonal of a square unipartite covariate is not counted, since the diagonal is unobserved anyway. In an undirected fit (symmetric = TRUE) a dyad has one covariate value: a hole in one triangle of a dyadic covariate is filled from the other triangle, and a dyad missing in both is unobserved. The per-actor mean of a node covariate runs over the periods in which it is observed. An actor missing a node covariate in every period has no observed cell on that side: the fit leaves its effect there to the prior (zero when the actor has no cell on either side). A covariate that is missing everywhere stops the fit, as it does in ame and lame.

Identifiability of the additive and multiplicative terms. For R > 0 the additive term \(a_i + b_j\) and the multiplicative term \(u_i' v_j\) are not separately identified by the objective alone: a broadcast (row- or column-constant) component can sit in either, since a pure sender effect \(a 1'\) is itself rank one. The estimator imposes the standard AME gauge — the multiplicative term is double-centered (zero row and column means), so all broadcast structure is carried by \(a, b\) — which makes the reported \(a, b, U, V\) unique given the fitted values and independent of the optimisation path. For a unipartite network the double-centering means are taken over the full matrix, which includes the structurally unobserved self-tie diagonal that the model fills in by its low-rank completion; the additive/multiplicative split therefore carries an \(O(1/n)\) dependence on that completion. On a disconnected observed-dyad graph the additive effects additionally have a per-component level shift, which is pinned to a precision-weighted minimum-norm gauge so that a, b and the variance components remain reproducible. A dyadic covariate that is itself (near) low-rank can still be partially aliased with the multiplicative term, so keep R modest relative to the covariate structure. This residual aliasing is intrinsic to the AME model — the MCMC estimator resolves it only through its priors.

Choosing R. Every fit has a rank criterion, fit$eb$log_marginal (see Choosing the rank): fit a few values, e.g. lapply(0:4, function(r) ame_als(Y, R = r, ...)), and compare them. With R > 0 the objective is non-convex; use multistart to guard against local optima.

A binary network whose observed cells are all ties or all non-ties has no finite intercept, which is unpenalized, and is refused (class lame_als_separation); use ame() or lame() with proper priors for such data. Covariates that separate the ties from the non-ties are held finite by the coefficient prior, and the fit warns.

Uncertainty. Every fit reports Laplace standard errors for every coefficient (vcov(), confint(), fit$eb$se), and standard errors for the variance components (fit$VC_se, fit$VC_ci), the sender and receiver effects (fit$a_sd, fit$b_sd) and the latent positions and product cells (fit$U_sd, fit$V_sd, fit$UVPM_sd; posterior_sd in latent_positions). A product the data barely determine is reported shrunken, with its larger standard errors. A latent position whose eigenvalue is zero is reported at the zero the fit estimates, with standard error \(1/\sqrt{n}\), that of an entry of a direction uniform over the centred unit vectors; its product cells and the eigenvalue keep their errors. bootstrap = N adds bootstrap errors for the coefficients (see ame_als_bootstrap).

Coverage relative to ame / lame

The ALS estimator is a fast empirical-Bayes estimator. It covers most static AME workflows, and the top-level lame(..., method = "als") dispatcher covers several dynamic workflows, but posterior-specific features still require the MCMC estimator:

  • Families. ALS supports normal, binary, and poisson. For ordinal, fall back to ame / lame.

  • Dynamic effects. lame_als itself fits a static model pooled across time slices. The top-level dispatcher lame(..., method = "als") routes supported dynamic requests to a dynamic estimator for normal, binary, and Poisson panels (an empirical-Bayes fit; see lame), including named panels where actors enter or exit: dynamic_ab, selected intercept/dyadic/node dynamic_beta, AR(1) dynamic_uv for directed, symmetric, and bipartite panels, and Student-t dynamic_uv for directed and symmetric panels (bipartite t requests are refused). dynamic_uv_kind = "snap" has no ALS route and is refused. Node-covariate coefficients use the same orthogonal additive-effect decomposition as lame_als; dynamic node coefficients use period-specific node values when selected by dynamic_beta, while static node coefficients use per-actor means. A dynamic normal fit whose latent product the data do not determine withholds it (fit$eb$product_withheld; see Choosing the rank of a normal fit in ame_als). Changing actor composition requires row and column names on every slice so actors can be aligned; the fit treats an absent actor-period as a free AR state. Dynamic ordinal fits remain on the MCMC path. Static ame_als() / lame_als() fits still use a single latent rank R; the dynamic bipartite ALS dispatcher honours separate R_row and R_col values.

  • Priors. ame_als(), lame_als() and lame(..., method = "als") read one entry of prior, s20, the scale of the prior of the noise variance of a normal or Poisson fit, and the dynamic empirical-Bayes fits read the hyperprior entries of lame in their EM. Every other entry of the samplers' prior list and g = ... are MCMC-only; the dispatcher ame(..., method = "als") warns and ignores prior and g (pass prior = list(s20 = ) to ame_als()). The empirical-Bayes fits apply the default additive-effect prior of ame / lame with its covariance estimated. The coefficients of a binary or count fit carry the Zellner prior of the samplers (unit information on the centred design, the intercept flat), so the fast fit and ame() / lame() at their default prior apply the same coefficient prior; a normal fit has none, since its likelihood bounds every coefficient of a full-rank design. A combination of coefficients is separated when the observed cells that bound the likelihood along it (ties whose predictor it lowers, non-ties whose predictor it raises; positive counts whose predictor it moves, zero counts whose predictor it raises) number fewer than one: there are none, so the likelihood has no finite maximum along it (one such cell gives it one). The check reads the data alone, not the prior or the fitted values: the fit warns (class "lame_als_separation"), names the covariates, and records it in fit$eb$coef_separation; its value and standard error come from the prior.

  • Posterior quantities. No $BETA / $VC posterior draws on the point fit. Use bootstrap = N for a sampling distribution analogue; the draws are bootstrap, not Bayesian.

  • Multi-chain. Not applicable: an ALS fit is one fit, and chains has no effect on ame(..., method = "als") or lame(..., method = "als").

  • Convergence diagnostics. No Rhat / ESS / trace_plot.

Features that work the same on ALS fits: coef, vcov (Laplace covariance of the empirical-Bayes fit, or the bootstrap covariance when one is attached), confint (auto-routes bootstrap intervals when present, Wald intervals otherwise), predict, fitted, residuals, summary, print, nobs, simulate.ame_als, gof_plot.ame_als, ab_plot.ame_als, uv_plot, latent_positions.

References

Minhas, S. and Hoff, P. D. (2025). Decomposing Network Dynamics: Social Influence Regression. Political Analysis. The iterative block coordinate descent estimator adapted here originates with that work (implemented in sir::sir_alsfit()).

See also

lame_als for longitudinal networks, ame_als_bootstrap for bootstrap uncertainty, ame for the full MCMC estimator.

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau

Examples

Y <- matrix(rnorm(400), 20, 20); diag(Y) <- NA
fit <- ame_als(Y, R = 1, family = "normal", verbose = FALSE)
coef(fit)
#>   intercept 
#> -0.01640926