This vignette shows how to:

  1. Synthesize correlation matrices with mars
  2. Fit latent factor models using lavaan-style syntax in path_model()
library(mars)

Synthesize Correlations

becker09 <- na.omit(becker09)

model_out <- mars(
  data = becker09,
  studyID = "ID",
  effectID = "numID",
  sample_size = "N",
  effectsize_type = "cor",
  varcov_type = "weighted",
  variable_names = c(
    "Cognitive_Performance",
    "Somatic_Performance",
    "Selfconfidence_Performance",
    "Somatic_Cognitive",
    "Selfconfidence_Cognitive",
    "Selfconfidence_Somatic"
  )
)

summary(model_out)
#> Results generated with MARS:v 0.5.1.1 
#> Thursday, April  2, 2026
#> 
#> Model Type: 
#> multivariate
#> 
#> Estimation Method: 
#> Restricted Maximum Likelihood
#> 
#> Model Formula: 
#> NULL
#> 
#> Data Summary: 
#> Number of Effect Sizes: 48
#> Number of Fixed Effects: 6
#> Number of Random Effects: 6
#> 
#> Random Components: 
#>          ri_1     ri_2     ri_3      ri_4      ri_5       ri_6
#> ri_1  0.13204  0.07630 -0.03144  0.003058 -0.018150  0.0022236
#> ri_2  0.99878  0.04420 -0.01698  0.001532 -0.009861  0.0008355
#> ri_3 -0.42074 -0.39284  0.04229 -0.007313  0.009630 -0.0122546
#> ri_4  0.23176  0.20062 -0.97927  0.001319 -0.001498  0.0022776
#> ri_5 -0.62514 -0.58701  0.58603 -0.516444  0.006384 -0.0024641
#> ri_6  0.09632  0.06256 -0.93797  0.987249 -0.485426  0.0040360
#> 
#> Fixed Effects Estimates: 
#>  attribute estimate      SE  z_test   p_value   lower     upper
#>          1 -0.09773 0.13777 -0.7093 4.781e-01 -0.3677  0.172299
#>          2 -0.17556 0.08620 -2.0367 4.168e-02 -0.3445 -0.006613
#>          3  0.31868 0.08406  3.7911 1.500e-04  0.1539  0.483438
#>          4  0.52720 0.03335 15.8070 2.785e-56  0.4618  0.592564
#>          5 -0.41756 0.04590 -9.0968 9.305e-20 -0.5075 -0.327591
#>          6 -0.40071 0.04182 -9.5821 9.510e-22 -0.4827 -0.318750
#> 
#> Model Fit Statistics: 
#>  logLik    Dev   AIC   BIC  AICc
#>   18.63 -37.25 16.75 63.67 29.48
#> 
#> Q Error: 230.642 (42), p < 0.0001
#> 
#> I2 (General): 
#>  names values
#>   ri_1  94.53
#>   ri_2  85.26
#>   ri_3  84.69
#>   ri_4  14.71
#>   ri_5  45.51
#>   ri_6  34.56
#> 
#> I2 (Jackson): 
#>  names values
#>   ri_1  90.98
#>   ri_2  77.93
#>   ri_3  81.33
#>   ri_4  16.14
#>   ri_5  43.25
#>   ri_6  31.42
#> 
#> I2 (Between): 83.393
#> 
#> Residual Diagnostics: 
#>   n n_finite_raw mean_raw sd_raw   rmse    mae q_pearson mean_abs_studentized
#>  48           48 -0.02155 0.2127 0.2116 0.1646     133.5                1.419
#>  max_abs_studentized prop_abs_studentized_gt2 prop_abs_studentized_gt3
#>                5.006                   0.2708                   0.1042
#> 
#> Normality (whitened residuals):                   test n_tested statistic p_value
#>  shapiro_wilk_whitened       48    0.9789  0.5351
#> 
#> Heteroscedasticity trend (|raw residual| ~ fitted):   n corr_abs_raw_fitted     slope p_value
#>  48           -0.002893 -0.001091  0.9844

The synthesized (average) correlation matrix can be inspected directly:

R_hat <- corpcor::vec2sm(model_out$beta_r)
diag(R_hat) <- 1
R_hat
#>             [,1]        [,2]       [,3]       [,4]
#> [1,]  1.00000000 -0.09772505 -0.1755555  0.3186811
#> [2,] -0.09772505  1.00000000  0.5271955 -0.4175566
#> [3,] -0.17555552  0.52719552  1.0000000 -0.4007139
#> [4,]  0.31868112 -0.41755660 -0.4007139  1.0000000

One-Factor CFA

path_model() accepts lavaan-like latent syntax (for example, =~, ~~, ~).

model_cfa <- "
General =~ Performance + Cognitive + Somatic + Selfconfidence
"

fit_cfa <- path_model(
  mars_object = model_out,
  model = model_cfa
)

