tests/testthat/test-sem.R

context("Structural Equation Modeling")

options <- jaspTools::analysisOptions("SEM")
options$models <- list(list(name = "Model1", syntax = list(model = "x1 ~ x2 + x3 + y1", columns = c("x1", "x2", "x3", "y1"))))
options$emulation         <- "lavaan"
options$estimator         <- "default"
options$group             <- ""
options$samplingWeights   <- ""
options$informationMatrix <- "expected"
options$naAction          <- "fiml"
options$modelTest         <- "standard"
results <- jaspTools::runAnalysis("SEM", "poldem_grouped.csv", options)

fittab   <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fittab"]][["data"]]

test_that("Basic SEM fit table works", {
  if (jaspBase::getOS() == "linux") skip("Skipped for now cause that part of the table is removed in another PR anyways")
  expect_equal_tables(fittab, list(48.156355426353, 59.7437959940346, 0, 0, "Model1", 75, 1, "", 0, 0), "Model fit table")
})

  parcont <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]]
  parcov  <- parcont[["modelContainer_params_cov"]][["data"]]
  parreg  <- parcont[["modelContainer_params_reg"]][["data"]]
  parvar  <- parcont[["modelContainer_params_var"]][["data"]]
  partot  <- parcont[["modelContainer_params_toteff"]][["data"]]


test_that("Basic SEM covariance parameter table works", {
  expect_equal_tables(parcov, list(1.782009228184, 1.782009228184, 1.782009228184, "", "x2 - x3",
                                   "", 0, "", 1.2564136096, 1.2564136096, 1.2564136096, "", "x2 - y1",
                                   "", 0, "", 0.899301179999998, 0.899301179999998, 0.899301179999998,
                                   "", "x3 - y1", "", 0, ""),
                      "Covariance parameter table")
  expect_equal_tables(parreg, list(0.26348889641759, 0.446867412394827, 0.355178154406208, "x1",
                                   3.13082892944294e-14, "x2", 0.0467810932812294, 7.59234403247094,
                                   -0.018377879348242, 0.174214412813761, 0.0779182667327594, "x1",
                                   0.112759784761359, "x3", 0.0491315895805092, 1.58590974560428,
                                   0.00202079123204174, 0.0593563876703967, 0.0306885894512192,
                                   "x1", 0.0358943944804584, "y1", 0.014626696431825, 2.09812171834281),
                      "Regressions parameter table")
  expect_equal_tables(partot, list(0.26348889641759, 0.446867412394827, 0.355178154406208, "x2 <unicode> x1",
                                   3.13082892944294e-14, 0.0467810932812294, 7.59234403247094,
                                   -0.018377879348242, 0.174214412813761, 0.0779182667327594, "x3 <unicode> x1",
                                   0.112759784761359, 0.0491315895805092, 1.58590974560428, 0.00202079123204174,
                                   0.0593563876703967, 0.0306885894512192, "y1 <unicode> x1", 0.0358943944804584,
                                   0.014626696431825, 2.09812171834281),
                      "Total effects table")
  expect_equal_tables(parvar, list(0.0662130628477228, 0.128548647454031, "x1", 0.0973808551508767,
                                   "", "x1", 9.14129882900738e-10, 0.0159022270557018, 6.12372435695796,
                                   2.25167664969695, 2.25167664969695, "x2", 2.25167664969695,
                                   "", "x2", "", 0, "", 1.94967853807201, 1.94967853807201, "x3",
                                   1.94967853807201, "", "x3", "", 0, "", 6.78685155555555, 6.78685155555555,
                                   "y1", 6.78685155555555, "", "y1", "", 0, ""))
})


