performance icon indicating copy to clipboard operation
performance copied to clipboard

supporting `lavaan` models in `check_model`

Open statzhero opened this issue 4 years ago • 7 comments

Hi, I got an error when using check_model on a lavaan::sem model object. Could be simply because I'm using it wrong. If not, please let me know. Thank you!

Error in if (minfo$is_bayesian) { : argument is of length zero
In addition: Warning message:
Could not access model information. 

statzhero avatar Jul 10 '20 16:07 statzhero

Do you have a reproducible example?

strengejacke avatar Jul 10 '20 20:07 strengejacke

Here is one, it's a bit lengthy though. The SEM doesn't fit properly because I only included fifty observations. The check_model error is the same.

repex <- structure(list(x2 = c(24, 346, 821, 711, 3, 450, 385, 632, 388, 
859, 677, 919, 250, 25, 22, 63, 191, 82, 113, 36, 749, 510, 160, 
577, 735, 604, 527, 246, 268, 590, 224, 316, 383, 460, 574, 33, 
803, 232, 463, 563, 445, 123, 495, 238, 333, 470, 491, 647, 133, 
750), x3 = c(2, 3, 23, 25, 1, 28, 5, 22, 21, 43, 31, 15, 9, 2, 
7, 4, 6, 3, 4, 8, 32, 28, 9, 31, 34, 27, 15, 12, 15, 26, 16, 
14, 15, 19, 25, 2, 21, 3, 14, 15, 27, 7, 21, 8, 17, 14, 29, 10, 
10, 20), x4 = c(64.05, 52.62, 42.32, 45.34, 72.44, 50.68, 51.93, 
46.99, 51.9, 40.33, 46.1, 31.51, 54.56, 63.64, 64.27, 60.17, 
56.12, 59.43, 58.33, 62.04, 44.42, 49.57, 57.17, 48.22, 44.81, 
47.62, 49.16, 54.67, 54.07, 47.94, 55.23, 53.1, 51.98, 50.49, 
48.27, 62.16, 42.78, 54.97, 50.38, 48.6, 50.74, 58, 49.88, 54.84, 
52.75, 50.22, 49.94, 46.76, 57.68, 44.36), x5 = c(61.33, 39.18, 
62.14, 57.66, 83.48, 45.72, 59.25, 30.66, 64.14, 38.99, 35.86, 
38.73, 52.41, 52.78, 52.29, 58.14, 58.47, 63.75, 52.33, 42.91, 
56.75, 55.39, 56.16, 41.32, 42.67, 54.81, 45.05, 42.43, 43.03, 
33.51, 63.37, 51.52, 41.51, 51.19, 50.2, 50.19, 44.8, 41.25, 
42.36, 57.23, 33.55, 70.03, 41.05, 51.88, 43.63, 43.28, 45.76, 
44.78, 49.92, 42.63), x6 = c(39.95, 39.52, 46.43, 106.23, 50.26, 
39.5, 44.72, 38.31, 42.36, 40.21, 38.32, 55.39, 67.18, 45.95, 
40.13, 40.88, 52.33, 50.94, 41.59, 41.95, 90.45, 42.07, 47.19, 
40.79, 47.04, 89.98, 40.58, 38.31, 40.85, 38.42, 42.4, 54.36, 
43.7, 41.84, 63.86, 39.95, 38.42, 40.65, 38.29, 43.92, 38.45, 
125, 39.28, 40.21, 38.3, 38.85, 38.95, 38.33, 40.21, 38.75), 
    x7 = c(39.95, 39.52, 46.43, 106.23, 50.26, 39.5, 44.72, 38.31, 
    42.36, 40.21, 38.32, 55.39, 67.18, 45.95, 40.13, 40.88, 52.33, 
    50.94, 41.59, 41.95, 90.45, 42.07, 47.19, 40.79, 47.04, 89.98, 
    40.58, 38.31, 40.85, 38.42, 42.4, 54.36, 43.7, 41.84, 63.86, 
    39.95, 38.42, 40.65, 38.29, 43.92, 38.45, 125, 39.28, 40.21, 
    38.3, 38.85, 38.95, 38.33, 40.21, 38.75), x8 = c(35.76, 23.33, 
    76.23, 64.41, 84.89, 37.24, 61.64, 57.73, 32.94, 54.63, 35.77, 
    47.79, 40.36, 41.61, 43.33, 32.54, 39.93, 60.3, 56, 28.75, 
    57.69, 55.82, 56.91, 29.03, 55.99, 32.81, 23.2, 69.82, 44.54, 
    53.19, 54.2, 39.1, 51.79, 49.24, 70.53, 37.55, 56.17, 34.53, 
    30.27, 63.64, 44.13, 48.28, 32.06, 56.65, 69.86, 51.04, 32.78, 
    49.98, 41.18, 54.41), x9 = c(49.79, 38.4, 79.21, 44.54, 109.8, 
    49.64, 54.08, 47.58, 49.44, 46.22, 46, 62.95, 42.92, 74.9, 
    54.78, 47.51, 46.66, 54.19, 56.77, 45.78, 47.4, 46.73, 46.35, 
    45.03, 47.19, 46.85, 44.11, 46.87, 40.64, 46.12, 44.93, 30.59, 
    44.51, 43.05, 67.58, 48.86, 46.21, 46.39, 47.96, 57.19, 47.4, 
    48.15, 47.59, 48.01, 47.57, 46.48, 46.67, 37.71, 52.9, 49.02
    ), x10 = c(43.89, 43.27, 79.17, 67.97, 75.02, 46.68, 49.41, 
    42.08, 52.69, 42.76, 42.32, 49.34, 57.95, 60.83, 45.66, 43.89, 
    48.13, 59.92, 47.66, 42.83, 48.67, 44.89, 48.14, 42.83, 44.44, 
    43.36, 43.36, 41.79, 46.49, 41.73, 44.01, 53.91, 42, 46.37, 
    53.01, 42.91, 41.65, 42.65, 42.13, 50.29, 42.16, 53.42, 43.14, 
    44.66, 41.95, 42.58, 42.01, 41.85, 45.49, 42.61), x11 = c(50.31, 
    41.62, 47.97, 45.92, 51.63, 47.49, 48.36, 60.3, 46.61, 46.15, 
    45.66, 53.03, 45.69, 49.91, 52.8, 47.27, 46.17, 46.91, 50.95, 
    45.51, 46.36, 46.36, 46.09, 44.62, 46.76, 46.82, 44.3, 82.67, 
    44.35, 45.63, 45.19, 44.19, 41.87, 44.98, 51.51, 52.53, 50.95, 
    46.48, 68.02, 49.13, 53.69, 46.35, 48.15, 47.3, 95.53, 46.71, 
    49.26, 44.51, 50.89, 58.48), x12 = c(74.4, 50.63, 36.93, 
    18.99, 39.63, 53.08, 25.74, 61.54, 38.28, 7.69, 57.17, 48.28, 
    48.49, 82.55, 80.92, 70.68, 54.32, 74.69, 58.6, 64.41, 38.07, 
    44.05, 54.22, 80.24, 57.17, -25, 59.8, 50.45, 58.45, 30.75, 
    73.51, 25.85, 90.56, 50.02, 47.17, 74.17, -22.87, 30.65, 
    70.46, 41.06, 65.07, 53.1, 52.27, 60.23, 58.21, 51.57, 33.54, 
    57.25, 58.28, 12.16), x13 = c(55.8, 48.18, 40.77, 35.13, 
    13, 29.32, 55.99, 31.8, 46.48, -25, 67.98, 70.46, 62.23, 
    69.91, 53.03, 42.85, 54.84, 68.38, 69.7, 43.61, 74.67, 46.08, 
    44.56, 72.75, 30.66, -25, 49.13, 27.99, 68.56, 10.85, 71.79, 
    57.53, 76.36, 68.75, 57.13, 59.61, 46.45, 22.28, 71.41, 39.8, 
    55.8, 59.41, 53.32, 56.94, 39.42, 48.94, 64.18, 64.35, 55.22, 
    12.38), x14 = c(79.33, 52.73, 40.4, 20.22, 72.07, 75.11, 
    9.08, 84.82, 36.64, 70.13, 42.35, 27.06, 35.59, 76.97, 91.49, 
    86.93, 51.38, 67.17, 42.68, 77.13, 8.15, 45.34, 61.51, 70.8, 
    79.67, 35, 64.98, 72.66, 43.61, 61.43, 62.06, 7.7, 82.03, 
    31.28, 38.8, 75.19, -25, 49.86, 58.05, 47.33, 65.9, 45.05, 
    49.95, 57.8, 72.41, 53.32, 12.12, 46.1, 56.7, 33.14), x15 = c(22.09, 
    13.2, 56.13, 75.89, 46.66, 25.79, 75.89, 68.45, 10.63, 75.89, 
    32.12, 29.41, 30.48, -5.62, 30.87, 19.74, 35.05, 63.52, 58.89, 
    15.28, 75.89, 75.89, 75.89, 17.57, 75.89, 22.02, 4.38, 75.89, 
    55.49, 74.12, 75.89, 45.35, 75.89, 63.79, 76.8, 26.05, 75.89, 
    27.62, -5.12, 75.89, 42.77, 47.97, 18.39, 75.89, 62.26, 66.7, 
    21.03, 75.89, 29.71, 60.4), x16 = c(56, 91.63, 43.19, 52.02, 
    55.43, 41.48, 55.1, 59.08, 63.83, 45.08, 38.71, 21.15, 42.66, 
    73.57, 44.13, 52.43, 69.66, 58.28, 58.93, 45.08, 34.59, 62.66, 
    60.17, 60.73, 24.94, 53.44, 49.97, 63.42, 63.62, 72.52, 18.67, 
    56.79, 49.97, 54.96, 46.97, 53.17, 43.17, 63.35, 55.58, 54.59, 
    48.53, 64.1, 51.73, 63.57, 48.05, 51.35, 37.24, 39.52, 69.86, 
    41.44), x17 = c(56.25, 44.59, 54.45, 35.23, -25, 35.47, 50.46, 
    42.75, 39.97, 57.52, 40.19, 61.72, 59.93, 54.77, 11.39, 57.64, 
    22.64, 56.18, 64.67, 70.02, 68.89, 63.23, 62.85, 60.48, 35.02, 
    32.69, 25.51, 66.71, 62.92, 45.16, 63.43, 25.82, 60.68, 46.31, 
    60.31, 66.4, 59.29, 57.71, 21.42, 68.47, 63.42, 28.48, 59.03, 
    55.1, 71.19, 51.1, 40.89, 61.05, 38.61, 13.56), x18 = c(56.25, 
    44.59, 54.45, 35.23, -25, 35.47, 50.46, 42.75, 39.97, 57.52, 
    40.19, 61.72, 59.93, 54.77, 11.39, 57.64, 22.64, 56.18, 64.67, 
    70.02, 68.89, 63.23, 62.85, 60.48, 35.02, 32.69, 25.51, 66.71, 
    62.92, 45.16, 63.43, 25.82, 60.68, 46.31, 60.31, 66.4, 59.29, 
    57.71, 21.42, 68.47, 63.42, 28.48, 59.03, 55.1, 71.19, 51.1, 
    40.89, 61.05, 38.61, 13.56), x19 = c(56.58, 112.25, 41.4, 
    50.07, 54.04, 43.14, 60.4, 51.12, 79.86, 37.3, 27.56, 20.52, 
    42.23, 89.14, 39.23, 47.63, 85.52, 60.21, 60.95, 68.63, 17.7, 
    70.49, 68.32, 68.04, -0.97, 50.96, 47.97, 69.93, 73.19, 90.34, 
    37.77, 60.45, 41.38, 54.33, 38.85, 51.32, 30.38, 73.77, 51.14, 
    55.8, 45.33, 72.92, 51.16, 66.82, 45.66, 43.46, 48.4, 25.53, 
    76.11, 26.43), x20 = c(56.17, 33.06, 48.05, 56.17, 53.84, 
    34.1, 52.17, 56.17, 42.66, 56.17, 56.17, -12.39, 51.04, 54.86, 
    50.45, 56.17, 51.35, 56.17, 56.17, 56.17, 56.17, 56.17, 56.17, 
    22.5, 56.17, 56.17, 56.17, 56.17, 56.17, 56.17, 56.17, 56.17, 
    56.17, 49.76, 56.17, 56.17, 56.17, 56.17, 56.17, 56.17, 56.17, 
    54.87, 56.17, 56.17, 56.17, 56.17, 31.17, 56.17, 56.17, 56.17
    ), x21 = c(52.21, 52.21, 52.21, 52.21, 52.21, 46.26, 51.05, 
    52.21, 50.08, 52.21, 52.21, 30.65, 48.99, 50.57, 52.21, 52.21, 
    52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 
    52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 44.15, 
    52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 52.21, 50.58, 52.21, 
    52.21, 52.21, 52.21, 36.49, 52.21, 52.21, 52.21), x22 = c(59.78, 
    74.82, 33.47, 37.23, 54.14, 59.78, 74.82, 63, 106.62, -7.87, 
    14.68, 19.69, 41.74, 74.82, 59.78, 37.23, 54.14, 49.37, 47.25, 
    102.38, 33.47, 54.14, 68.46, 16.94, 33.47, 59.78, 82.33, 
    85.15, 37.23, 41.74, 80.72, 30.29, 85.15, 66.55, 47.25, 41.74, 
    23.14, 37.23, 16.94, 104.88, 74.82, 66.55, 63, 95.49, 82.33, 
    37.23, 41.74, 16.94, 41.74, 25.21), x23 = c(89.24, 89.62, 
    39.13, 88.22, 87.52, 38.74, 32.11, 36.12, 35.57, 87.52, 28.18, 
    87.52, 33.23, 89.24, 29.56, 34.15, 39.13, 89.62, 88.22, 87.52, 
    2.02, 39.13, 39.45, 88.78, 22.29, 38.74, 33.23, 81.2, 38.74, 
    88.78, 12.26, 89.62, 37.02, 88.78, 37.72, 88.78, 30.71, 38.74, 
    83.73, 38.74, 32.11, 38.28, 36.12, 89.62, 84.65, 34.15, 88.78, 
    47.16, 88.78, 14.48), x24 = c(37.63, 99.51, 36.1, 37.18, 
    37.95, 36.51, 38.83, 37.32, 40.31, 35.89, 36.76, 36.56, 37.01, 
    100.14, 39.04, 36.76, 99.3, 38.29, 37.24, 41.22, 37.83, 99.18, 
    99.31, 35.78, 37.58, 37.32, 38.69, 39.46, 35.95, 97.49, 38.26, 
    35.5, 38.47, 37.5, 36.27, 36.73, 36.17, 98.49, 35.86, 40.17, 
    38.23, 99.51, 37.49, 39.33, 38.87, 36.82, 36.59, 38.1, 37.15, 
    35.75), x25 = c(35.67, 125, 35.67, 35.67, 35.67, 35.67, 35.67, 
    35.67, 81.18, 35.67, 35.67, 35.67, 35.67, 81.18, 35.67, 81.18, 
    81.18, 58.42, 35.67, 35.67, 35.67, 81.18, 58.42, 125, 35.67, 
    35.67, 35.67, 35.67, 111.52, 88.76, 81.18, 81.18, 35.67, 
    35.67, 35.67, 35.67, 35.67, 81.18, 35.67, 35.67, 35.67, 81.18, 
    35.67, 35.67, 35.67, 35.67, 35.67, 35.67, 125, 35.67), x26 = c(57.78, 
    57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 
    57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 
    57.78, 57.78, 57.78, 57.78, 57.78, -25, 57.78, -1.71, 57.78, 
    57.78, 57.78, -1.71, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 
    57.78, 57.78, 57.78, 57.78, 57.78, 57.78, 57.78, -1.71, 57.78, 
    57.78, 57.78, 57.78, 57.78), x27 = c(58.1, 58.1, 48.54, 58.1, 
    58.1, 36.43, 47.86, 52.3, 45.46, 58.1, 58.1, 10.98, 46.28, 
    58.03, 42.38, 58.1, 58.1, 58.1, 58.1, 18.09, 58.1, 58.1, 
    58.1, 58.1, 58.1, 58.1, 58.1, 58.1, 52.95, 58.1, -21.91, 
    58.1, 58.1, 58.1, 58.1, 57.74, 58.1, 58.1, 58.1, 58.1, 58.1, 
    58.1, 58.1, 58.1, 58.1, 58.1, 19.21, 58.1, 58.1, 58.1), x28 = c(57.04, 
    57.04, 39.2, 57.04, 57.04, 16.6, 52.31, 57.04, 39.71, 57.04, 
    57.04, -25, 43.9, 57.04, 27.7, 57.04, 57.04, 57.04, 57.04, 
    57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 
    57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 
    57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 57.04, 
    -7.09, 57.04, 57.04, 57.04), x29 = c(52.91, 52.91, 52.91, 
    52.91, 52.91, 52.91, 38.53, 42.08, 46.65, 52.91, 52.91, 52.91, 
    43.99, 52.79, 52.91, 52.91, 52.91, 52.91, 52.91, 52.91, 52.91, 
    52.91, 52.91, 52.91, 52.91, 52.91, 52.91, 52.91, 43.29, 52.91, 
    52.91, 52.91, 52.91, 52.91, 52.91, 52.25, 52.91, 52.91, 52.91, 
    52.91, 52.91, 52.91, 52.91, 52.91, 52.91, 52.91, 44.45, 52.91, 
    52.91, 52.91), x30 = c(35.79, 95.94, 65.87, 35.79, 35.79, 
    65.87, 95.94, 65.87, 95.94, 35.79, 35.79, 35.79, 65.87, 35.79, 
    35.79, 35.79, 95.94, 35.79, 65.87, 35.79, 5.72, 35.79, 35.79, 
    65.87, 35.79, 65.87, 95.94, 65.87, 95.94, 65.87, 35.79, 35.79, 
    5.72, 35.79, 35.79, 35.79, 35.79, 65.87, 65.87, 35.79, 35.79, 
    35.79, 65.87, 35.79, 35.79, 65.87, 65.87, 5.72, 35.79, 35.79
    ), x31 = c(55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 
    55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 
    55.17, 55.17, 55.17, -19.51, 55.17, 55.17, 55.17, 55.17, 
    55.17, 55.17, 55.17, 55.17, 55.17, 55.17, -25, 55.17, 55.17, 
    55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 
    55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17, 55.17), 
    x32 = c(70.09, 56.08, 27.52, 26.26, 68.83, 67.15, 42.07, 
    47.1, 45.9, 30.23, 51.1, 25.17, 61.29, 71.66, 76.91, 64.35, 
    49.02, 61.24, 69.28, 77.17, 35.53, 54.2, 66.09, 62.81, 45.86, 
    35.33, 45.13, 66.62, 52.61, 45.55, 63.61, 53.07, 58.01, 45.17, 
    42.49, 71.7, 31.81, 62.87, 52.16, 35.32, 59.63, 52.42, 46.77, 
    62.45, 63.11, 49.6, 57.34, 50.29, 59.66, 43.08), x33 = c(81.66, 
    65.83, -25, 55.87, 103.4, 52.93, 53.81, 39.17, 50.01, 11.94, 
    38.29, 38.29, 83.4, 81.36, 88.4, 50.01, 59.67, -4.22, 118.91, 
    78.42, 47.08, 47.08, 103.04, 58.79, 29.51, 90.45, 47.08, 
    55.87, 50.88, 38.29, 55.87, 51.19, 47.08, 47.96, 29.51, 47.08, 
    20.72, 95.49, 47.08, 67.58, 39.17, 109.25, 47.08, 52.93, 
    47.08, 47.08, 47.08, 47.08, 62.6, 47.08), x34 = c(61.52, 
    61.52, 61.52, 26.47, 61.52, 96.57, 61.52, 26.47, 96.57, 61.52, 
    61.52, 26.47, 61.52, 96.57, 96.57, 61.52, 26.47, 61.52, 61.52, 
    61.52, 26.47, 26.47, 61.52, 26.47, 26.47, 96.57, 26.47, 61.52, 
    26.47, 26.47, 61.52, 61.52, 61.52, 61.52, 26.47, 96.57, 26.47, 
    26.47, 26.47, 26.47, 26.47, 61.52, 26.47, 96.57, 61.52, 26.47, 
    61.52, 26.47, 61.52, 26.47), x35 = c(80.35, 57.29, 26.72, 
    23.21, 49.27, 57.29, 16.2, 34.24, 38.25, 58.8, 49.27, 21.71, 
    40.25, 50.28, 90.87, 81.85, 35.74, 65.81, 52.78, 85.86, 12.69, 
    62.31, 56.79, 53.79, 81.85, 62.31, 56.79, 88.87, 48.77, 105.91, 
    49.27, 40.75, 79.35, 46.77, 37.25, 81.85, -20.89, 56.79, 
    40.75, 31.73, 63.81, 56.29, 47.27, 50.78, 59.8, 50.28, 18.2, 
    42.8, 43.26, 45.77), x36 = c(68.69, 46.07, 36.03, 25.34, 
    94.17, 89.62, 24.62, 29.28, 54.85, 18.52, 58.61, -15.24, 
    56.87, 83.27, 106.06, 96.13, 56.42, 81.2, 72.86, 104.97, 
    30.65, 42.44, 49.41, 38.16, 23.78, 22.85, 25.92, 68.86, 39.37, 
    21.09, 39.4, 79.12, 23.62, 40.35, 36.08, 92.49, 21.35, 47.57, 
    44.46, 42.57, 55.43, 30.56, 23.02, 95.05, 84.8, 38.2, 92.69, 
    34.49, 67.42, 45.36), x37 = c(86.14, 35.74, 35.74, 50.13, 
    86.14, 86.14, 35.74, 35.74, 86.14, 35.74, 35.74, 14.13, 86.14, 
    86.14, 100.57, 100.57, 50.13, 86.14, 64.53, 100.57, 35.74, 
    35.74, 35.74, 14.13, 35.74, 50.13, 14.13, 50.13, 14.13, 14.13, 
    35.74, 78.96, 35.74, 35.74, 57.35, 86.14, 14.13, 14.13, 14.13, 
    35.74, 35.74, 35.74, 14.13, 100.57, 57.35, 35.74, 86.14, 
    14.13, 71.74, 50.13), x38 = c(43.11, 58.12, 42.39, 11.28, 
    82.99, 75.87, 24.54, 31.83, 21.45, 14.99, 77.74, -16.23, 
    24.62, 65.93, 87.16, 71.62, 59.92, 62.69, 71.26, 85.46, 33.98, 
    52.42, 63.33, 67.34, 23.22, 7.37, 48.19, 79.38, 69.24, 40.63, 
    47.68, 66.61, 22.97, 49.15, 20.86, 80.36, 41.04, 82.07, 77.2, 
    52.63, 72.76, 33.84, 43.65, 69.93, 97.11, 45.8, 80.67, 61.59, 
    55.52, 42.61), x39 = c(43.92, 72.46, 61.65, 20.85, 71.74, 
    69.22, 37.86, 61.58, 53.72, 65.9, 50.48, 24.81, 56.97, 53.65, 
    84.36, 81.11, 65.62, 77.51, 61.65, 71.02, 38.94, 59.49, 72.82, 
    50.4, 65.98, 64.17, 36.71, 75.27, 65.62, 39.95, 85.44, 42.55, 
    85.8, 49.76, 52.64, 50.4, 28.78, 59.85, 41.03, 65.98, 77.87, 
    61.29, 55.16, 59.85, 59.41, 35.27, 41.83, 9.44, 71.74, 32.38
    ), x40 = c(31.47, 67.33, 67.33, 31.47, 67.33, 67.33, 67.33, 
    31.47, 67.33, 31.47, 67.33, 31.47, 67.33, 31.47, 67.33, 67.33, 
    67.33, 67.33, 67.33, 67.33, 67.33, 67.33, 67.33, 31.47, 67.33, 
    67.33, 31.47, 31.47, 67.33, 31.47, 67.33, 67.33, 67.33, 67.33, 
    67.33, 31.47, 31.47, 67.33, 31.47, 67.33, 67.33, 67.33, 67.33, 
    67.33, 31.47, 31.47, 67.33, -4.4, 67.33, 31.47), x41 = c(59.79, 
    64.97, 49.42, 26.62, 63.93, 60.3, 15.22, 85.18, 38.02, 91.4, 
    33.36, 32.32, 42.68, 73.78, 82.07, 77.41, 55.12, 72.22, 49.42, 
    62.89, 16.77, 46.31, 65.49, 69.11, 55.64, 53.05, 49.42, 104.87, 
    55.12, 54.09, 83.62, 21.96, 84.14, 32.32, 36.47, 69.11, 38.02, 
    46.83, 55.64, 55.64, 72.74, 48.9, 40.09, 46.83, 82.07, 47.35, 
    20.92, 46.07, 63.93, 43.2), x42 = c(67.96, 69.4, 55.56, 15.85, 
    55.62, 70.08, 19.04, 42.92, 52.3, 63.56, 47.11, 17.52, 36.91, 
    88.66, 90.6, 71.02, 52.6, 60.87, 48.69, 72.42, 7.32, 40.45, 
    55.39, 46.14, 58.99, 69.61, 31.07, 88.37, 33.18, 75.92, 59.59, 
    35.03, 79.1, 41.01, 25.2, 104.79, 5.14, 59.63, 31.13, 47.79, 
    50.69, 49.71, 54.34, 64.46, 67.37, 31.89, 22.48, 28.99, 47.37, 
    29.53), x43 = c(52.22, 52.22, 40.45, 52.22, 52.22, 52.22, 
    52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 
    52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 
    52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 
    52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 
    52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22, 52.22), 
    x44 = c(52.85, 52.85, -25, 52.85, 52.85, 52.85, 52.85, 52.85, 
    52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 
    -25, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 
    52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 
    52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 52.85, 
    52.85, 52.85, 52.85, 52.85, 52.85, 52.85), x45 = c(56.56, 
    56.56, 75.24, 69.02, 69.02, 62.78, 64.65, 33.52, 56.56, -24.41, 
    31.65, 31.65, 93.93, 89.57, 70.89, 56.56, 77.11, 81.46, 102.02, 
    83.33, 50.33, 50.33, 102.02, 75.24, 12.96, 75.24, 50.33, 
    69.02, 58.42, 31.65, 69.02, 25.41, 50.33, 52.2, 12.96, 50.33, 
    -5.73, 52.2, 50.33, 93.93, 33.52, 81.46, 50.33, 62.78, 50.33, 
    50.33, 50.33, 50.33, 83.33, 50.33), x46 = c(78.07, 63.71, 
    32.45, 26.27, 82.45, 76.03, 57.52, 57.21, 26.92, 57.68, 57.82, 
    -5.12, 47.1, 55.08, 80.04, 49.06, 35.32, 66.44, 60.48, 69.36, 
    15.09, 46.24, 51.57, 67.55, 46.47, 7.7, 42.84, 61.88, 49.14, 
    70.4, 55.66, 59.88, 75.4, 37.11, 25.14, 67.51, 39.7, 80.37, 
    79.06, -25, 64.32, 31.28, 49.22, 62.95, 64.96, 87.76, 65.73, 
    53.33, 56.65, 53.57), x47 = c(52.53, 52.53, 41.19, 52.25, 
    52.39, 52.53, 52.53, 52.53, 48.39, 52.53, 52.53, 52.53, 52.42, 
    52.29, 52.53, 52.53, 52.53, 52.53, 52.53, 52.53, 52.53, 52.53, 
    52.53, 52.53, 52.53, 52.53, 52.53, 52.53, 47.78, 52.53, 52.53, 
    52.53, 52.53, 52.53, 52.53, 52.53, 52.53, 52.53, 52.53, -25, 
    52.53, 49, 52.53, 51.89, 52.53, 52.53, 52.53, 52.53, 52.53, 
    52.53), x48 = c(54.4, 66.33, 38.5, 12.65, 78.76, 75.78, 38.5, 
    62.36, 40.49, 46.95, 67.82, 9.67, 30.05, 42.47, 83.23, 62.36, 
    59.87, 59.87, 63.85, 72.3, 21.6, 58.88, 66.83, 73.29, 54.4, 
    14.64, 69.32, 70.81, 62.85, 92.18, 60.37, 36.01, 81.25, 40.98, 
    10.16, 74.78, 23.59, 62.36, 62.36, 38, 87.21, 37.01, 48.94, 
    59.37, 76.77, 63.85, 78.26, 46.76, 56.89, 40.49), x49 = c(97.39, 
    57.67, 36.34, 39.16, 81.66, 72.08, 73.53, 49.07, 16.46, 65.38, 
    44.78, -18.88, 61.92, 65.06, 72.38, 33.3, 9.19, 69.42, 53.91, 
    62.64, 8.31, 31.32, 33.69, 58.14, 36.23, 0.96, 14.29, 49.66, 
    37.7, 44.78, 48.06, 80.58, 65.38, 31.54, 39.18, 56.58, 53.96, 
    93.89, 91.35, 68.08, 37.97, 27.75, 47.02, 63.8, 49.66, 106.71, 
    49.66, 57.16, 53.46, 63.9), x50 = c(67.99, 44.7, 39.74, -5.53, 
    40.41, 59.32, 38.34, 40.99, 44.17, -2.01, 47.26, 47.06, 78.78, 
    70.57, 52.02, 45.32, 37.19, 69.32, 64.19, 84.37, 40.95, 79.81, 
    76.96, 83.61, 59.91, 37.1, 52.72, 81.5, 53.76, 48.13, 76.55, 
    56.51, 40.97, 49.43, 63.45, 84.72, 75.54, 55.98, 41.1, 48.56, 
    62.54, 43.54, 41.93, 49.17, 62.59, 31.14, 62.68, 79.73, 50.53, 
    65.39), x51 = c(67.99, 44.7, 39.74, -5.53, 40.41, 59.32, 
    38.34, 40.99, 44.17, -2.01, 47.26, 47.06, 78.78, 70.57, 52.02, 
    45.32, 37.19, 69.32, 64.19, 84.37, 40.95, 79.81, 76.96, 83.61, 
    59.91, 37.1, 52.72, 81.5, 53.76, 48.13, 76.55, 56.51, 40.97, 
    49.43, 63.45, 84.72, 75.54, 55.98, 41.1, 48.56, 62.54, 43.54, 
    41.93, 49.17, 62.59, 31.14, 62.68, 79.73, 50.53, 65.39), 
    x52 = c(36.21, 95.27, 95.27, 36.21, 36.21, 36.21, 36.21, 
    36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 95.27, 36.21, 36.21, 
    95.27, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 
    36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 
    36.21, 95.27, 36.21, 95.27, 36.21, 95.27, 36.21, 36.21, 95.27, 
    36.21, 36.21, 36.21, 36.21, 36.21, 36.21, 36.21), x53 = c(67.16, 
    34.77, 30.48, 28.1, 67.16, 60.49, 8.1, 85.26, 34.77, 77.64, 
    45.72, 33.82, 29.05, 55.25, 78.59, 73.35, 49.06, 63.82, 46.2, 
    72.87, 17.15, 50.96, 59.06, 73.83, 78.11, 54.3, 32.86, 110.02, 
    46.2, 96.69, 77.16, 23.81, 96.21, 32.86, 37.63, 64.3, 45.25, 
    45.72, 49.06, 40.96, 75.25, 45.25, 41.91, 52.87, 86.21, 41.44, 
    14.76, 41.62, 52.39, 40.01), x54 = c(105.72, 72.05, 38.39, 
    38.39, 125, 38.39, 38.39, 38.39, 38.39, 38.39, 38.39, 38.39, 
    72.05, 72.05, 105.72, 38.39, 38.39, 38.39, 125, 72.05, 38.39, 
    38.39, 105.72, 38.39, 38.39, 105.72, 38.39, 38.39, 38.39, 
    38.39, 38.39, 72.05, 38.39, 38.39, 38.39, 38.39, 38.39, 125, 
    38.39, 38.39, 38.39, 125, 38.39, 38.39, 38.39, 38.39, 38.39, 
    38.39, 38.39, 38.39), x55 = c(72.51, 48.3, -25, 65.11, 77.36, 
    73.01, 68.15, 49.75, 70.66, 40.54, 49.75, 64.45, 70.37, 77.36, 
    49.75, 71.67, 55.09, 67.14, 49.75, 56.44, 58.95, 68.15, 64.98, 
    65.14, 40.54, 58.95, 76.78, 58.95, 71.17, 49.75, 77.36, 58.95, 
    40.54, 49.75, 58.95, 58.95, 49.75, 65.05, 49.75, 12.11, 58.95, 
    68.15, 68.42, 49.75, 49.75, 49.75, 58.95, 68.15, 70.5, 40.54
    ), x56 = c(52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 
    52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 
    52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 
    52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 
    52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 
    52.76, 52.76, 52.76, 52.76, 52.76, 52.76, 52.76), x57 = c(55.77, 
    53.73, 46.16, 50.18, 55.77, 55.77, 55.77, 55.77, 55.77, 55.77, 
    55.77, 48.96, 52.46, 55.77, 55.77, 55.77, 51.72, 53.9, 55.77, 
    55.77, 55.77, 55.77, 53.63, 55.77, 55.77, 55.77, 54.7, 55.77, 
    55.77, 55.77, 55.77, 55.77, 55.77, 55.77, 55.77, 55.77, 55.77, 
    50.37, 55.77, 47.2, 55.77, 55.77, 49.49, 55.77, 55.77, 55.77, 
    55.77, 55.77, 55.77, 55.77), x58 = c(81.18, 81.18, 81.18, 
    64.26, 81.18, 81.18, 64.26, 30.43, 81.18, 13.52, 30.43, 64.26, 
    81.18, 81.18, 30.43, 81.18, 64.26, 64.26, 30.43, 47.35, 47.35, 
    64.26, 81.18, 64.26, 13.52, 47.35, 81.18, 47.35, 81.18, 30.43, 
    81.18, 47.35, 13.52, 30.43, 47.35, 47.35, 30.43, 81.18, 30.43, 
    64.26, 47.35, 64.26, 81.18, 30.43, 30.43, 30.43, 47.35, 64.26, 
    81.18, 13.52), x59 = c(51.65, 9.21, -25, 60.57, 60.57, 52.57, 
    60.57, 60.57, 48.27, 60.57, 60.57, 60.57, 51.04, 60.57, 60.57, 
    50.11, 40.61, 60.57, 60.57, 55.96, 60.57, 60.57, 39.96, 55.03, 
    60.57, 60.57, 60.57, 60.57, 49.19, 60.57, 60.57, 60.57, 60.57, 
    60.57, 60.57, 60.57, 60.57, 43.35, 60.57, -25, 60.57, 60.57, 
    50.42, 60.57, 60.57, 60.57, 60.57, 60.57, 47.96, 60.57), 
    x60 = c(57.36, 50.67, 29.92, 35.08, 53.06, 57.05, 48.63, 
    43.19, 47.23, 22.21, 57.91, 45.08, 56.77, 64.71, 57.78, 56.03, 
    51.97, 62.05, 59.94, 62.44, 52.22, 58.54, 59.1, 65.6, 43.18, 
    30.53, 55.26, 58.76, 60.46, 42.35, 63.02, 57.39, 47.6, 53.64, 
    50.86, 64.73, 52.92, 55.02, 57.37, 30.06, 59.13, 51.03, 52.01, 
    54.98, 58.94, 46.73, 61.87, 63.1, 56.09, 44.28), x61 = c(TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), x62 = c(65.7, 
    56.71, 52.17, 37.94, 67.54, 74.4, 43.19, 38.31, 66.25, 39.51, 
    45.73, 23.75, 67.76, 75.24, 88.65, 76.32, 51.01, 74.49, 68.5, 
    80.46, 32.84, 46.87, 65.78, 44.01, 44.6, 69.68, 36.89, 68.96, 
    42.68, 43.62, 60.2, 49.84, 62.55, 49.2, 37.33, 73.06, 8.55, 
    41.89, 34.54, 50.77, 47.48, 59.26, 38.67, 74.11, 57.68, 39.62, 
    51.6, 28.63, 66.32, 41.02), x63 = c(54.86, 65.26, 53.6, 48.44, 
    58.29, 47.63, 44.33, 56.37, 49.93, 56.53, 44, 35.53, 43.64, 
    63.32, 50.31, 54.95, 61.03, 57.78, 54.1, 50.75, 35.17, 51.7, 
    51.97, 61.83, 44.11, 47.53, 44.26, 63.25, 57.81, 65.02, 40.33, 
    48.88, 51.72, 47.24, 46.96, 59.68, 39.91, 57.77, 53.01, 52.88, 
    49.94, 50.12, 52.83, 53.53, 53.23, 49.27, 39.17, 44.25, 60.03, 
    43.09), x64 = c(66.29, 66.83, 30.32, 36.1, 57.91, 52.98, 
    52.48, 49.39, 47.87, 41.3, 42.21, 28.57, 50.79, 66.02, 60.63, 
    45.5, 48.05, 40.93, 63.54, 67.64, 37.33, 56.85, 69.96, 47.98, 
    41.13, 43.42, 45.91, 57.57, 46.84, 58.94, 54.58, 47.59, 60.31, 
    44.87, 40.63, 52.5, 41.05, 75.36, 45.59, 58.69, 56.13, 62.45, 
    49.53, 57.76, 58.58, 55.28, 48.34, 44.46, 45.58, 38.59)), row.names = c(NA, 
-50L), class = c("tbl_df", "tbl", "data.frame"))

# Latent variables
se <- c("x13",
         "x38",
         "x43",
         "x47",
         "x50",
         "x55")

fl <- c("x34",
         "x35",
         "x37",
         "x39",
         "x45")

vi <- c("x8",
         "x14",
         "x20",
         "x21",
         "x23",
         "x25",
         "x25",
         "x27",
         "x30",
         "x52",
         "x53")

eq <- c("x18",
         "x22",
         "x24",
         "x44",
         "x48",
         "x49",
         "x54")


# Model
esvf_cfa <- paste0(
  "s =~ ", paste(se, collapse = '+'), "\n",
  "f =~ ", paste(fl, collapse = '+'), "\n",
  "v =~ ", paste(vi, collapse = '+'), "\n", 
  "e =~ ", paste(eq, collapse = '+')
)


esvf <- lavaan::sem(esvf_cfa, data = repex, std.lv = TRUE, model.type = "cfa")
summary(esvf, fit.measures = TRUE)

performance::check_model(esvf)

Result of last command

Error in if (minfo$is_bayesian) { : argument is of length zero
In addition: Warning message:
Could not access model information. 

statzhero avatar Jul 11 '20 00:07 statzhero

Ah, got it. check_model() does not support lavaan objects. Maybe I can implement this.

strengejacke avatar Jul 20 '20 09:07 strengejacke

Assumption checks for CFA/SEM are hard.

But here is what I taught last year (might help) https://github.com/mattansb/Structural-Equation-Modeling-foR-Psychologists/blob/master/06%20assumption%20checks/assumption%20checks.R

mattansb avatar Jan 13 '21 15:01 mattansb

Related to that (looking at Mattan's link), a long time ago I wanted to add report support for lavaan::modificationIndices(), but a nice first step could be to support it by parameters() that could improve its output?

DominiqueMakowski avatar Jan 14 '21 01:01 DominiqueMakowski

Regarding modification indices, something like this from the OpenMx::mxMI() help file could be good:

Users should be cautious in their use of modification indices. If a model was created with the aid of MIs, then it should always be reported. Do not pretend that you have a theoretical reason for part of a model that was put there because it was suggested by a modification index. This is fraud. When using modification indices there are two options for best practices. First, you can report the analyses as exploratory. Document all the explorations that you did, and know that your results may or may not generalize. Second, you can use cross-validation. Reserve part of your data for exploration, and use the remaining data to test if the exploratory model generalizes to new data.

bwiernik avatar Jul 14 '21 16:07 bwiernik

I would just like to express my explicit support for this possible future enhancement. It would be very useful to me and my colleagues. I realize this must be quite complicated and thus a ton of work, so thanks for keeping the issue open 💪

rempsyc avatar May 25 '22 02:05 rempsyc