summary(fit_cfa)
#> Results generated with MARS:v 0.5.1.1 
#> Thursday, April  2, 2026
#> 
#> Model Type: 
#> multivariate
#>  
#> Average Correlation Matrix: 
#>                Performance   Cognitive    Somatic Selfconfidence
#> Performance     1.00000000 -0.09772505 -0.1755555      0.3186811
#> Cognitive      -0.09772505  1.00000000  0.5271955     -0.4175566
#> Somatic        -0.17555552  0.52719552  1.0000000     -0.4007139
#> Selfconfidence  0.31868112 -0.41755660 -0.4007139      1.0000000
#> 
#> Synthesis options:
#>   method: model 
#>   transform: none 
#>   missing_corr: available 
#>   attenuation: none 
#>   pd_adjust: none 
#>   pd_adjusted: FALSE 
#>   min eigen (before/after): 0.4579 / 0.4579 
#>   SE note: Latent-model delta SEs are conditional on the synthesized correlation matrix and are not reported. Use se_method = "simulation" or "bootstrap" to propagate correlation uncertainty. 
#> 
#>  
#>  Model Fitted: 
#>  
#> General =~ Performance + Cognitive + Somatic + Selfconfidence
#>  
#>  
#> Fixed Effects: 
#>                           predictor        outcome  estimate standard_errors
#> General -> Performance      General    Performance  1.000000              NA
#> General -> Cognitive        General      Cognitive -2.668056              NA
#> General -> Somatic          General        Somatic -2.701034              NA
#> General -> Selfconfidence   General Selfconfidence  2.249712              NA
#>                           test_statistic p_value
#> General -> Performance                NA      NA
#> General -> Cognitive                  NA      NA
#> General -> Somatic                    NA      NA
#> General -> Selfconfidence             NA      NA
#> 
#>  
#>  Fit Statistics: 
#>                    Type         Value
#> 1      Model Chi-Square 37.632 (2), 0
#> 2 Null Model Chi-Square   393.314 (6)
#> 3                   CFI         0.908
#> 4                   TLI         0.724
#> 5                 RMSEA          <NA>
#> 6                  SRMR         0.059
#> 7             CFI (raw)         0.908
#> 8             TLI (raw)         0.724

Two-Factor Structural Model

This example adds structural regression between latent constructs.

model_sem <- "
Preparation =~ Cognitive + Selfconfidence
Execution =~ Performance + Somatic
Execution ~ Preparation
"

fit_sem <- path_model(
  mars_object = model_out,
  model = model_sem
)

summary(fit_sem)
#> Results generated with MARS:v 0.5.1.1 
#> Thursday, April  2, 2026
#> 
#> Model Type: 
#> multivariate
#>  
#> Average Correlation Matrix: 
#>                Performance   Cognitive    Somatic Selfconfidence
#> Performance     1.00000000 -0.09772505 -0.1755555      0.3186811
#> Cognitive      -0.09772505  1.00000000  0.5271955     -0.4175566
#> Somatic        -0.17555552  0.52719552  1.0000000     -0.4007139
#> Selfconfidence  0.31868112 -0.41755660 -0.4007139      1.0000000
#> 
#> Synthesis options:
#>   method: model 
#>   transform: none 
#>   missing_corr: available 
#>   attenuation: none 
#>   pd_adjust: none 
#>   pd_adjusted: FALSE 
#>   min eigen (before/after): 0.4579 / 0.4579 
#>   SE note: Latent-model delta SEs are conditional on the synthesized correlation matrix and are not reported. Use se_method = "simulation" or "bootstrap" to propagate correlation uncertainty. 
#> 
#>  
#>  Model Fitted: 
#>  
#> Preparation =~ Cognitive + Selfconfidence
#> Execution =~ Performance + Somatic
#> Execution ~ Preparation
#>  
#>  
#> Fixed Effects: 
#>                                 predictor        outcome   estimate
#> Preparation -> Cognitive      Preparation      Cognitive  1.0000000
#> Preparation -> Selfconfidence Preparation Selfconfidence -0.8429299
#> Execution -> Performance        Execution    Performance  1.0000000
#> Execution -> Somatic            Execution        Somatic -2.7029996
#> Preparation -> Execution      Preparation      Execution -0.3744296
#>                               standard_errors test_statistic p_value
#> Preparation -> Cognitive                   NA             NA      NA
#> Preparation -> Selfconfidence              NA             NA      NA
#> Execution -> Performance                   NA             NA      NA
#> Execution -> Somatic                       NA             NA      NA
#> Preparation -> Execution                   NA             NA      NA
#> 
#>  
#>  Fit Statistics: 
#>                    Type        Value
#> 1      Model Chi-Square 37.65 (1), 0
#> 2 Null Model Chi-Square  393.314 (6)
#> 3                   CFI        0.905
#> 4                   TLI        0.432
#> 5                 RMSEA         <NA>
#> 6                  SRMR        0.059
#> 7             CFI (raw)        0.905
#> 8             TLI (raw)        0.432

This workflow supports latent factor analysis after the correlation synthesis step, while keeping model fitting inside MARS.