# Reliability, AVE, HTMT works
options <- jaspTools::analysisOptions("SEM")
options$models <- list(list(name = "Model1", syntax = list(model = "
# latent variable definitions
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3 + y4
  dem65 =~ y5 + y6 + y7 + y8
# regressions
  dem60 ~ ind60
  dem65 ~ ind60 + dem60
# residual (co)variances
  y1 ~~ y5
  y2 ~~ y4 + y6
  y3 ~~ y7
  y4 ~~ y8
  y6 ~~ y8
", columns = c("x1", "x2", "x3", "y1", "y2", "y3", "y4", "y5", "y6", "y7", "y8"))))
options$emulation         <- "lavaan"
options$estimator         <- "default"
options$group             <- ""
options$samplingWeights   <- ""
options$informationMatrix <- "expected"
options$naAction          <- "fiml"
options$modelTest         <- "standard"
options$reliability       <- TRUE
options$ave               <- TRUE
options$htmt              <- TRUE
results <- jaspTools::runAnalysis("SEM", "poldem_grouped.csv", options)


container   <- results[["results"]][["modelContainer"]][["collection"]]
ave         <- container[["modelContainer_AVE"]][["data"]]
htmt        <- container[["modelContainer_htmt"]][["collection"]][["modelContainer_htmt_htmttab"]][["data"]]
reliability <- container[["modelContainer_reliability"]][["data"]]

test_that("reliability/ AVE/ htmt works", {
  expect_equal_tables(ave, list(0.8588015398276, "ind60", 0.597128239158634, "dem60", 0.640021072526866,
                                   "dem65"))
  expect_equal_tables(htmt, list("", "", 1, 1, "", 0.420934414880351, 0.980709420149052, 1, 0.549916280338394
  ))
  expect_equal_tables(reliability, list("ind60", 0.902334680203148, 0.943690008441057, "dem60", 0.858794528217608,
                                   0.841179471771507, "dem65", 0.882739385479519, 0.857553923970666,
                                   "total", 0.91494164193877, 0.919205517992938))
})



test_that("Multigroup, multimodel SEM works", {
  options <- jaspTools::analysisOptions("SEM")
  options$emulation                   = "lavaan"
  options$estimator                   = "default"
  options$group                       = "group"
  options$informationMatrix           = "expected"
  options$meanStructure               = TRUE
  options$modificationIndexLowHidden  = TRUE
  options$naAction                    = "listwise"
  options$impliedCovariance           = TRUE
  options$mardiasCoefficient          = TRUE
  options$modificationIndex           = TRUE
  options$observedCovariance          = TRUE
  options$pathPlot                    = TRUE
  options$rSquared                    = TRUE
  options$residualCovariance          = TRUE
  options$standardizedResidual        = TRUE
  options$pathPlotParameter           = TRUE
  options$standardizedEstimate        = TRUE
  options$latentInterceptFixedToZero <- TRUE
  options$modelTest                   = "satorraBentler"
  options$samplingWeights             = ""

  modelDefault <- list(model = "
  # latent variable definitions
    ind60 =~ x1 + x2 + x3
    dem60 =~ y1 + y2 + y3 + y4
    dem65 =~ y5 + y6 + y7 + y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual (co)variances
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
  ", columns = c("x1", "x2", "x3", "y1", "y2", "y3", "y4", "y5", "y6", "y7", "y8"))
  modelConstrained <- list(model = "
  # latent variable definitions
    ind60 =~ x1 + x2 + x3
    dem60 =~ c(a1,a2)*y1 + c(b1,b2)*y2 + c(c1,c2)*y3 + c(d1,d2)*y4
    dem65 =~ c(a1,a3)*y5 + c(b1,b3)*y6 + c(c1,c3)*y7 + c(d1,d3)*y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual (co)variances
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
  ", columns = c("x1", "x2", "x3", "y1", "y2", "y3", "y4", "y5", "y6", "y7", "y8"))
  modelMoreConstrained <- list(model = "
  # latent variable definitions
    ind60 =~ x1 + x2 + x3
    dem60 =~ c(a1, a2)*y1 + c(b1, b2)*y2 + c(c1, c2)*y3 + c(d1, d2)*y4
    dem65 =~ c(a1, a2)*y5 + c(b1, b2)*y6 + c(c1, c2)*y7 + c(d1, d2)*y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual (co)variances
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
  ", columns = c("x1", "x2", "x3", "y1", "y2", "y3", "y4", "y5", "y6", "y7", "y8"))

  options$models = list(
    list(name = "default",          syntax = modelDefault),
    list(name = "constrained",      syntax = modelConstrained),
    list(name = "more constrained", syntax = modelMoreConstrained)
  )

  results <- jaspTools::runAnalysis("SEM", "poldem_grouped.csv", options)

  fittab   <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fittab"]][["data"]]
  expect_equal_tables(fittab, list(3189.26691715402, 3383.93591869107, 85.6796813843018, 70, "default",
                                   75, 0.0980338951401478, "", "", "", 3184.34803034567, 3372.06456754211,
                                   87.9549367720082, 73, "constrained", 75, 0.111927575441416, 0.647754490401111,
                                   1.65156784895969, 3, 3181.07183366569, 3361.83590652152, 92.7433708195334,
                                   76, "more constrained", 75, 0.0929761753674234, 0.110596895607335,
                                   6.02091896557529, 3), "Model fit table")


  rsquared <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_rsquared"]][["data"]]
  expect_equal_tables(rsquared, list(1, "x1", 0.883076871616545, 0.88344099961725, 0.883440941017356,
                                     1, "x2", 0.993698159869737, 0.993307380054294, 0.993308312239008,
                                     1, "x3", 0.734550879193546, 0.734754000085834, 0.734752992615769,
                                     1, "y1", 0.76374604003533, 0.783825225382152, 0.783824495338428,
                                     1, "y2", 0.526988232837519, 0.469805811235219, 0.469797871843766,
                                     1, "y3", 0.540743668690899, 0.602813004892641, 0.602813008520997,
                                     1, "y4", 0.758371834315633, 0.715732725592277, 0.715727580943472,
                                     1, "y5", 0.74873567690424, 0.760689523184987, 0.760685788176897,
                                     1, "y6", 0.626089440009365, 0.636528021958327, 0.636530171924641,
                                     1, "y7", 0.729758226751308, 0.710375682244039, 0.71037601689489,
                                     1, "y8", 0.574575906571731, 0.588831799668115, 0.588835817501729,
                                     1, "dem60", 0.275927380324134, 0.258157185403394, 0.258145005894915,
                                     1, "dem65", 0.941713333219213, 0.938883931908498, 0.938882940520396,
                                     2, "x1", 0.787475869571125, 0.78747617521673, 0.788439850883342,
                                     2, "x2", 0.90066092940223, 0.900660946749863, 0.900202685338541,
                                     2, "x3", 0.749867733548725, 0.749868295135393, 0.749372699570588,
                                     2, "y1", 0.731921944773149, 0.731929437708713, 0.683849857838249,
                                     2, "y2", 0.550065444500199, 0.55006739915162, 0.519184271086883,
                                     2, "y3", 0.465824888188388, 0.465819890503162, 0.543696244446076,
                                     2, "y4", 0.651968126202522, 0.651959003998254, 0.694898810552775,
                                     2, "y5", 0.536001769615456, 0.535995620432757, 0.598318029638657,
                                     2, "y6", 0.625808175301569, 0.625823134164411, 0.607599332020539,
                                     2, "y7", 0.658946836103404, 0.658945492261667, 0.618117097165422,
                                     2, "y8", 0.842442637402788, 0.842449295416932, 0.821972120799197,
                                     2, "dem60", 0.0753599955960172, 0.0753581296999281, 0.0905522598180797,
                                     2, "dem65", 0.956917027167473, 0.956910675588687, 0.977886505597527), "R-squared table")

  mardia   <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_mardiasTable"]][["data"]]
  expect_equal_tables(mardia, list(330.8978096739, 26.471824773912, 286, "Skewness", 0.0347860345067638,
                                   "", "", 134.567190822067, "", "Kurtosis", 0.0308358026617131,
                                   -2.15918518879414), "Mardia's coefficient table")

  # parameter tables (use only the most constrained one, model 3)
  parcont <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][[3]][["collection"]]

  parcov  <- parcont[["modelContainer_params_more constrained_cov"]][["data"]]
  parind  <- parcont[["modelContainer_params_more constrained_ind"]][["data"]]
  parlvar <- parcont[["modelContainer_params_more constrained_lvar"]][["data"]]
  parmu   <- parcont[["modelContainer_params_more constrained_mu"]][["data"]]
  parreg  <- parcont[["modelContainer_params_more constrained_reg"]][["data"]]
  parvar  <- parcont[["modelContainer_params_more constrained_var"]][["data"]]
  partoteff <- parcont[["modelContainer_params_more constrained_toteff"]][["data"]]
  parindeff <- parcont[["modelContainer_params_more constrained_indeff"]][["data"]]

  expect_equal_tables(parcov, list(-0.6954531542207, 1.13004177555805, 0.217294310668675, 1, "",
                                   "y1 - y5", 0.640785259230165, 0.465696039360422, 0.122229400273098,
                                   0.217294310668675, 0.122229400273098, 0.466601156769773, 0.433556460847837,
                                   4.21291697813377, 2.3232367194908, 1, "", "y2 - y4", 0.0159680098210626,
                                   0.964140297244501, 0.551561502186759, 2.3232367194908, 0.551561502186759,
                                   2.40964590540462, -0.453419237958842, 2.505951236881, 1.02626599946108,
                                   1, "", "y2 - y6", 0.17402837160491, 0.754955320144396, 0.193560311396125,
                                   1.02626599946108, 0.193560311396125, 1.35937316034119, -0.360831524130165,
                                   2.44595509715802, 1.04256178651393, 1, "", "y3 - y7", 0.145384170743897,
                                   0.716030152448658, 0.308401783418161, 1.04256178651393, 0.308401783418161,
                                   1.45603056372502, -1.1752514946784, 0.804530353606003, -0.185360570536198,
                                   1, "", "y4 - y8", 0.713611427442158, 0.505055670384933, -0.055456132680955,
                                   -0.185360570536198, -0.055456132680955, -0.367010176115681,
                                   -0.214945884704212, 3.12165697220468, 1.45335554375024, 1, "",
                                   "y6 - y8", 0.0877403085916073, 0.851189839004082, 0.345429944587142,
                                   1.45335554375024, 0.345429944587142, 1.70743995892938, -0.118867422075107,
                                   1.57858876509683, 0.729860671510864, 2, "", "y1 - y5", 0.0918990888281448,
                                   0.433032494617569, 0.378922580175638, 0.729860671510864, 0.378922580175638,
                                   1.68546397922271, -0.465368071384461, 3.32132373684828, 1.42797783273191,
                                   2, "", "y2 - y4", 0.139348430266928, 0.966010558893349, 0.272324473644576,
                                   1.42797783273191, 0.272324473644576, 1.47822176433329, 0.0620106319581817,
                                   4.11438168212343, 2.0881961570408, 2, "", "y2 - y6", 0.0433887887248896,
                                   1.0337871211231, 0.353104277180419, 2.0881961570408, 0.353104277180419,
                                   2.01994793161304, -1.37202057656756, 2.36286703932311, 0.495423231377773,
                                   2, "", "y3 - y7", 0.603085629226917, 0.95279496086433, 0.102496109909358,
                                   0.495423231377773, 0.102496109909358, 0.519968358069766, -0.467325344619643,
                                   1.95619519341019, 0.744434924395273, 2, "", "y4 - y8", 0.228555681753865,
                                   0.618256395818049, 0.289753166031978, 0.744434924395273, 0.289753166031978,
                                   1.20408770443898, -0.397060222176712, 2.20355649897539, 0.903248138399338,
                                   2, "", "y6 - y8", 0.173364480031275, 0.663434823717536, 0.311727419658627,
                                   0.903248138399338, 0.311727419658627, 1.3614723046011), "Covariance parameter table")
  expect_equal_tables(parind, list(1, 1, 1, 1, "a1", "dem60", "", "y1", 0, 0.885338633144645, 2.42166834175017,
                                   0.885338633144645, "", 0.760887096093346, 1.33133716576763,
                                   1.04611213093049, 1, "b1", "dem60", 6.55031584528842e-13, "y2",
                                   0.145525651025714, 0.685418027078195, 2.53333662939518, 0.685418027078195,
                                   7.18850679283783, 0.783222538721785, 1.29591955303148, 1.03957104587663,
                                   1, "c1", "dem60", 1.99840144432528e-15, "y3", 0.130792458012948,
                                   0.776410335145661, 2.51749629079955, 0.776410335145661, 7.94824917025196,
                                   0.796321916480285, 1.25466669817794, 1.02549430732911, 1, "d1",
                                   "dem60", 0, "y4", 0.116926837766668, 0.846006844501551, 2.48340709870393,
                                   0.846006844501551, 8.77039289624442, 1, 1, 1, 1, "a1", "dem65",
                                   "", "y5", 0, 0.872173026513029, 2.49219827699714, 0.872173026513029,
                                   "", 0.760887096093347, 1.33133716576763, 1.04611213093049, 1,
                                   "b1", "dem65", 6.55031584528842e-13, "y6", 0.145525651025714,
                                   0.797828410076152, 2.60711885025078, 0.797828410076152, 7.18850679283783,
                                   0.783222538721786, 1.29591955303148, 1.03957104587663, 1, "c1",
                                   "dem65", 1.99840144432528e-15, "y7", 0.130792458012948, 0.842838072760652,
                                   2.59081716934986, 0.842838072760652, 7.94824917025198, 0.796321916480285,
                                   1.25466669817794, 1.02549430732911, 1, "d1", "dem65", 0, "y8",
                                   0.116926837766668, 0.767356382329443, 2.55573514579599, 0.767356382329443,
                                   8.77039289624441, 1, 1, 1, 1, "", "ind60", "", "x1", 0, 0.9399153903503,
                                   0.657997769223687, 0.9399153903503, "", 1.94762156768515, 2.55197241207641,
                                   2.24979698988078, 1, "", "ind60", 0, "x2", 0.154173966756102,
                                   0.996648539977362, 1.48036140054772, 0.996648539977362, 14.5925867850302,
                                   1.40827986384489, 2.23529739101974, 1.82178862743232, 1, "",
                                   "ind60", 0, "x3", 0.21097773573858, 0.857177340236995, 1.19873285284755,
                                   0.857177340236995, 8.63498046869587, 1, 1, 1, 2, "a2", "dem60",
                                   "", "y1", 0, 0.826952149666623, 1.88731847029611, 0.826952149666623,
                                   "", 1.00619302224548, 1.96819575821973, 1.4871943902326, 2,
                                   "b2", "dem60", 1.3615824023816e-09, "y2", 0.245413370746198,
                                   0.720544426865466, 2.80680944160676, 0.720544426865466, 6.05995665888404,
                                   0.971906075502799, 1.81486423470296, 1.39338515510288, 2, "c2",
                                   "dem60", 9.20110654334394e-11, "y3", 0.215044298224178, 0.737357609607493,
                                   2.62976153946208, 0.737357609607493, 6.47952615628205, 1.13497135653258,
                                   1.96970928417875, 1.55234032035566, 2, "d2", "dem60", 3.10418357685194e-13,
                                   "y4", 0.212947261845238, 0.833605908420025, 2.92976055879263,
                                   0.833605908420025, 7.28978765401475, 1, 1, 1, 2, "a2", "dem65",
                                   "", "y5", 0, 0.773510200087017, 1.83190459395535, 0.773510200087017,
                                   "", 1.00619302224548, 1.96819575821973, 1.4871943902326, 2,
                                   "b2", "dem65", 1.3615824023816e-09, "y6", 0.245413370746198,
                                   0.779486582322325, 2.72439823557173, 0.779486582322325, 6.05995665888404,
                                   0.971906075502799, 1.81486423470296, 1.39338515510288, 2, "c2",
                                   "dem65", 9.20110654334394e-11, "y7", 0.215044298224178, 0.786204233749362,
                                   2.55254866678216, 0.786204233749362, 6.47952615628205, 1.13497135653258,
                                   1.96970928417875, 1.55234032035566, 2, "d2", "dem65", 3.10418357685194e-13,
                                   "y8", 0.212947261845238, 0.906626781426181, 2.84373936424167,
                                   0.906626781426181, 7.28978765401476, 1, 1, 1, 2, "", "ind60",
                                   "", "x1", 0, 0.887941355542888, 0.569877660945511, 0.887941355542888,
                                   "", 1.83150200846409, 2.88878207416714, 2.36014204131561, 2,
                                   "", "ind60", 0, "x2", 0.269719258629941, 0.948790116589829,
                                   1.34499222600411, 0.948790116589829, 8.75036529947522, 1.44864109706262,
                                   2.4658864657564, 1.95726378140951, 2, "", "ind60", 4.61852778244065e-14,
                                   "x3", 0.259506138050923, 0.865663155950736, 1.11540090560302,
                                   0.865663155950736, 7.54226391757035), "Loadings parameter table")
  expect_equal_tables(parlvar, list(0.209581796157056, 0.656340332449642, "ind60", 0.432961064303349,
                                    1, "", "ind60", 0.000145359164061443, 0.113971108606219, 1,
                                    1, 1, 3.79886683211329, 1.81562506860136, 6.88555885899937,
                                    "dem60", 4.35059196380036, 1, "", "dem60", 0.000768902080227507,
                                    1.29337422278904, 0.741854994105085, 0.741854994105085, 0.741854994105085,
                                    3.3637534188819, -0.373266498808562, 1.1324689986252, "dem65",
                                    0.379601249908318, 1, "", "dem65", 0.323041135527759, 0.384123256679921,
                                    0.0611170594796042, 0.0611170594796042, 0.0611170594796042,
                                    0.988227719376618, 0.139438652248914, 0.51008244464054, "ind60",
                                    0.324760548444727, 2, "", "ind60", 0.000593282653738703, 0.0945537253018976,
                                    1, 1, 1, 3.43466687756415, 1.1885891662882, 5.29026380193365,
                                    "dem60", 3.23942648411092, 2, "", "dem60", 0.00196225561471564,
                                    1.04636479751642, 0.90944774018192, 0.90944774018192, 0.90944774018192,
                                    3.09588634078651, -0.343713422100036, 0.492133643448633, "dem65",
                                    0.0742101106742985, 2, "", "dem65", 0.727819060322371, 0.213230210386957,
                                    0.0221134944024726, 0.0221134944024726, 0.0221134944024726,
                                    0.348028126688176), "Latent variance parameter table")
  expect_equal_tables(parmu, list(5.114583249089, 5.56572485901911, 5.34015405405405, 1, "", "x1",
                                  0, 0.115089260182496, 7.62813069741675, 5.34015405405405, 7.62813069741675,
                                  46.4001075824643, 4.69962810017044, 5.65682865658632, 5.17822837837838,
                                  1, "", "x2", 0, 0.244188302429574, 3.48622556023865, 5.17822837837838,
                                  3.48622556023865, 21.2058822099876, 3.4912357243792, 4.39245184318836,
                                  3.94184378378378, 1, "", "x3", 0, 0.229906295706921, 2.81869239020784,
                                  3.94184378378378, 2.81869239020784, 17.145436455593, 5.0659390403021,
                                  6.8286555542925, 5.9472972972973, 1, "", "y1", 0, 0.449680843090609,
                                  2.17427463923019, 5.9472972972973, 2.17427463923019, 13.2255963060871,
                                  2.8433068923923, 5.22515797247257, 4.03423243243243, 1, "",
                                  "y2", 3.1510793974121e-11, 0.607626236723739, 1.09149948827483,
                                  4.03423243243243, 1.09149948827483, 6.6393321891178, 5.71017508116214,
                                  7.79973464856759, 6.75495486486486, 1, "", "y3", 0, 0.533060705167961,
                                  2.08326693059709, 6.75495486486486, 2.08326693059709, 12.6720180260454,
                                  4.36666487548144, 6.25836052992396, 5.3125127027027, 1, "",
                                  "y4", 0, 0.482584289651232, 1.80978064785815, 5.3125127027027,
                                  1.80978064785815, 11.0084659128504, 4.76881059441114, 6.61024886504832,
                                  5.68952972972973, 1, "", "y5", 0, 0.469763292887578, 1.99111539784598,
                                  5.68952972972973, 1.99111539784598, 12.1114821355174, 1.69721605838774,
                                  3.80307150917983, 2.75014378378378, 1, "", "y6", 3.0678012175045e-07,
                                  0.537217894666127, 0.841596785005017, 2.75014378378378, 0.841596785005017,
                                  5.11923338944798, 5.40096255495839, 7.38189582341999, 6.39142918918919,
                                  1, "", "y7", 0, 0.505349405419424, 2.07924353896195, 6.39142918918919,
                                  2.07924353896195, 12.6475446901625, 3.28677224232016, 5.43309959551768,
                                  4.35993591891892, 1, "", "y8", 1.77635683940025e-15, 0.547542549283426,
                                  1.30906547943089, 4.35993591891892, 1.30906547943089, 7.96273444798913,
                                  0, 0, 0, 1, "", "ind60", "", 0, 0, 0, 0, "", 0, 0, 0, 1, "",
                                  "dem60", "", 0, 0, 0, 0, "", 0, 0, 0, 1, "", "dem65", "", 0,
                                  0, 0, 0, "", 4.57207725542129, 4.9801932708945, 4.77613526315789,
                                  2, "", "x1", 0, 0.10411314154045, 7.44182183380953, 4.77613526315789,
                                  7.44182183380953, 45.8744707199359, 3.96560094944749, 4.86703905055251,
                                  4.41632, 2, "", "x2", 0, 0.229962924884195, 3.11537917222519,
                                  4.41632, 3.11537917222519, 19.204486993823, 2.77397157389089,
                                  3.59331947874069, 3.18364552631579, 2, "", "x3", 0, 0.209021163478693,
                                  2.47082875753002, 3.18364552631579, 2.47082875753002, 15.2312113918566,
                                  4.2690970296885, 5.72037665452202, 4.99473684210526, 2, "",
                                  "y1", 0, 0.370231197175312, 2.18850630331085, 4.99473684210526,
                                  2.18850630331085, 13.4908589017153, 3.23427002973344, 5.71134102289814,
                                  4.47280552631579, 2, "", "y2", 1.46083145580178e-12, 0.631917477235172,
                                  1.14822725286081, 4.47280552631579, 1.14822725286081, 7.07814815612578,
                                  5.24236503773425, 7.51026812016048, 6.37631657894737, 2, "",
                                  "y3", 0, 0.578557335827383, 1.787852426998, 6.37631657894737,
                                  1.787852426998, 11.0210625362286, 2.49773616542863, 4.73263378193979,
                                  3.61518497368421, 2, "", "y4", 2.28425278692157e-10, 0.570137419396414,
                                  1.02862998310564, 3.61518497368421, 1.02862998310564, 6.3409010717302,
                                  3.84453746449672, 5.35053095655592, 4.59753421052632, 2, "",
                                  "y5", 0, 0.384189072844778, 1.94127992190503, 4.59753421052632,
                                  1.94127992190503, 11.9668531342739, 2.0887392465132, 4.31127233243417,
                                  3.20000578947368, 2, "", "y6", 1.66224263242753e-08, 0.566983144448578,
                                  0.915564231278779, 3.20000578947368, 0.915564231278779, 5.64391696791245,
                                  4.97396373438834, 7.03851152876955, 6.00623763157895, 2, "",
                                  "y7", 0, 0.526680033578704, 1.84996647323673, 6.00623763157895,
                                  1.84996647323673, 11.4039592326437, 2.73789322525061, 4.73245519580203,
                                  3.73517421052632, 2, "", "y8", 2.1227464230833e-13, 0.508826179022745,
                                  1.19082958696484, 3.73517421052632, 1.19082958696484, 7.34076658103582,
                                  0, 0, 0, 2, "", "ind60", "", 0, 0, 0, 0, "", 0, 0, 0, 2, "",
                                  "dem60", "", 0, 0, 0, 0, "", 0, 0, 0, 2, "", "dem65", "", 0,
                                  0, 0, 0, ""), "Means parameter table")
  expect_equal_tables(parreg, list(0.721100887386564, 3.01873119149832, 1.86991603944244, 1, "dem60",
                                   0.00142166660030174, "ind60", 0.586140950097851, 0.508079723955714,
                                   0.508079723955714, 0.508079723955714, 3.19021566251304, 0.478026990501928,
                                   1.96570674995725, 1.22186687022959, 1, "dem65", 0.00128400773281667,
                                   "ind60", 0.379517116434269, 0.322601007439955, 0.322601007439955,
                                   0.322601007439955, 3.21953033820864, 0.572218807581072, 1.00102151163503,
                                   0.78662015960805, 1, "dem65", 6.43485265072741e-13, "dem60",
                                   0.109390454987004, 0.764358580570299, 0.764358580570299, 0.764358580570299,
                                   7.19093964552485, -0.154169499851477, 2.14733425618112, 0.99658237816482,
                                   2, "dem60", 0.0896244560523969, "ind60", 0.587129093745232,
                                   0.300919025350807, 0.300919025350807, 0.300919025350807, 1.69738203877401,
                                   -0.115343312911686, 0.965518339191284, 0.425087513139799, 2,
                                   "dem65", 0.12315820352967, "ind60", 0.275735079988375, 0.132238260925043,
                                   0.132238260925043, 0.132238260925043, 1.54165191152943, 0.730849486044932,
                                   1.09592060871138, 0.913385047378158, 2, "dem65", 0, "dem60",
                                   0.0931320997595074, 0.941014327982574, 0.941014327982574, 0.941014327982574,
                                   9.80741387488061), "Regressions parameter table")
  expect_equal_tables(parvar, list(0.019971862523661, 0.0942758067618645, "x1", 0.0571238346427628,
                                   1, "", "x1", 0.00258179957955118, 0.0189554361264553, 0.116559058982644,
                                   0.0571238346427628, 0.116559058982644, 3.01358587909447, -0.119066895021194,
                                   0.148593743772327, "x2", 0.0147634243755663, 1, "", "x2", 0.828822156218558,
                                   0.0682820299007519, 0.00669168776099212, 0.0147634243755663,
                                   0.00669168776099212, 0.216212441209275, 0.265760017116629, 0.77173003351152,
                                   "x3", 0.518745025314075, 1, "", "x3", 5.84703635451156e-05,
                                   0.129076355582531, 0.265247007384231, 0.518745025314075, 0.265247007384231,
                                   4.01890046378318, 0.416929012723307, 2.81786755996509, "y1",
                                   1.6173982863442, 1, "", "y1", 0.00827424337847726, 0.612495578025943,
                                   0.216175504661572, 1.6173982863442, 0.216175504661572, 2.64066932786197,
                                   3.64229436414009, 10.8436303032633, "y2", 7.24296233370169,
                                   1, "", "y2", 8.06075272521412e-05, 1.8371092519879, 0.530202128156234,
                                   7.24296233370169, 0.530202128156234, 3.94258660766322, 1.93231536174354,
                                   6.41948442904567, "y3", 4.17589989539461, 1, "", "y3", 0.000264281837194513,
                                   1.1447070208168, 0.397186991479003, 4.17589989539461, 0.397186991479003,
                                   3.64800758574445, 0.931737730528367, 3.96732278343115, "y4",
                                   2.44953025697976, 1, "", "y4", 0.00156076961142304, 0.774398171815168,
                                   0.284272419056528, 2.44953025697976, 0.284272419056528, 3.16314054724345,
                                   0.731947613472583, 3.17608668229141, "y5", 1.95401714788199,
                                   1, "", "y5", 0.00172519104089064, 0.623516321753329, 0.239314211823103,
                                   1.95401714788199, 0.239314211823103, 3.13386687679209, 1.83678103920313,
                                   5.92570847199455, "y6", 3.88124475559884, 1, "", "y6", 0.000198569846390217,
                                   1.04311290029928, 0.363469828075359, 3.88124475559884, 0.363469828075359,
                                   3.72082902482106, 1.19521510119136, 4.2780912840873, "y7", 2.73665319263933,
                                   1, "", "y7", 0.000501976062955434, 0.786462457273012, 0.28962398310511,
                                   2.73665319263933, 0.28962398310511, 3.47969972035084, 2.19176630693849,
                                   6.93007982455653, "y8", 4.56092306574751, 1, "", "y8", 0.000161182628549028,
                                   1.20877565990836, 0.411164182498271, 4.56092306574751, 0.411164182498271,
                                   3.7731757984714, 0.0313581547372507, 0.142926262721349, "x1",
                                   0.0871422087292997, 2, "", "x1", 0.00220063448354591, 0.0284617750285549,
                                   0.211560149116658, 0.0871422087292997, 0.211560149116658, 3.06172783116557,
                                   -0.0362625145249454, 0.437358296920339, "x2", 0.200547891197697,
                                   2, "", "x2", 0.0969472731768826, 0.120823855739479, 0.0997973146614593,
                                   0.200547891197697, 0.0997973146614593, 1.65983687551007, 0.174335809406066,
                                   0.65785418558488, "x3", 0.416094997495473, 2, "", "x3", 0.000742674694836687,
                                   0.123348791098394, 0.250627300429412, 0.416094997495473, 0.250627300429412,
                                   3.37332043378973, 0.67728943233645, 2.61617514252359, "y1",
                                   1.64673228743002, 2, "", "y1", 0.000870742833376514, 0.494622790388198,
                                   0.316150142161751, 1.64673228743002, 0.316150142161751, 3.32926892862662,
                                   3.61992130179251, 10.9720172659021, "y2", 7.29596928384731,
                                   2, "", "y2", 0.000100243055731752, 1.87556914874508, 0.480815728913117,
                                   7.29596928384731, 0.480815728913117, 3.89000282326511, 2.80111563779673,
                                   8.80696575715111, "y3", 5.80404069747392, 2, "", "y3", 0.000151736573070549,
                                   1.53213277558357, 0.456303755553924, 5.80404069747392, 0.456303755553924,
                                   3.78820999718072, 1.47037447709196, 6.06693911089053, "y4",
                                   3.76865679399125, 2, "", "y4", 0.00130948831028421, 1.17261456589399,
                                   0.305101189447225, 3.76865679399125, 0.305101189447225, 3.21389218896327,
                                   1.06639719058268, 3.43954844740097, "y5", 2.25297281899183,
                                   2, "", "y5", 0.000198106085773642, 0.605406853273174, 0.401681970361344,
                                   2.25297281899183, 0.401681970361344, 3.72141941705974, 2.22486686951239,
                                   7.36215298126356, "y6", 4.79350992538798, 2, "", "y6", 0.00025457326577949,
                                   1.31055625314379, 0.392400667979461, 4.79350992538798, 0.392400667979461,
                                   3.65761478295129, 1.87928674169851, 6.1714850562742, "y7", 4.02538589898636,
                                   2, "", "y7", 0.000236681377467019, 1.09496866994292, 0.381882902834578,
                                   4.02538589898636, 0.381882902834578, 3.67625669070166, 0.346950686712466,
                                   3.15605228468781, "y8", 1.75150148570014, 2, "", "y8", 0.0145209073086436,
                                   0.716620718577785, 0.178027879200803, 1.75150148570014, 0.178027879200803,
                                   2.44411226230828), "(Residual) variances parameter table")
  expect_equal_tables(partoteff, list(1.63130176674587, 3.75425928051304, 2.69278052362946, 1, " ind60 <unicode> dem65",
                                      6.62397930284442e-07, 0.541580746001658, 0.710956104059294,
                                      0.710956104059294, 0.710956104059294, 4.97207580496447, 0.721100887386564,
                                      3.01873119149832, 1.86991603944244, 1, " ind60 <unicode> dem60",
                                      0.00142166660030174, 0.586140950097851, 0.508079723955714, 0.508079723955714,
                                      0.508079723955714, 3.19021566251304, 0.572218807581072, 1.00102151163503,
                                      0.78662015960805, 1, " dem60 <unicode> dem65", 6.43485265072741e-13,
                                      0.109390454987004, 0.764358580570299, 0.764358580570299, 0.764358580570299,
                                      7.19093964552485, 0.247077278790176, 2.42362463288204, 1.33535095583611,
                                      2, " ind60 <unicode> dem65", 0.0161748412862954, 0.55525187484571,
                                      0.415407375342704, 0.415407375342704, 0.415407375342704, 2.40494632495778,
                                      -0.154169499851477, 2.14733425618112, 0.99658237816482, 2, " ind60 <unicode> dem60",
                                      0.0896244560523969, 0.587129093745232, 0.300919025350807, 0.300919025350807,
                                      0.300919025350807, 1.69738203877401, 0.730849486044932, 1.09592060871138,
                                      0.913385047378158, 2, " dem60 <unicode> dem65", 0, 0.0931320997595074,
                                      0.941014327982574, 0.941014327982574, 0.941014327982574, 9.80741387488061), "Total effects table")
  expect_equal_tables(parindeff, list(0.481357882787227, 2.46046942401251, 1.47091365339987, 1, "ind60 <unicode> dem60 <unicode> dem65",
                                      0.00357555663622788, 0.504884670544015, 0.388355096619339, 0.388355096619339,
                                      0.388355096619339, 2.91336564410829, -0.159005756965501, 1.97953264235812,
                                      0.910263442696311, 2, "ind60 <unicode> dem60 <unicode> dem65",
                                      0.0952150456736578, 0.545555534742511, 0.283169114417661, 0.283169114417661,
                                      0.283169114417661, 1.66850739242511), "Indirect effects table")

  # covariance tables. Use model 2, but the way this is ordered uses actually the default model
  covcont  <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_covars"]][["collection"]][[2]][["collection"]]
  covimp <- covcont[["modelContainer_covars_default_implied"]][["collection"]][["modelContainer_covars_default_implied_1"]][["data"]]
  covobs <- covcont[["modelContainer_covars_default_observed"]][["collection"]][["modelContainer_covars_default_observed_1"]][["data"]]
  covres <- covcont[["modelContainer_covars_default_residual"]][["collection"]][["modelContainer_covars_default_residual_1"]][["data"]]
  covstd <- covcont[["modelContainer_covars_default_stdres"]][["collection"]][["modelContainer_covars_default_stdres_1"]][["data"]]

  expect_equal_tables(covimp, list(0.49008300563634, "", "", "", "", "", "", "", "", "", "", 0.974061924820936,
                                   2.20622852804642, "", "", "", "", "", "", "", "", "", 0.788491080043323,
                                   1.77466015582184, 1.95570584174645, "", "", "", "", "", "",
                                   "", "", 0.835178540092752, 1.87973981648419, 1.5216261310825,
                                   7.64797977172544, "", "", "", "", "", "", "", 0.955666527250095,
                                   2.15092263069125, 1.74114526494313, 6.6837892939784, 14.5127221504755,
                                   "", "", "", "", "", "", 0.788253740427639, 1.77412597456093,
                                   1.43613303237535, 5.51292920802481, 6.30825824454682, 9.62227326013948,
                                   "", "", "", "", "", 0.904244744111686, 2.03518740934666, 1.647459034785,
                                   6.32415300473142, 9.23882105681506, 5.96882824654787, 9.02873362112345,
                                   "", "", "", "", 1.14334478995368, 2.57333087773904, 2.08307951619225,
                                   5.82366205597868, 6.32427984118539, 5.21639829184987, 5.98398776520799,
                                   7.98119516009606, "", "", "", 1.18710886159188, 2.6718308559361,
                                   2.16281403020389, 5.73848644656917, 7.58931007411123, 5.41606756969487,
                                   6.21303824196686, 6.20454284533332, 10.2893215377554, "", "",
                                   1.25970543427747, 2.83522426425121, 2.29507897323411, 6.0894184140595,
                                   6.96791532513603, 6.91162808862569, 6.59299099686961, 6.58397607191045,
                                   6.83599243915776, 9.9403352106315, "", 1.15531617741013, 2.60027492931625,
                                   2.10489039267504, 5.58480055205702, 6.39049819021453, 5.27101657115423,
                                   5.85298682041024, 6.03837521104465, 7.68811256412372, 6.65291356937697,
                                   10.6193105678442), "Model-implied covariance table")

  expect_equal_tables(covobs, list(0.490082575997078, "", "", "", "", "", "", "", "", "", "", 0.973932449184952,
                                   2.20622591129467, "", "", "", "", "", "", "", "", "", 0.78518275394412,
                                   1.77565205254938, 1.95570361423433, "", "", "", "", "", "",
                                   "", "", 0.842173686632578, 1.60646357669832, 1.14904644265887,
                                   7.62580350620891, "", "", "", "", "", "", "", 0.966640855417166,
                                   2.56661076528232, 2.30600417597728, 6.02486581738495, 14.676007521986,
                                   "", "", "", "", "", "", 0.569651258731629, 1.29778304025924,
                                   0.751981605089701, 6.44636651314828, 5.79397804058276, 9.73209047934931,
                                   "", "", "", "", "", 1.07850808055391, 2.50663181045844, 2.0195628491114,
                                   6.09461043973703, 9.30788611653126, 5.64475186161118, 9.01279131583053,
                                   "", "", "", "", 1.23810412812272, 2.61063748721578, 1.81722127066318,
                                   5.59878435062089, 6.6520705502466, 5.03859665459321, 6.05661431962235,
                                   7.93189524242966, "", "", "", 1.43792308816034, 2.91763544604397,
                                   2.84145873393433, 5.38621551022644, 8.42865402090701, 4.21966332811402,
                                   6.90922843998977, 6.08535469304967, 10.3746040258343, "", "",
                                   1.04665319855464, 2.45836864046895, 1.77472198140307, 6.2463340788897,
                                   7.67698969559927, 6.73419489425259, 7.01801387855084, 6.81611022694302,
                                   6.30443702471928, 9.78003437719124, "", 1.23565159843141, 2.65937421505933,
                                   1.72765599854139, 5.4174694403214, 7.39753077439182, 4.59181056574472,
                                   6.45111697395995, 5.63862367744565, 7.7210072538895, 6.57011319209561,
                                   10.545706988345), "Observed covariance table")

  expect_equal_tables(covres, list(-4.29639262000681e-07, "", "", "", "", "", "", "", "", "", "",
                                   -0.000129475635983867, -2.61675175305953e-06, "", "", "", "",
                                   "", "", "", "", "", -0.00330832609920362, 0.000991896727542851,
                                   -2.22751211431671e-06, "", "", "", "", "", "", "", "", 0.00699514653982602,
                                   -0.273276239785871, -0.372579688423628, -0.0221762655165261,
                                   "", "", "", "", "", "", "", 0.0109743281670703, 0.415688134591076,
                                   0.56485891103415, -0.65892347659345, 0.163285371510497, "",
                                   "", "", "", "", "", -0.21860248169601, -0.476342934301688, -0.684151427285647,
                                   0.933437305123476, -0.514280203964063, 0.109817219209827, "",
                                   "", "", "", "", 0.174263336442222, 0.471444401111776, 0.372103814326393,
                                   -0.229542564994383, 0.0690650597162001, -0.324076384936694,
                                   -0.0159423052929153, "", "", "", "", 0.094759338169033, 0.0373066094767367,
                                   -0.265858245529067, -0.224877705357793, 0.327790709061214, -0.177801637256668,
                                   0.0726265544143621, -0.0492999176663993, "", "", "", 0.250814226568454,
                                   0.245804590107875, 0.678644703730438, -0.352270936342729, 0.839343946795778,
                                   -1.19640424158084, 0.696190198022915, -0.119188152283651, 0.0852824880789491,
                                   "", "", -0.213052235722835, -0.376855623782256, -0.52035699183104,
                                   0.156915664830205, 0.709074370463244, -0.177433194373092, 0.425022881681233,
                                   0.232134155032578, -0.531555414438472, -0.160300833440264, "",
                                   0.0803354210212817, 0.0590992857430783, -0.377234394133652,
                                   -0.167331111735621, 1.00703258417729, -0.679206005409508, 0.598130153549711,
                                   -0.399751533598995, 0.0328946897657785, -0.0828003772813588,
                                   -0.073603579499208), "Residual covariance table")

  jaspTools::expect_equal_tables(covstd,
                                 list(-4.29639261390058e-07, "", "", "", "", "", "", "", "", "", "",
                                      -0.906062050868875, -2.61675175172726e-06, "", "", "", "", "",
                                      "", "", "", "", -0.38600980945636, 1.26765266847845, -2.22751211365058e-06,
                                      "", "", "", "", "", "", "", "", 0.0846242017037755, -1.78626926801858,
                                      -1.50899731338318, -0.979353662950849, "", "", "", "", "", "",
                                      "", 0.0462187188848366, 0.915104116857723, 1.26724625016898,
                                      -3.10613908775842, 1.19239959132546, "", "", "", "", "", "",
                                      -1.56053141398542, -1.98571672118215, -1.95273558316733, 3.48139850416601,
                                      -0.952297065273875, 1.24738002520415, "", "", "", "", "", 1.70227576368358,
                                      2.48446501830506, 1.72887724327013, -2.99331507437673, 0.771585871131651,
                                      -1.33482628389656, -0.761717885855758, "", "", "", "", 1.47327037945452,
                                      0.272709782087463, -1.29757118956179, -2.40643758666971, 0.874896574845907,
                                      -0.503887231903551, 0.376035675353966, -2.1367412250306, "",
                                      "", "", 2.35212346611526, 1.25498978664384, 3.0336022528353,
                                      -1.19107613633585, 2.12597830042835, -2.99704518860994, 2.32847953539758,
                                      -0.590849981828543, 0.804440146444814, "", "", -2.69577565127516,
                                      -2.24649212532572, -1.71719477088287, 0.64413121241335, 1.49678459768851,
                                      -0.987168253316867, 1.96201526731966, 1.27341637632111, -2.11609347217146,
                                      -2.41207540474584, "", 0.623012707174373, 0.275105560993146,
                                      -1.61236921599306, -0.52937530261534, 1.44125542894765, -1.29066565900691,
                                      2.4993679036409, -2.1413979271183, 0.273074594418328, -0.249446746350577,
                                      -2.59387512655313), "Standardized residual covariance table")

})


# bootstrapping works
options <- jaspTools::analysisOptions("SEM")
options$models <- list(list(name = "Model1", syntax = list(model = "x1 ~ x2 + x3 + y1", columns = c("x1", "x2", "x3", "y1"))))
options$emulation         <- "lavaan"
options$estimator         <- "default"
options$group             <- ""
options$samplingWeights   <- ""
options$informationMatrix <- "expected"
options$naAction          <- "fiml"
options$modelTest         <- "standard"
options$errorCalculationMethod    <- "bootstrap"
options$bootstrapCiType   <- "percentile"
options$bootstrapSamples  <- 100

set.seed(1)
results <- jaspTools::runAnalysis("SEM", "poldem_grouped.csv", options)

# Model fit table results match
test_that("Bootstrapping model fit table works", {

  if (jaspBase::getOS() == "linux") skip("Skipped for now cause that part of the table is removed in another PR anyways")

  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fittab"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(48.1563554263444, 59.7437959940259, 0, 0, "Model1", 75, 1, "",
                                      0, 0),
                                 label = "Model fit table results match")
})


# Residual covariances table results match
test_that("Bootstrapping residual covariances work", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_cov"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(1.782009228184, 1.782009228184, 1.782009228184, "", "x2 - x3",
                                      "", 0, "", 1.2564136096, 1.2564136096, 1.2564136096, "", "x2 - y1",
                                      "", 0, "", 0.899301179999998, 0.899301179999998, 0.899301179999998,
                                      "", "x3 - y1", "", 0, ""),
                                 label = "Residual covariances table results match")
})


