Title
Examples
set.seed(26)
mblock <- model_mediator_block(n = 100, k = 5)
graph <- sample_tidygraph(mblock)
graph
#> # A tbl_graph: 100 nodes and 1195 edges
#> #
#> # An undirected multigraph with 48 components
#> #
#> # Node Data: 100 × 4 (active)
#> name trt C2 C3
#> <chr> <dbl> <dbl> <dbl>
#> 1 1 1 1 0
#> 2 2 1 1 0
#> 3 3 1 0 1
#> 4 4 1 0 0
#> 5 5 1 0 0
#> 6 6 1 0 0
#> 7 7 1 0 0
#> 8 8 1 0 0
#> 9 9 1 0 0
#> 10 10 1 0 0
#> # ℹ 90 more rows
#> #
#> # Edge Data: 1,195 × 2
#> from to
#> <int> <int>
#> 1 2 13
#> 2 1 12
#> 3 4 6
#> # ℹ 1,192 more rows
fit <- nodelm(US(A, 5) ~ . - name - 1, graph = graph)
fit
#>
#> Call:
#> stats::lm(formula = formula, data = data)
#>
#> Coefficients:
#> 1 2 3 4 5
#> trt 0.677469 0.988492 -0.162015 -0.739258 -0.141555
#> C2 0.425999 0.669099 -0.373419 1.092110 0.102677
#> C3 0.947462 -0.144890 0.497861 0.006272 0.997851
#>