Getting error to convert sem object to semPlotModel; length of 'dimnames' [2] not equal to array extent

71 views
Skip to first unread message

zillur rahman

unread,
Sep 24, 2024, 2:43:18 PM9/24/24
to lavaan
Hi,
 I am getting the above-mentioned error to convert a sem object into a semPlotModel object. Any Help?

mediation_results5 <- sem(mediation_model4, data = df2, verbose = TRUE)
> semPlot::semPlotModel(mediation_results5)
Error in dimnames(x) <- dn :
  length of 'dimnames' [2] not equal to array extent

summary(mediation_results5)
lavaan 0.6-18 ended normally after 76 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        72

  Number of observations                        270288

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                              1803.154    1875.300
  Degrees of freedom                                12          12
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  0.962
  Shift parameter                                            0.871
    simple second-order correction                                

Parameter Estimates:

  Parameterization                               Delta
  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  MVPA ~                                              
    BIP_PRS   (a1)    0.008    0.002    3.171    0.002
    Sex              -0.033    0.005   -6.764    0.000
    Age              -0.019    0.000  -61.077    0.000
    PC1               0.001    0.002    0.673    0.501
    PC2               0.001    0.002    0.706    0.480
    PC3               0.004    0.002    2.801    0.005
    PC4              -0.003    0.001   -2.485    0.013
    PC5              -0.001    0.001   -1.405    0.160
    PC6               0.004    0.002    2.646    0.008
    PC7              -0.003    0.001   -2.131    0.033
    PC8               0.004    0.001    3.164    0.002
    PC9              -0.000    0.001   -0.514    0.607
    PC10             -0.002    0.001   -1.902    0.057
  Screen ~                                            
    BIP_PRS   (a2)   -0.015    0.002   -8.008    0.000
    Sex               0.241    0.004   63.938    0.000
    Age               0.016    0.000   68.727    0.000
    PC1               0.004    0.001    3.156    0.002
    PC2              -0.002    0.001   -1.324    0.186
    PC3              -0.002    0.001   -1.468    0.142
    PC4               0.005    0.001    5.099    0.000
    PC5               0.005    0.000   13.568    0.000
    PC6              -0.003    0.001   -2.642    0.008
    PC7               0.002    0.001    1.983    0.047
    PC8              -0.001    0.001   -1.184    0.236
    PC9               0.002    0.000    3.908    0.000
    PC10              0.003    0.001    3.424    0.001
  Healthy_Food ~                                      
    BIP_PRS   (a3)   -0.014    0.003   -5.378    0.000
    Sex               0.282    0.005   55.600    0.000
    Age              -0.025    0.000  -77.724    0.000
    PC1              -0.001    0.002   -0.694    0.488
    PC2              -0.001    0.002   -0.329    0.742
    PC3              -0.002    0.002   -0.999    0.318
    PC4               0.003    0.001    2.376    0.017
    PC5               0.004    0.001    7.550    0.000
    PC6              -0.002    0.002   -1.048    0.294
    PC7               0.000    0.001    0.219    0.827
    PC8              -0.000    0.001   -0.067    0.947
    PC9               0.003    0.001    5.326    0.000
    PC10             -0.001    0.001   -0.775    0.438
  Meat ~                                              
    BIP_PRS   (a4)   -0.014    0.003   -5.378    0.000
    Sex               0.282    0.005   55.600    0.000
    Age              -0.025    0.000  -77.724    0.000
    PC1              -0.001    0.002   -0.694    0.488
    PC2              -0.001    0.002   -0.329    0.742
    PC3              -0.002    0.002   -0.999    0.318
    PC4               0.003    0.001    2.376    0.017
    PC5               0.004    0.001    7.550    0.000
    PC6              -0.002    0.002   -1.048    0.294
    PC7               0.000    0.001    0.219    0.827
    PC8              -0.000    0.001   -0.067    0.947
    PC9               0.003    0.001    5.326    0.000
    PC10             -0.001    0.001   -0.775    0.438
  BMI ~                                              
    BIP_PRS    (c)   -0.047    0.009   -5.460    0.000
    MVPA      (b1)   -0.633    0.011  -59.162    0.000
    Screen    (b2)    0.956    0.008  114.224    0.000
    Helthy_Fd (b3)   -0.036    0.006   -5.816    0.000
    Meat      (b4)   -0.036    0.006   -5.816    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
 .MVPA ~~                                            
   .Screen           -0.102    0.002  -43.911    0.000
   .Healthy_Food     -0.201    0.003  -69.753    0.000
   .Meat             -0.201    0.003  -69.753    0.000
 .Screen ~~                                          
   .Healthy_Food      0.085    0.002   37.476    0.000
   .Meat              0.085    0.002   37.476    0.000
 .Healthy_Food ~~                                    
   .Meat              0.000    0.001    0.030    0.976

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Screen           -0.800    0.020  -40.053    0.000
   .Healthy_Food      1.260    0.027   46.027    0.000
   .Meat              1.260    0.027   46.027    0.000
   .BMI              26.150    0.092  285.225    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)
    MVPA|t1          -1.040    0.026  -39.689    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .MVPA              1.000                          
   .Screen            0.925    0.003  360.269    0.000
   .Healthy_Food      1.728    0.002  715.677    0.000
   .Meat              1.728    0.002  715.677    0.000
   .BMI              19.379    0.043  450.468    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    indirect1        -0.005    0.002   -3.167    0.002
    indirect2        -0.014    0.002   -7.989    0.000
    indirect3         0.000    0.000    3.947    0.000
    indirect4         0.000    0.000    3.948    0.000
    total            -0.065    0.009   -7.385    0.000

Shu Fai Cheung (張樹輝)

unread,
Sep 24, 2024, 7:47:22 PM9/24/24
to lavaan
I believe this error is similar to the one reported below:


-- Shu Fai

zillur rahman

unread,
Sep 25, 2024, 4:29:44 AM9/25/24
to lavaan
Ok. Thank you.
But they don't post any solution to the problem. Only a few users reported the problem and someone just posted codes with publicly available data.
There is no real help.

Reply all
Reply to author
Forward
0 new messages