# Regression coefficients table results match
test_that("Bootstrapping regression coefficients work", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_reg"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(0.249609316197927, 0.447867152439518, 0.355178154406208, "x1",
                                      3.13082892944294e-14, "x2", 0.0467810932812294, 7.59234403247094,
                                      -0.0367153099343007, 0.19997796482335, 0.0779182667327594, "x1",
                                      0.112759784761359, "x3", 0.0491315895805092, 1.58590974560428,
                                      0.00301905711375345, 0.056769954444189, 0.0306885894512192,
                                      "x1", 0.0358943944804584, "y1", 0.014626696431825, 2.09812171834281
                                 ),
                                 label = "Regression coefficients table results match")
})


# Residual variances table results match
test_that("Bootstrapping residual variances work", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_var"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(0.0579281075433616, 0.121472727074924, "x1", 0.097380852992327,
                                      "", "x1", 9.14129882900738e-10, 0.0159022267032121, 6.12372435695794,
                                      2.25167664969695, 2.25167664969695, "x2", 2.25167664969695,
                                      "", "x2", "", 0, "", 1.94967853807201, 1.94967853807201, "x3",
                                      1.94967853807201, "", "x3", "", 0, "", 6.78685155555555, 6.78685155555555,
                                      "y1", 6.78685155555555, "", "y1", "", 0, ""),
                                 label = "Residual variances table results match")
})



