Skip to main content

Edge based analysis with latent space model

The R function sem.net.edge.lsm can be used to conduct edge based analysis with latent space model.

When embedding the LSM into the edge-based approach, one thing that needs to be considered is whether to model covariates predicting the social networks in the LSM framework or in the SEM framework. This is only a concern in the edge-based model since covariates need to be edge-based as well if using the LSM method, and it defies the purpose of simplicity if we consider the LSM in the actor-based approach. In this example, we will accommodate the covariates in the LSM framework within the edge-
based approach. The dataset used in this example is the Florentine marriage dataset. The model is quite simple as shown below. Essentially, the observed marriage network is hypothesized to be based not only on the latent positions, but also on the non-network variable of wealth. Additionally, priorates is viewed as a predictor of the distance between latent positrons of the marriage networks.

model <- '
  flo ~ lp.flo + wealth
  lp.flo ~ priorates 
'

When fitting the model using the sem.net.edge.lsm function, the argument type and latent.dim are needed. Here, although the marriage network contains binary edges, the ordered argument is not needed since only the continuous latent distances will be used in the SEM.

set.seed(100)
res <- sem.net.edge.lsm(model=model, type = "difference", data=data, latent.dim = 2) 

In this model, the latentnet package is first used to estimate the LSM with the covariate of wealth. Then, the resulting latent positions of the marriage network, taking apart the effect of wealth, is hypothesized to be influenced by priorates and the effect is
estimated through lavaan. Thus, the latent distances of the marriage network acts like a mediator between priorates and the observed network. The resulting estimates from both the SEM component and the LSM component are shown below.

### SEM output
> summary(res$estimates$sem.es, fit = TRUE)
lavaan 0.6.15 ended normally after 8 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         2

  Number of observations                           256

Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Model Test Baseline Model:

  Test statistic                                 0.000
  Degrees of freedom                                 1
  P-value                                        1.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000
  Tucker-Lewis Index (TLI)                       1.000

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)               -978.191
  Loglikelihood unrestricted model (H1)             NA
                                                      
  Akaike (AIC)                                1960.381
  Bayesian (BIC)                              1967.472
  Sample-size adjusted Bayesian (SABIC)       1961.131

Root Mean Square Error of Approximation:

  RMSEA                                          0.000
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.000
  P-value H_0: RMSEA <= 0.050                       NA
  P-value H_0: RMSEA >= 0.080                       NA

Standardized Root Mean Square Residual:

  SRMR                                           0.000

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  flo.dists ~                                         
    priorates        -0.000    0.019   -0.000    1.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .flo.dists       122.026   10.786   11.314    0.000


### marriage network LSM results
> summary(res$estimates$lsm.es[[1]])

==========================
Summary of model fit
==========================

Formula:   net ~ euclidean(d = latent.dim) + edgecov(as.matrix(net, attrname = "wealth"))
<environment: 0x7f8cf869e8e8>
Attribute: edges
Model:     Bernoulli 
MCMC sample of size 4000, draws are 10 iterations apart, after burnin of 10000 iterations.
Covariate coefficients posterior means:
                                               Estimate
(Intercept)                                  5.0993e+00
edgecov.as.matrix(net, attrname = "wealth")  9.0489e-05
                                                   2.5%
(Intercept)                                  2.5191e+00
edgecov.as.matrix(net, attrname = "wealth") -1.1898e-02
                                             97.5%
(Intercept)                                 8.2646
edgecov.as.matrix(net, attrname = "wealth") 0.0120
                                            2*min(Pr(>0),Pr(<0))
(Intercept)                                               <2e-16
edgecov.as.matrix(net, attrname = "wealth")               0.9945
                                               
(Intercept)                                 ***
edgecov.as.matrix(net, attrname = "wealth")    
---
Signif. codes:  
% 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Overall BIC:        263.5609 
Likelihood BIC:     90.40981 
Latent space/clustering BIC:     173.1511 

Covariate coefficients MKL:
                                                 Estimate
(Intercept)                                  2.785165e+00
edgecov.as.matrix(net, attrname = "wealth") -9.407945e-05