An MCMC routine providing a fit to an additive and multiplicative effects
(AME) regression model to cross-sectional relational data of various types.
This function supports both unipartite (square) and bipartite (rectangular)
networks. For longitudinal networks, use the lame function. The
additive and multiplicative effects framework is due to Hoff (2005, 2021).
Usage
ame(
Y,
Xdyad = NULL,
Xrow = NULL,
Xcol = NULL,
rvar = TRUE,
cvar = TRUE,
dcor = !symmetric,
nvar = TRUE,
R = 0,
R_row = NULL,
R_col = NULL,
mode = c("unipartite", "bipartite"),
family = "normal",
intercept = !(family == "ordinal"),
symmetric = FALSE,
odmax = rep(max(apply(Y > 0, 1, sum, na.rm = TRUE)), nrow(Y)),
prior = list(),
g = NA,
seed = 6886,
nscan = 10000,
burn = 500,
odens = 25,
verbose = TRUE,
gof = TRUE,
custom_gof = NULL,
plot = FALSE,
start_vals = NULL,
periodic_save = FALSE,
out_file = NULL,
save_interval = 0.25,
posterior_opts = NULL,
n_chains = 1,
cores = 1,
use_sparse_matrices = FALSE,
method = c("mcmc", "als"),
bootstrap = 0L,
bootstrap_type = c("parametric", "block"),
bootstrap_block_length = 1L,
bootstrap_seed = NULL,
save_log_lik = FALSE,
ordinal_cutpoints = c("data_induced", "explicit"),
print,
...,
model.name = NULL
)Arguments
- Y
For unipartite: an n x n square relational matrix. For bipartite: an nA x nB rectangular relational matrix where nA is the number of row nodes and nB is the number of column nodes. A cross-sectional netify object is also accepted and converted with
netify::to_lame(); whenfamilyormodeis omitted, the value inferred by netify is used. See family below for data types.- Xdyad
For unipartite: an n x n x pd array of dyadic covariates (e.g. distance, shared group). For bipartite: an nA x nB x pd array. A 2-D matrix (single dyadic covariate) must be wrapped as
array(x, dim = c(n, n, 1));Inf/NaNentries are rejected.- Xrow
For unipartite: an n x pr matrix of sender (row) covariates (e.g. sender's age, group). For bipartite: an nA x pr matrix of row-node covariates. A
data.frameis accepted and coerced to numeric matrix internally.- Xcol
For unipartite: an n x pc matrix of receiver (column) covariates. For bipartite: an nB x pc matrix of column-node covariates. A
data.frameis accepted and coerced internally.- rvar
logical: fit row random effects (asymmetric case)?
- cvar
logical: fit column random effects (asymmetric case)?
- dcor
logical: fit a dyadic correlation (asymmetric case)? Note: not used for bipartite networks.
- nvar
logical: fit nodal random effects (symmetric case)?
- R
integer: dimension of the multiplicative effects (can be zero). For bipartite networks, this is used as the default for both R_row and R_col if they are not specified.
- R_row
integer: for bipartite networks, dimension of row node multiplicative effects (defaults to R)
- R_col
integer: for bipartite networks, dimension of column node multiplicative effects (defaults to R)
- mode
character: either "unipartite" (default) for square networks or "bipartite" for rectangular networks. Not all combinations of
familyandmodeare supported – see the table under Supported family x mode combinations below.- family
character: one of "normal","binary","ordinal","cbin","frn","poisson". See the Supported family x mode combinations table below for which combinations are valid; see Details for the model assumptions behind each family.
- intercept
logical: fit model with an intercept?
- symmetric
logical: Is the sociomatrix symmetric by design?
- odmax
a scalar integer or vector of length n giving the maximum number of nominations that each node may make - used for "frn" and "cbin" families
- prior
a list containing hyperparameters for the prior distributions. Available options and their defaults:
- Sab0
Prior scale matrix for the additive-effects covariance. A 2x2 matrix where Sab0\[1,1\] is the prior variance for row effects, Sab0\[2,2\] is the prior variance for column effects, and off-diagonals control correlation between row and column effects. For a unipartite fit this defaults to
diag(2)scaled to the observed sender/receiver heterogeneity inY(unconditionally for the continuous families, conditionally for the discrete ones); a bipartite fit defaults todiag(2). See the note on the additive-effects variance scale in Details. Passdiag(2)explicitly for a fixed unit-scale prior.- eta0
Prior degrees of freedom for the additive-effects covariance \(\Sigma_{ab}\) (default: round(4 + 3 \* n/100) for a unipartite continuous-family fit, round(4 \* vdfmlt) for a unipartite discrete-family fit, and 4 + 3 \* (nA + nB) / 200 for a bipartite fit – except bipartite
"binary", which also uses round(4 \* vdfmlt) – where n is the number of actors and vdfmlt is a probit-moment variance multiplier estimated fromY). Higher values impose stronger shrinkage of the row/column effects toward the prior scale. The multiplicative-effects degrees of freedom are controlled bykappa0, noteta0.- etaab
Prior degrees of freedom for covariance of additive effects (default: 4 + 3 \* n/100). Controls shrinkage of row/column random effects. Larger values shrink effects toward zero. Used by the bipartite and longitudinal paths; ignored for a unipartite cross-sectional
ame()fit, which controls the additive prior throughSab0andeta0.- s20
Prior scale for the dyadic residual variance \(v_e\) (default: 1), entering the inverse-gamma draw as a pseudo-observation scale. Larger values pull \(v_e\) upward. The regression-coefficient prior is controlled separately by
g, not bys20.- s2u0
Prior variance for multiplicative effects (default: 1). Used by the bipartite and longitudinal paths.
- Suv0
Inverse-Wishart (inverse) scale matrix for the multiplicative-effects covariance. The prior scale is
kappa0 * Suv0and the prior mean iskappa0 * Suv0 / (kappa0 - 2 * R - 1). When not supplied it defaults todiag(2 * R)times a scale estimated from the data.- kappa0
Prior degrees of freedom for the multiplicative-effects covariance \(\Sigma_{uv}\) (default when R > 0: 2 \* R + 2, times the same probit-moment multiplier as
eta0for a unipartite discrete-family fit). Higher values impose stronger shrinkage of the latent factors toward the prior scalekappa0 * Suv0.
Common usage: prior = list(Sab0 = diag(c(2, 2)), eta0 = 10) for moderate shrinkage, or prior = list(Sab0 = diag(c(0.5, 0.5))) for tighter control. For a unipartite cross-sectional
ame()fit the prior is controlled bySab0,eta0,Suv0andg.- g
optional scalar for the Zellner g-prior on regression coefficients (
beta ~ N(0, g * sigma^2 * solve(XtX))whereXtXis the design cross-product). If not specified, defaults are: fornormalfamily,g = n * var(Y); for other families,g = n(number of non-missing dyads). Per-coefficient (vector)gis not currently supported by the unipartite path – pass a scalar. Note:gis a top-level argument toame(), not an element ofprior = list(...); passingprior = list(g = 0.1)is a no-op (warned about).- seed
random seed for the MCMC sampler (default 6886). The sampler is seeded internally with this value, so results are reproducible by default and an external
set.seed()call has no effect on the chain – pass a differentseedhere to vary the draws (e.g. when running multiple chains). The caller's.Random.seedis restored on exit, so fitting never perturbs your RNG stream.- nscan
number of iterations of the Markov chain (beyond burn-in)
- burn
burn in for the Markov chain. Typical use is
burnfar smaller thannscan;burn > nscanis allowed but warns.- odens
output density (thinning interval) for the Markov chain.
nscan / odenssamples are stored.- verbose
logical: print progress while running? Default TRUE.
- gof
logical: calculate goodness of fit statistics? Setting to TRUE adds approximately 2-5% to runtime. For faster sampling without GOF overhead, set gof=FALSE and use gof() after model fitting.
- custom_gof
optional function or list of named functions for computing custom goodness-of-fit statistics. Each function must accept a single matrix Y as input and return a numeric vector. If a single function is provided, it should return a named vector. If a list of functions is provided, each function should return a single value and will be named according to the list names. Custom statistics will be computed in addition to default statistics. Example: custom_gof = function(Y) c(density = mean(Y > 0, na.rm = TRUE))
- plot
accepted for signature parity with
lame; ignored.ame()runs a single-period MCMC and does not draw live trace panels. DefaultFALSE.- start_vals
List from previous model run containing parameter starting values for new MCMC
- periodic_save
logical: indicating whether to periodically save MCMC results
- out_file
character vector indicating name and path in which file should be stored if periodic_save is selected. For example, on an Apple OS out_file="~/Desktop/ameFit.rda".
- save_interval
quantile interval indicating when to save during the post-burn-in period.
- posterior_opts
optional list of posterior draw-storage options, usually built with
posterior_options. Recognised names (unknown names trigger a warning):save_UV,save_UV_draws,save_ab,thin_UV,thin_ab.save_UV = TRUEstores per-iteration latent-position draws onfit$U_samples/fit$V_samples([actor, dim, draw]arrays; bipartite fits also store the interaction-matrix draws onfit$G_samples);save_UV_draws(thelamespelling) is accepted as an alias.save_ab = TRUEstores additive-effect draws onfit$a_samples/fit$b_samples.thin_UV/thin_abthin the stored draws. DefaultNULL.- n_chains
integer: number of MCMC chains to run (default: 1)
- cores
integer: number of cores for parallel chains (default: 1)
- use_sparse_matrices
logical: use sparse matrix storage for large networks? (default: FALSE). Recommended only for truly sparse networks (< 10% non-zero entries).
- method
character:
"mcmc"(default, the Bayesian MCMC fit) or"als"(the fast, MCMC-free iterative block coordinate descent point estimator). Whenmethod = "als", MCMC-specific arguments (nscan,burn,odens,prior, ...) are warned about and ignored; the call forwards toame_als.- bootstrap
integer (only used when
method = "als"): number of bootstrap replicates.0(default) skips the bootstrap;N > 0runsNreplicates and attaches the result so thatconfintreturns bootstrap intervals.- bootstrap_type
character (only used when
method = "als"):"parametric"(default) or"block".- bootstrap_block_length
integer: block length for the block bootstrap.
- bootstrap_seed
optional integer seed for the bootstrap.
- save_log_lik
logical: when
TRUE, attach a per-iteration pointwise log-likelihood matrixfit$log_lik(ann_iter x n_obsarray), required forloo(fit)andwaic(fit). For families normal, binary, cbin, poisson, and ordinal this is the exact observed-data log density of Y (fit$log_lik_method = "observed_exact"); only frn falls back to the augmented-Z normal approximation on the latent scale (with a one-time warning). DefaultFALSE(no log_lik storage; default fit is byte-identical to previous releases).- ordinal_cutpoints
character: cutpoint convention for
family = "ordinal"."data_induced"(default) uses the data-induced cutpoints;"explicit"samples explicit cutpoints via a Cowles (1996) Metropolis-Hastings update. Ignored for other families.Deprecated. Use
verboseinstead.- ...
reserved for future use. Passing
lame()-only arguments (e.g.dynamic_beta,period_exposure) here triggers a clean abort directing you tolame; passing any other unrecognised name warns so typos are visible rather than silently dropped.- model.name
optional string for model selection output
Value
Posterior Samples (full MCMC chains):
- BETA
Regression coefficients (
nscan/odensx p matrix; one row per stored draw)- VC
Variance components (
nscan/odensx k matrix)- GOF
Goodness-of-fit statistics ((
nscan/odens+ 1) x 5 matrix). First row contains observed values, remaining rows contain posterior predictive samples. Seegoffor post-hoc computation andgof_plotfor visualization.
Posterior Means (averaged over chain):
- APM
Additive row/sender effects (n-vector)
- BPM
Additive column/receiver effects (m-vector); NULL for symmetric networks
- U
Multiplicative row/sender factors (n xR matrix)
- V
Multiplicative column/receiver factors (m xR matrix); NULL for symmetric networks
- L
Eigenvalue matrix (R xR diagonal); symmetric networks only
- YPM
Posterior mean of Y on response scale (for predictions and imputing missing values)
Metadata:
- family
Model family (normal, binary, etc.)
- mode
Network mode (unipartite or bipartite)
- symmetric
Logical indicating if network is symmetric
- R
Dimension of multiplicative effects
Optional Posterior Samples (if requested via posterior_options):
- U_samples
Samples of U (n xR xiterations array)
- V_samples
Samples of V (m xR xiterations array)
- a_samples
Samples of row effects (n xiterations matrix)
- b_samples
Samples of column effects (m xiterations matrix)
Note on the latent-scale matrices:
The posterior-mean multiplicative product is stored on the fit
(UVPM, or ULUPM for symmetric fits); EZ (the expected
latent network) is not stored, to save memory. Accessors:
reconstruct_EZ(fit)- Returns linear predictor (link scale, not response scale)reconstruct_UVPM(fit)- Returns the stored posterior-mean multiplicative product (UVPM/ULUPM) when present, otherwise U\
Generating posterior distributions:
Use simulate_posterior(fit, component="UV") to generate posterior samples
for components where only means are stored, or use posterior_options()
during model fitting to save full posterior samples.
- model.name
Name of the model (if provided)
Details
This command provides posterior inference for parameters in AME models of cross-sectional relational data, assuming one of eight possible data types/models. The function supports both unipartite networks (square adjacency matrices) and bipartite networks (rectangular adjacency matrices with distinct row and column node sets) for single time point analysis.
Model. For a dyad \((i, j)\) the AME linear predictor is
$$\eta_{ij} = \beta_0 + x_{ij}'\beta + a_i + b_j + u_i' D v_j,$$
where \(\beta\) are regression coefficients on dyadic / nodal
covariates, \(a_i\) is a row (sender) random effect, \(b_j\) is
a column (receiver) random effect, and \(u_i' D v_j\) is the
multiplicative latent-factor term (rank R). The observation
model is \(Y_{ij} \sim F(\eta_{ij}, \theta)\) with \(F\)
specified by family (Gaussian for "normal", probit
for "binary" / "cbin", etc.). For unipartite
(symmetric = FALSE) the residual error has dyad-level
correlation \(\rho\) between \((i, j)\) and \((j, i)\); for
bipartite, dyad correlation is fixed at 0.
Priors (in brief). \(\beta\) has a Zellner-style g-prior
(g); \((a_i, b_i)\) are jointly Normal with covariance
\(\Sigma_{ab}\) (Inverse-Wishart prior Sab0 / eta0);
\(u_i, v_j\) are independent Normal with covariance
\(\Sigma_{uv}\) (Inverse-Wishart prior with scale kappa0 * Suv0
and kappa0 degrees of freedom);
the dyad-correlation \(\rho\) has an arc-sine prior on \((-1, 1)\)
(density proportional to \((1-\rho^2)^{-1/2}\)), updated with
Metropolis steps. See prior_summary(fit) for the priors
actually used.
Choosing R. The multiplicative rank R controls the
dimensionality of latent homophily / heterogeneity not explained
by covariates and additive effects. R = 0 fits an
additive-only social-relations model; R = 1 or 2 is
typical for small / medium networks; R > floor(n/3) is rarely
identifiable and will issue a warning. Latent factors capture
unobserved structure (clusters, hub patterns, transitive triangles
the covariates miss) and are accessed at fit$U, fit$V.
Identifiability. The latent factor term \(u_i' D v_j\)
is invariant to rotation and reflection of \(U, V\); the package
canonicalises with an SVD so successive draws are interpretable.
For visual stability across posterior summaries see
procrustes_align and latent_positions.
Theoretical Foundation:
The AME model decomposes network structure into several components: $$y_{ij} = \beta'x_{ij} + a_i + b_j + u_i'v_j + \epsilon_{ij}$$ where:
\(\beta'x_{ij}\): Fixed effects of dyadic/nodal covariates
\(a_i\): Additive sender (row) effect for node i
\(b_j\): Additive receiver (column) effect for node j
\(u_i'v_j\): Multiplicative interaction between latent factors
\(\epsilon_{ij}\): Dyadic error term (may be correlated)
This specification generalizes the social relations model (Warner et al. 1979) and latent space models (Hoff et al. 2002) within a unified framework.
Prior Distributions:
The model uses conjugate and semi-conjugate priors where possible:
Regression coefficients: \(\beta \sim N(0, g\sigma^2(X'X)^{-1})\) (g-prior)
Additive effects: \((a_i, b_i)' \sim N(0, \Sigma_{ab})\) jointly
Covariance: \(\Sigma_{ab} \sim IW(\eta_0, \eta_0 S_{ab0})\) (inverse-Wishart)
Multiplicative effects: Hierarchical shrinkage via \(\eta_0\)
Dyadic correlation: arc-sine prior on \((-1, 1)\), density \(p(\rho) \propto (1-\rho^2)^{-1/2}\), with Metropolis updates
The inverse-Wishart prior on \(\Sigma_{ab}\) allows learning correlation between sender and receiver effects, capturing reciprocity patterns.
Note on the additive-effects variance scale: for a unipartite fit Sab0
defaults to a data-scaled matrix rather than a fixed diag(2). For the
"normal" and "poisson" families the default is
Sab0 = diag(2) * vscale, where vscale is an empirical-Bayes
moment estimate of the sender/receiver variance: the mean of the variances of
the centred row means and column means of Y (of log1p(Y) for
"poisson"). The "binary", "ordinal", "cbin" and
"frn" families apply the same idea to a probit-moment residual, but
only when start_vals is not supplied and the design has at least one
column; otherwise they fall back to Sab0 = diag(2) with
eta0 = 4. A bipartite fit always uses Sab0 = diag(2).
Call prior_summary() on a fitted object to see the prior actually used.
The data scaling matters because the inverse-Wishart prior contributes
pseudo-data on the scale of eta0 * Sab0 no matter what units Y
is in, so a fixed Sab0 = diag(2) pulls the additive-effects variances
va/vb upward whenever the true sender/receiver variance is well
below 1, most visibly at small \(n\). In Social Relations Model simulations
the data-scaled default recovers small true variances with modest bias where
a fixed diag(2) prior can nearly double them; the data-scaled prior is
mildly more conservative in the opposite regime, when the true variance is
large relative to the residual scale.
This default differs from the amen package, whose
ame(family = "nrm") leaves Sab0 = diag(2) and eta0 = 4.
To reproduce amen's additive-effects posterior, pass
prior = list(Sab0 = diag(2), eta0 = 4). The choice affects only
va, vb and (weakly) cab; ve and rho are
unchanged.
Multiplicative Effects (Latent Factors):
When R > 0, the model includes R-dimensional latent factors:
Asymmetric case: \(u_i, v_j \in \mathbb{R}^R\) with \(u_i'v_j\) interaction
Symmetric case: \(u_i = v_i\) with eigendecomposition \(ULU'\)
Captures homophily, transitivity, and community structure
R chosen via model selection or set to 2-3 for visualization
Estimation Algorithm:
The model uses a Gibbs sampler with the following updates:
Sample latent Z given parameters (data augmentation for non-normal families)
Update regression coefficients \(\beta\) via g-prior conjugate update
Update additive effects (a,b) jointly with \(\beta\)
Update covariance \(\Sigma_{ab}\) from inverse-Wishart
Update multiplicative effects U,V via Gibbs or Metropolis-Hastings
Update dyadic correlation \(\rho\) via Metropolis-Hastings
Update variance \(\sigma^2\) (for continuous families)
Standard Model Types:
The following data types/models are available:
"normal": A normal AME model (identity link: \(E[Y] = \eta\)).
"binary": A binary probit AME model (probit link: \(P(Y=1) = \Phi(\eta)\)).
"ordinal": An ordinal probit AME model (cumulative probit link). An intercept is not identifiable in this model.
"cbin": An AME model for censored binary data (probit link with censoring). The value of 'odmax' specifies the maximum number of links each row may have.
"frn": An AME model for fixed rank nomination networks. A higher value of the rank indicates a stronger relationship. The value of 'odmax' specifies the maximum number of links each row may have.
"poisson": An overdispersed Poisson AME model for count data: \(Y \sim \mathrm{Poisson}(\exp(z))\) with \(z \sim N(\eta, \sigma^2)\), a lognormal-mixed Poisson. The conditional mean given the latent \(z\) is \(\exp(z)\); the marginal mean is \(\exp(\eta + \sigma^2/2)\), not \(\exp(\eta)\).
Supported family x mode combinations
Every family is supported under
both modes. The bipartite Z-samplers live in R/rZ_bipartite.R
and dispatch per family; see also the inline comment in R/lame.R
(the rectangular samplers live in R/rZ_bipartite.R).
| family | unipartite | bipartite |
| normal | yes | yes |
| binary | yes | yes |
| ordinal | yes | yes |
| cbin | yes | yes |
| frn | yes | yes |
| poisson | yes | yes |
Symmetric (symmetric = TRUE) fits require a symmetric Y.
family = "ordinal" with symmetric = TRUE is supported via the
dedicated sampler in R/rZ_ord_sym_fc.R, which uses the
symmetric-doubled precision and mirrors upper-triangle draws to the lower
triangle so \(Z = t(Z)\) holds at every sweep.
Symmetric input with one triangle missing. When
symmetric = TRUE and one triangle of Y is fully NA
(the user stored only the lower or upper triangle), the symmetry validator
any(is.finite(Y - t(Y))) evaluates FALSE and the call
proceeds: the sampler then treats the populated triangle as the
symmetric data and mirrors it. This is usually intended, but if the
upper / lower triangles were meant to differ, the model is silently
fitting half the data. Audit anyNA(Y[upper.tri(Y)]) !=
anyNA(Y[lower.tri(Y)]) before calling if you are unsure.
Data preparation
ame() accepts a matrix directly. For long-format edgelists,
bipartite data, and covariates, use netify to build the network object
and pass that object as Y. ame() will call
netify::to_lame() internally. If you already have an igraph or
network object and only need a plain adjacency matrix,
as_lame_y is still available as a small convenience helper.
For an undirected/symmetric network, pass symmetric = TRUE; for a
rectangular two-mode network (students x courses, donors x candidates), pass
mode = "bipartite" or build the netify object with
mode = "bipartite". Xrow and Xcol accept either a
numeric matrix or a data.frame (coerced internally); Xdyad must be a
3-D array n x n x p of numeric covariates with no
Inf/NaN.
When to use AME vs ERGM
AME and ERGM are complementary tools for binary network analysis, not direct substitutes. ERGM is a class of exponential-family models built around explicit network statistics (counts of edges, mutual ties, triangles, geometrically-weighted shared partners, ...). You write the statistics you think matter, ERGM gives you their coefficients. ERGM excels when you have a substantive theory about which configurations drive tie formation.
AME models latent homophily / heterogeneity directly via
sender, receiver, and multiplicative latent-factor effects. You don't
enumerate triadic terms; the multiplicative-effects rank R
captures higher-order structure (clustering, transitivity, hub
patterns) implicitly. AME excels when (a) you have dyadic / nodal
covariates whose effects you want to interpret cleanly without ERGM
degeneracy, (b) higher-order structure is "nuisance" that you want
to absorb but not parameterise, or (c) you need a posterior
distribution over predictions for forecasting or imputation.
Practical guidance: if your research question is "do nodes that
share attribute X tend to form triangles together?", reach for
ERGM's gwesp. If your research question is "controlling for
unobserved sender / receiver heterogeneity and latent clustering,
what is the effect of dyadic covariate X?", reach for AME. The
R = 0 additive-only case is the social relations model
(Warner, Kenny, Stoto 1979); R >= 1 adds latent space.
ERGM to AME translation
For users coming from statnet::ergm, the rough analogues are:
| ERGM term | AME analogue |
edges | intercept (probit link, not logit) |
nodecov("x") | Xrow = x or Xcol = x |
nodematch("g") | dyadic covariate via nodematch(g) into Xdyad |
nodefactor("g") | dyadic covariate via nodefactor(g) into Xdyad (drop one level) |
absdiff("z") | dyadic covariate via absdiff(z) into Xdyad |
mutual | dcor = TRUE -> the rho parameter (probit-scale, not log-odds; not numerically comparable to ERGM's mutual) |
gwesp / transitivity | R >= 1 multiplicative latent factors (not the same statistic) |
| sender activity heterogeneity | rvar = TRUE, gives a_i, va |
| receiver popularity heterog. | cvar = TRUE, gives b_j, vb |
For family = "binary" the link is probit, so the intercept is on the
probit scale; do not compare it to an ERGM edges estimate by simple
arithmetic.
Migration from amen
Both amen and lame export ame(); loading both
packages fires a startup warning telling you to call
lame::ame(...) or amen::ame(...) explicitly.
For default cross-sectional calls, lame::ame() follows the
amen::ame() interface: the fit$BETA slot is a
2-D [n_stored, p] matrix in both packages, so scripts that
call colMeans(fit$BETA) or apply(fit$BETA, 2, mean)
continue to work unchanged. lame additionally accepts
family = "binary" (which amen 1.4.5 no longer
accepts; amen requires "bin"). The print
argument is deprecated in favour of verbose; calls that pass
print = ... still work but warn.
The cross-sectional path has no dynamic_beta option (an
AR(1) prior on a single-period coefficient is unidentified), so the
BETA 3-D shape that lame() can produce never arises
from ame(). See lame for the longitudinal path
and the silent-aggregation hazard with 2-D apply(fit$BETA, 2, mean)
scripts under dynamic_beta = TRUE.
Notes on priors
The regression-coefficient prior is a Zellner g-prior (
beta ~ N(0, g * sigma^2 * (XtX)^-1)whereXtXis the design cross-product).gis a top-level argument ofame(), not an entry inprior = list(...)(a common slip).There is no per-coefficient prior knob. If you need student_t, horseshoe, or to centre a slope away from zero, AME does not currently expose it; the g-prior structure is the only knob.
Unknown names in
prior = list(...)are warned about (a typo likeSab = ...instead ofSab0would otherwise be silently dropped).
See also
lame for longitudinal models,
gof for post-hoc goodness-of-fit computation,
gof_plot for visualizing GOF results,
latent_positions for extracting latent positions as a tidy data frame,
procrustes_align for Procrustes alignment of latent positions,
summary.ame for model summaries,
coef.ame for coefficient extraction
Examples
# \donttest{
data(YX_bin)
fit <- ame(YX_bin$Y, Xdyad = YX_bin$X, burn = 10, nscan = 100, odens = 1,
family = "binary", verbose = FALSE)
summary(fit)
#>
#> === AME Model Summary ===
#>
#> Call:
#> [1] "Y ~ dyad(intercept, rgpa, rsmoke, cgpa, csmoke, igrade, igpa, ismoke) + a[i] + b[j] + rho*e[ji], family = 'binary'"
#>
#> Regression coefficients:
#> ------------------------
#> Estimate StdError z_value p_value CI_lower CI_upper
#> intercept_dyad -2.508 0.107 -23.332 0 -2.74 -2.331 ***
#> rgpa_dyad 0.18 0.086 2.108 0.035 0.038 0.376 *
#> rsmoke_dyad 0.252 0.105 2.395 0.017 0.059 0.469 *
#> cgpa_dyad 0.179 0.046 3.921 0 0.099 0.263 ***
#> csmoke_dyad 0.179 0.063 2.814 0.005 0.074 0.278 **
#> igrade_dyad 1.099 0.072 15.233 0 0.962 1.284 ***
#> igpa_dyad 0.055 0.037 1.506 0.132 -0.01 0.117
#> ismoke_dyad 0.002 0.049 0.031 0.975 -0.096 0.099
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Note: stars are a visual hint from posterior mean / SD only; for inference use the credible intervals.
#>
#> Variance components:
#> -------------------
#> Estimate StdError
#> va 0.373 0.088
#> cab 0.039 0.018
#> vb 0.070 0.013
#> rho 0.809 0.063
#> ve 1.000 0.000
#> (va = sender, cab = sender-receiver covariance, vb = receiver,
#> rho = dyadic correlation, ve = residual variance)
# Note: you should run the Markov chain much longer in practice
# }