test_that("t-size RMSEA and CFI match values of original article (Katerina M. Marcoulides & Ke-Hai Yuan (2017))", {
  options <- jaspTools::analysisOptions("SEM")
  options$sampleSize <- 600
  options$samplingWeights <- ""
  options$additionalFitMeasures <- TRUE
  options$informationMatrix <- "expected"
  options$estimator <- "default"
  options$modelTest <- "standard"
  options$naAction <- "ml"
  options$emulation <- "mplus"
  options$group <- ""
  options$dataType <- "varianceCovariance"
  options$models <- list(list(name = "Model1", syntax = list(model = "factor1 =~ V1 + V2 + V3 + V4 + V5 + V6 + V7\n factor2 =~ V8 + V9 + V10 + V11 + V12",
                                                                  columns = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", "V12"))))
  set.seed(1)
  dataset <- structure(list(V1 = c(1.321, 0.443, 0.283, 0.379, 0.462, 0.316, 0.392, 0.404, 0.398, 0.313, 0.374, 0.381),
                            V2 = c(0.443, 1.41, 0.507, 0.526, 0.466, 0.392, 0.404, 0.342, 0.493, 0.423, 0.448, 0.486),
                            V3 = c(0.283, 0.507, 1.485, 0.542, 0.411, 0.37, 0.352, 0.389, 0.437, 0.372, 0.359, 0.387),
                            V4 = c(0.379, 0.526, 0.542, 1.547, 0.527, 0.418, 0.481, 0.449, 0.45, 0.379, 0.368, 0.359),
                            V5 = c(0.462, 0.466, 0.411, 0.527, 1.524, 0.496, 0.478, 0.426, 0.447, 0.398, 0.348, 0.37),
                            V6 = c(0.316, 0.392, 0.37, 0.418, 0.496, 1.441, 0.387, 0.391, 0.48, 0.3, 0.404, 0.438),
                            V7 = c(0.392, 0.404, 0.352, 0.481, 0.478, 0.387, 1.422, 0.405, 0.412, 0.351, 0.335, 0.371),
                            V8 = c(0.404, 0.342, 0.389, 0.449, 0.426, 0.391, 0.405, 1.566, 0.657, 0.538, 0.591, 0.556),
                            V9 = c(0.398,0.493, 0.437, 0.45, 0.447, 0.48, 0.412, 0.657, 1.646, 0.599, 0.608, 0.69),
                            V10 = c(0.313, 0.423, 0.372, 0.379, 0.398, 0.3, 0.351, 0.538, 0.599, 1.675, 0.659, 0.529),
                            V11 = c(0.374, 0.448, 0.359, 0.368, 0.348, 0.404, 0.335, 0.591, 0.608, 0.659, 1.63, 0.64),
                            V12 = c(0.381, 0.486, 0.387, 0.359, 0.37, 0.438, 0.371, 0.556, 0.69, 0.529, 0.64, 1.673)),
                       class = "data.frame", row.names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", "V12"))
  results <- jaspTools::runAnalysis("SEM", dataset, options)

  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_addfit"]][["collection"]][["modelContainer_addfit_incrits"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list("Log-likelihood", -10988.8301074082, "Number of free parameters",
                                      25, "Akaike (AIC)", 22027.6602148165, "Bayesian (BIC)", 22137.5834561969,
                                      "Sample-size adjusted Bayesian (SSABIC)", 22058.2153051905))

  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_addfit"]][["collection"]][["modelContainer_addfit_indices"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list("Comparative Fit Index (CFI)", 0.996320596799055, "T-size CFI",
                                      0.974924004613834, "Tucker-Lewis Index (TLI)", 0.995418101674295,
                                      "Bentler-Bonett Non-normed Fit Index (NNFI)", 0.995418101674295,
                                      "Bentler-Bonett Normed Fit Index (NFI)", 0.961983689254605,
                                      "Parsimony Normed Fit Index (PNFI)", 0.772502053492334, "Bollen's Relative Fit Index (RFI)",
                                      0.952658933788753, "Bollen's Incremental Fit Index (IFI)", 0.996352840580171,
                                      "Relative Noncentrality Index (RNI)", 0.996320596799055))

  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_addfit"]][["collection"]][["modelContainer_addfit_others"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list("Root mean square error of approximation (RMSEA)", 0.0130437119173581,
                                      "RMSEA 90% CI lower bound", 0, "RMSEA 90% CI upper bound", 0.0297980428058939,
                                      "RMSEA p-value", 0.999994986450328, "T-size RMSEA", 0.029823208611982,
                                      "Standardized root mean square residual (SRMR)", 0.0253510370222869,
                                      "Hoelter's critical N (<unicode> = .05)", 730.254899918116,
                                      "Hoelter's critical N (<unicode> = .01)", 821.162187177968,
                                      "Goodness of fit index (GFI)", 0.984016681585093, "McDonald fit index (MFI)",
                                      0.995501480640541, "Expected cross validation index (ECVI)",
                                      0.180684002957667))
})


