Skip to contents

Thin wrapper around ame_parallel that forces fitter = "lame". Use this for longitudinal data; in particular, multi-chain dynamic_beta / dynamic_uv / dynamic_ab fits are reached through here. The combined fit's $BETA is a 3-D array when dynamic_beta is on, and posterior::rhat(as_draws(fit)) gives R-hat across chains for every per-period coefficient.

Usage

lame_parallel(
  Y,
  n_chains = 4,
  cores = n_chains,
  combine_method = c("pool", "list"),
  ...
)

Arguments

Y

Longitudinal network: list of T relational matrices, or a 3-D array [n, n, T].

n_chains

Number of parallel chains (default 4).

cores

CPU cores to use (default n_chains; 1 = sequential).

combine_method

"pool" (default) or "list".

...

Additional arguments forwarded to lame, including dynamic_beta, dynamic_uv, dynamic_ab, family, nscan, burn, odens, etc.

Value

Same as ame_parallel: a combined lame fit (when combine_method = "pool") or a list of fits.

Examples

# \donttest{
data(YX_bin_list)
fit_pll <- lame_parallel(YX_bin_list$Y, Xdyad = YX_bin_list$X,
                         family = "binary", n_chains = 2, cores = 1,
                         nscan = 50, burn = 10, odens = 5,
                         dynamic_beta = "dyad", verbose = FALSE)
#> 
#> ── Running 2 chains sequentially ──
#> 
#> Starting chain 1 (`lame()`)
#> Warning: `family` = "binary" but `Y` contains values other than 0/1.
#>  `Y` will be thresholded to `1 * (Y > 0)`; if you meant counts, use "poisson",
#>   or "ordinal"/"normal" as appropriate.
#> Completed chain 1
#> Starting chain 2 (`lame()`)
#> Warning: `family` = "binary" but `Y` contains values other than 0/1.
#>  `Y` will be thresholded to `1 * (Y > 0)`; if you meant counts, use "poisson",
#>   or "ordinal"/"normal" as appropriate.
#> Completed chain 2
#> Combining chains...
#> 
#> ── MCMC Convergence Diagnostics 
#> Number of chains: 2
#> Samples per chain: "10, 10"
#> Diagnostics cover regression coefficients and variance components.
#> ! 1 parameter have R-hat >= 1.1
#> rho: R-hat = 2.736
dim(fit_pll$BETA)        # [iter * n_chains, p, T]
#> [1] 20  4  4
fit_pll$chain_indicator  # length iter * n_chains
#>  [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2
if (requireNamespace("posterior", quietly = TRUE)) {
  posterior::summarise_draws(posterior::as_draws(fit_pll))
}
#> # A tibble: 21 × 10
#>    variable      mean median     sd    mad     q5    q95  rhat ess_bulk ess_tail
#>    <chr>        <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl> <dbl>    <dbl>    <dbl>
#>  1 intercept[… 0.0596 0.0621 0.0192 0.0154 0.0315 0.0876  1.24       10       10
#>  2 X1_dyad[t1] 0.451  0.457  0.0625 0.0620 0.340  0.535   1.96       10       10
#>  3 X2_dyad[t1] 0.541  0.549  0.0689 0.0721 0.421  0.629   1.72       10       10
#>  4 X3_dyad[t1] 0.658  0.670  0.0900 0.0932 0.504  0.781   1.81       10       10
#>  5 intercept[… 0.0596 0.0621 0.0192 0.0154 0.0315 0.0876  1.24       10       10
#>  6 X1_dyad[t2] 0.424  0.435  0.0512 0.0590 0.338  0.498   1.62       10       10
#>  7 X2_dyad[t2] 0.527  0.545  0.0685 0.0691 0.413  0.597   1.75       10       10
#>  8 X3_dyad[t2] 0.657  0.661  0.0788 0.0849 0.510  0.754   1.71       10       10
#>  9 intercept[… 0.0596 0.0621 0.0192 0.0154 0.0315 0.0876  1.24       10       10
#> 10 X1_dyad[t3] 0.413  0.429  0.0583 0.0549 0.318  0.489   2.10       10       10
#> # ℹ 11 more rows
# }