1

I have done a SEM model in laavan. I looked at direct effect of genes on cognition and indirect effect of gene on cognition via mediator (brain volume).

The code is below:

mydata <- apply(mydata,  2, scale)
model <- "# a path
         Brain_volume ~ a * genes

         # b path
         Cognition ~ b * Brain_volume

         # c prime path 
         Cognition ~ cp * genes

         # indirect and total effects
         ab := a * b
         total := cp + ab
"
fit <- sem(model, data = mydata)
fit
summary(fit, fit.measures=TRUE, ci =TRUE)

This is the output:

lavaan 0.6.13 ended normally after 6 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         5

                                                  Used       Total
  Number of observations                          7462       16383

Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0
lavaan 0.6.13 ended normally after 6 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         5

                                                  Used       Total
  Number of observations                          7462       16383

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

Model Test Baseline Model:

  Test statistic                               473.475
  Degrees of freedom                                 3
  P-value                                        0.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)             -20950.988
  Loglikelihood unrestricted model (H1)     -20950.988
                                                      
  Akaike (AIC)                               41911.975
  Bayesian (BIC)                             41946.563
  Sample-size adjusted Bayesian (SABIC)      41930.674

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

I have numerous missing values, and when I added missing="fiml" this is the output I got (the error msgs are highlighted in bold):

Warning: lavaan WARNING: 6456 cases were deleted due to missing values in exogenous variable(s), while fixed.x = TRUE.

lavaan 0.6.13 ended normally after 7 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         7

                                                  Used       Total
  Number of observations                          9927       16383
  Number of missing patterns                         2    
Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Error in solve.default(X[[i]], ...) : Lapack routine dgesv: system is exactly singular: U[3,3] = 0

This is the traceback output:

10.
solve.default(X[[i]], ...)
9.
FUN(X[[i]], ...)
8.
lapply(Wm, solve)
7.
lav_fit_fiml_corrected(lavobject, version = version)
6.
lav_fit_cfi_lavobject(lavobject = object, fit.measures = fit.measures, 
baseline.model = baseline.model, standard.test = standard.test, 
scaled.test = scaled.test)
5.
lav_fit_measures(object, fit.measures = "default", fm.args = fm.args)
4.
lav_object_summary(object = object, header = header, fit.measures = fit.measures, 
estimates = estimates, ci = ci, fmi = fmi, std = std, standardized = standardized, 
remove.step1 = remove.step1, cov.std = cov.std, rsquare = rsquare, 
std.nox = std.nox, efa = efa.flag, fm.args = fm.args, modindices = modindices)
3.
.local(object, ...)
2.
summary(fit, fit.measures = TRUE)
1.
summary(fit, fit.measures = TRUE)

I understand the error but I don't understand why is it occuring with missing="fiml" when it's not occuring without it.

UPDATE: This analysis was run on a Linux machine. However, I don't get this error message when I ran the same script on my Windows machine.

Could this be related to some package? Can anyone please help?

Thanks!

DobraVila
  • 23
  • 3

0 Answers0