test_that("Variance-covariance input works", {
  options <- jaspTools::analysisOptions("SEM")
  options$dataType          <- "varianceCovariance"
  options$sampleSize        <- 75
  options$emulation         <- "lavaan"
  options$estimator         <- "default"
  options$group             <- ""
  options$samplingWeights   <- ""
  options$informationMatrix <- "expected"
  options$naAction          <- "fiml"
  options$modelTest         <- "standard"
  options$models <- list(
    list(name = "Model1", syntax = list(model = "F =~ x1 + x3 + y1", columns = c("x1", "x2", "x3"))),
    list(name = "Model2", syntax = list(model = "F =~ y1 + y2 + y3", columns = c("y1", "y2", "y3")))
    )

  data <- read.csv("poldem_grouped.csv")
  data <- cov(data)
  data <- as.data.frame(data)

  set.seed(1)
  results <- jaspTools::runAnalysis("SEM", data, options)
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fittab"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(707.570148255052, 721.47507693627, 0, 0, "Model1", 75, 1, "",
                                      "", "", 1095.63355300897, 1109.53848169019, 0, 0, "Model2", 75,
                                      1, "", 0, 0))
})


test_that("Fixing mean manifest intercepts works", {
  options <- jaspTools::analysisOptions("SEM")
  options$models <- list(list(name = "Model1", syntax = list(model = "factor =~ x2 + x3 + y1 + x1", columns = c("x1", "x2", "x3", "y1"))))
  options$emulation         <- "lavaan"
  options$estimator         <- "default"
  options$meanStructure     <- TRUE
  options$manifestMeanFixedToZero <- TRUE
  options$group             <- "group"
  options$samplingWeights   <- ""
  options$informationMatrix <- "expected"
  options$naAction          <- "fiml"
  options$modelTest         <- "standard"

  set.seed(1)

  results <- jaspTools::runAnalysis("SEM", "poldem_grouped.csv", options)
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_mu"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(-3.0031653252094, -0.238164753555845, -1.62066503938262, 1, "",
                                      "x2", 0.0215840525894235, 0.705370250031003, -2.29760900649183,
                                      -2.90748296601922, -0.257527727837225, -1.58250534692822, 1,
                                      "", "x3", 0.0192367987813871, 0.676021411384215, -2.34091009586205,
                                      -2.02601609127232, 3.81817181538369, 0.896077862055687, 1, "",
                                      "y1", 0.547816766514775, 1.49089165738611, 0.601034862336494,
                                      1.63165251250819, 2.98253253600213, 2.30709252425516, 1, "",
                                      "x1", 2.16224815829946e-11, 0.344618583338652, 6.6946259888371,
                                      5.33697746290641, 8.26080927533766, 6.79889336912203, 1, "",
                                      "factor", 0, 0.745889168243412, 9.11515230222956, -4.07239223241945,
                                      -0.696581025547053, -2.38448662898325, 2, "", "x2", 0.00562595928754916,
                                      0.861192152891677, -2.76882066444372, -3.8707672830057, -0.886230339808109,
                                      -2.37849881140691, 2, "", "x3", 0.00178440810521097, 0.761375455554092,
                                      -3.12394994356096, -0.553574385842091, 6.22823829704087, 2.83733195559939,
                                      2, "", "y1", 0.101006267898262, 1.73008604657459, 1.63999470501311,
                                      1.12212007800144, 2.7291868915801, 1.92565348479077, 2, "",
                                      "x1", 2.63986228365987e-06, 0.409973557232427, 4.69701874869713,
                                      5.05992393096499, 8.54168933431517, 6.80080663264008, 2, "",
                                      "factor", 1.90958360235527e-14, 0.88822178132198, 7.65665374983052
                                 ))
})


# multigroup sem with clickable equality constraints
options <- jaspTools::analysisOptions("SEM")
options$emulation                   = "lavaan"
options$estimator                   = "default"
options$group                       = "group"
options$informationMatrix           = "expected"
options$naAction                    = "listwise"
options$modelTest                   = "default"
options$equalLatentVariance <- TRUE
options$equalThreshold <- TRUE
options$equalResidualCovariance <- TRUE
options$samplingWeights             = ""

modelDefault <- list(model = "
  # latent variable definitions
    ind60 =~ x1 + x2 + x3
    dem60 =~ y1 + y2 + y3 + y4
    dem65 =~ y5 + y6 + y7 + y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual (co)variances
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
  ", columns = c("x1", "x2", "x3", "y1", "y2", "y3", "y4", "y5", "y6", "y7", "y8"))

options$models = list(
  list(name = "default", syntax = modelDefault)
)

results <- jaspTools::runAnalysis("SEM", "poldem_grouped.csv", options)


test_that("Model fit table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fittab"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(3132.86971459993, 3255.69658461736, 87.8060617718737, 79, "default",
                                      75, 0.233090294836104, 0.233090294836104, 87.8060617718737,
                                      79))
})

test_that("Residual covariances table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_cov"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(-0.00951791257482959, 1.24816024605178, 0.619321166738473, 1,
                                      ".p15.", "y1 - y5", 0.0535698529369328, 0.320842160505757, 1.93029857971973,
                                      0.275192537634027, 2.86800908936388, 1.57160081349895, 1, ".p16.",
                                      "y2 - y4", 0.0175009166166575, 0.661444948014774, 2.37601151572156,
                                      0.268525824232089, 2.7211595743112, 1.49484269927165, 1, ".p17.",
                                      "y2 - y6", 0.0168880472594957, 0.625683372098972, 2.38913604856865,
                                      -0.133131830969623, 2.16082046556287, 1.01384431729662, 1, ".p18.",
                                      "y3 - y7", 0.0831904444650153, 0.585202665617047, 1.73246701846037,
                                      -0.317356322859665, 1.22820518019921, 0.455424428669772, 1,
                                      ".p19.", "y4 - y8", 0.248061966101383, 0.394283138682666, 1.15506950206236,
                                      -0.107502588115688, 1.92491220954654, 0.908704810715428, 1,
                                      ".p20.", "y6 - y8", 0.0796666998015847, 0.518482689910034, 1.75262323776538,
                                      -0.00951791257482848, 1.24816024605178, 0.619321166738474, 2,
                                      ".p15.", "y1 - y5", 0.0535698529369324, 0.320842160505757, 1.93029857971974,
                                      0.275192537634027, 2.86800908936388, 1.57160081349895, 2, ".p16.",
                                      "y2 - y4", 0.0175009166166575, 0.661444948014774, 2.37601151572156,
                                      0.268525824232089, 2.7211595743112, 1.49484269927165, 2, ".p17.",
                                      "y2 - y6", 0.0168880472594957, 0.625683372098972, 2.38913604856865,
                                      -0.133131830969623, 2.16082046556287, 1.01384431729662, 2, ".p18.",
                                      "y3 - y7", 0.0831904444650153, 0.585202665617047, 1.73246701846037,
                                      -0.317356322859664, 1.22820518019921, 0.455424428669772, 2,
                                      ".p19.", "y4 - y8", 0.248061966101383, 0.394283138682666, 1.15506950206236,
                                      -0.107502588115688, 1.92491220954654, 0.908704810715428, 2,
                                      ".p20.", "y6 - y8", 0.0796666998015847, 0.518482689910034, 1.75262323776538
                                 ))
})

test_that("Factor Loadings table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_ind"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(1, 1, 1, 1, "", "dem60", "", "y1", 0, "", 0.756011678010104, 1.67072819069569,
                                      1.2133699343529, 1, "", "dem60", 1.9952676000301e-07, "y2",
                                      0.233350337021689, 5.19977793835421, 0.589605318467516, 1.32872910566561,
                                      0.959167212066564, 1, "", "dem60", 3.63917969981031e-07, "y3",
                                      0.188555451280791, 5.08692379642846, 0.805825133517716, 1.44228139685688,
                                      1.1240532651873, 1, "", "dem60", 4.42068603945245e-12, "y4",
                                      0.162364275149812, 6.92303318664248, 1, 1, 1, 1, "", "dem65",
                                      "", "y5", 0, "", 0.700926359250009, 1.43830977067363, 1.06961806496182,
                                      1, "", "dem65", 1.29983670493772e-08, "y6", 0.18811146971067,
                                      5.68608637531234, 0.772761413508819, 1.46047960799357, 1.11662051075119,
                                      1, "", "dem65", 1.95760740950846e-10, "y7", 0.175441538699023,
                                      6.36463017271413, 0.624931701232413, 1.39554577224672, 1.01023873673957,
                                      1, "", "dem65", 2.76438375079735e-07, "y8", 0.196588834563496,
                                      5.13884086541687, 1, 1, 1, 1, "", "ind60", "", "x1", 0, "",
                                      1.96896816200596, 2.59152950311334, 2.28024883255965, 1, "",
                                      "ind60", 0, "x2", 0.158819586997022, 14.3574786691921, 1.41188756682593,
                                      2.28258726764383, 1.84723741723488, 1, "", "ind60", 0, "x3",
                                      0.222121352148783, 8.31634329327129, 1, 1, 1, 2, "", "dem60",
                                      "", "y1", 0, "", 0.946873365788966, 1.95400766095123, 1.4504405133701,
                                      2, "", "dem60", 1.64848641404092e-08, "y2", 0.256926735161057,
                                      5.64534676572633, 0.693457886245215, 1.60751683650406, 1.15048736137464,
                                      2, "", "dem60", 8.06253452667605e-07, "y3", 0.233182588422242,
                                      4.93384763055875, 0.985835136390041, 1.80735761387033, 1.39659637513018,
                                      2, "", "dem60", 2.6662450025583e-11, "y4", 0.209575911588261,
                                      6.66391649949722, 1, 1, 1, 2, "", "dem65", "", "y5", 0, "",
                                      0.990824643773827, 2.24686561848509, 1.61884513112946, 2, "",
                                      "dem65", 4.36775339229811e-07, "y6", 0.320424503873223, 5.05218892925231,
                                      1.02335110163161, 2.23722284550416, 1.63028697356788, 2, "",
                                      "dem65", 1.40458174646696e-07, "y7", 0.309666849352186, 5.26464804669404,
                                      1.1798456720653, 2.29947786139703, 1.73966176673116, 2, "",
                                      "dem65", 1.12414877406763e-09, "y8", 0.285625704901529, 6.09070450200173,
                                      1, 1, 1, 2, "", "ind60", "", "x1", 0, "", 1.84998352886442,
                                      2.73263225194019, 2.2913078904023, 2, "", "ind60", 0, "x2",
                                      0.225169628125308, 10.1759189704181, 1.46115134483908, 2.34512680229753,
                                      1.90313907356831, 2, "", "ind60", 0, "x3", 0.225508086993215,
                                      8.43933846871561))
})

test_that("Factor variances table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_lvar"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(0.236834368913409, 0.526943426776363, "ind60", 0.381888897844886,
                                      1, ".p32.", "ind60", 2.46885135668506e-07, 0.0740087726487062,
                                      5.16004906144815, 2.10074625444669, 5.55500000431209, "dem60",
                                      3.82787312937939, 1, ".p33.", "dem60", 1.39965271599429e-05,
                                      0.881203373406886, 4.34391565545212, -0.163743825408124, 0.471589188522818,
                                      "dem65", 0.153922681557347, 1, ".p34.", "dem65", 0.342272660831397,
                                      0.162077726668033, 0.949684356522418, 0.236834368913409, 0.526943426776364,
                                      "ind60", 0.381888897844886, 2, ".p32.", "ind60", 2.46885135668506e-07,
                                      0.0740087726487062, 5.16004906144815, 2.10074625444669, 5.55500000431209,
                                      "dem60", 3.82787312937939, 2, ".p33.", "dem60", 1.39965271599429e-05,
                                      0.881203373406886, 4.34391565545212, -0.163743825408123, 0.471589188522818,
                                      "dem65", 0.153922681557347, 2, ".p34.", "dem65", 0.342272660831395,
                                      0.162077726668033, 0.949684356522422))
})

test_that("Regression coefficients table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_reg"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(0.74768461194592, 3.13257692292812, 1.94013076743702, 1, "dem60",
                                      0.00142817392050287, "ind60", 0.608402075189629, 3.18889570985161,
                                      0.348414558253314, 1.77200632968998, 1.06021044397165, 1, "dem65",
                                      0.0035077327559101, "ind60", 0.363167839477097, 2.91934011970383,
                                      0.561449579948802, 1.07483914739603, 0.818144363672416, 1, "dem65",
                                      4.188163149621e-10, "dem60", 0.130969132978152, 6.24684874266441,
                                      -0.159200803124074, 2.11012259112266, 0.975460893999292, 2,
                                      "dem60", 0.0919948186806887, "ind60", 0.578919666929308, 1.68496762110935,
                                      -0.060427080504905, 0.893216563537904, 0.4163947415165, 2, "dem65",
                                      0.0869740956449763, "ind60", 0.243280910150653, 1.7115800054293,
                                      0.520132317569988, 1.00885279137076, 0.764492554470373, 2, "dem65",
                                      8.68684457699942e-10, "dem60", 0.124675881203873, 6.13183999253438
                                 ))
})

test_that("Residual variances table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_params"]][["collection"]][["modelContainer_params_var"]][["data"]]
  jaspTools::expect_equal_tables(table,
                                 list(0.0203903214908377, 0.0937153039795448, "x1", 0.0570528127351912,
                                      1, "", "x1", 0.00228823496004704, 0.0187056963972515, 3.05002345400914,
                                      -0.118209788938257, 0.149904178675381, "x2", 0.0158471948685619,
                                      1, "", "x2", 0.816777242474263, 0.0683976771329697, 0.231692003776004,
                                      0.265272329814418, 0.77118752500936, "x3", 0.518229927411889,
                                      1, "", "x3", 5.93589306818743e-05, 0.129062370325561, 4.0153448763156,
                                      0.955937394672428, 3.44425722642889, "y1", 2.20009731055066,
                                      1, "", "y1", 0.000528495119347161, 0.63478713164732, 3.46588202700525,
                                      3.66970107786074, 9.74166689190863, "y2", 6.70568398488469,
                                      1, "", "y2", 1.49759018457374e-05, 1.54899933415685, 4.3290425224971,
                                      2.27047423539234, 6.74954147085745, "y3", 4.51000785312489,
                                      1, "", "y3", 7.91345249973041e-05, 1.1426401890023, 3.94700614990867,
                                      0.808965794775632, 3.41798227151407, "y4", 2.11347403314485,
                                      1, "", "y4", 0.00149631062392186, 0.66557765788505, 3.17539810434842,
                                      1.11694253229257, 3.50064331730598, "y5", 2.30879292479928,
                                      1, "", "y5", 0.000146608976578477, 0.608098108897852, 3.79674412897592,
                                      2.01550902816011, 5.70617179577256, "y6", 3.86084041196633,
                                      1, "", "y6", 4.11943023612693e-05, 0.941512904503329, 4.1006771054328,
                                      1.24180041617095, 4.19509083800568, "y7", 2.71844562708831,
                                      1, "", "y7", 0.000308309240888649, 0.753404257713385, 3.60821643793057,
                                      2.48138223648679, 6.90158475152541, "y8", 4.6914834940061, 1,
                                      "", "y8", 3.17543815182564e-05, 1.12762340275245, 4.16050561078682,
                                      0.029510673036908, 0.141539110406694, "x1", 0.0855248917218009,
                                      2, "", "x1", 0.00276651561179819, 0.0285792081521528, 2.99255638107519,
                                      -0.0267791677359907, 0.438546862055045, "x2", 0.205883847159527,
                                      2, "", "x2", 0.0828515610609226, 0.118707801128354, 1.73437503856139,
                                      0.176021005738021, 0.655774374392718, "x3", 0.415897690065369,
                                      2, "", "x3", 0.000678354170778217, 0.12238831234628, 3.39818142837566,
                                      0.574750605514609, 2.32900512597363, "y1", 1.45187786574412,
                                      2, "", "y1", 0.00117756468638741, 0.44752213160455, 3.24425936330466,
                                      3.6870584232221, 9.87516092384412, "y2", 6.78110967353311, 2,
                                      "", "y2", 1.74240725272501e-05, 1.57862658432323, 4.29557549636745,
                                      3.2208970735798, 9.03569722755529, "y3", 6.12829715056754, 2,
                                      "", "y3", 3.60771566090268e-05, 1.48339464394292, 4.13126552370331,
                                      1.74649287998714, 5.53471771963364, "y4", 3.64060529981039,
                                      2, "", "y4", 0.000165104461237187, 0.966401645521942, 3.76717622189492,
                                      1.12693384686582, 3.23414942031535, "y5", 2.18054163359059,
                                      2, "", "y5", 4.98493706548864e-05, 0.537564871107577, 4.05633208341514,
                                      2.42234871563612, 6.77525180716898, "y6", 4.59880026140255,
                                      2, "", "y6", 3.45243234869397e-05, 1.1104548669945, 4.14136620775002,
                                      1.93723745179962, 6.03541205409186, "y7", 3.98632475294574,
                                      2, "", "y7", 0.000137321827685, 1.04547191545817, 3.81294293419518,
                                      0.313473463282918, 2.61122637106262, "y8", 1.46234991717277,
                                      2, "", "y8", 0.0126047867836248, 0.586172227118478, 2.494744461643
                                 ))
})
jasp-stats/jaspSem documentation built on April 30, 2024, 7:06 p.m.