tests/testthat/test-classicalmetaanalysis.R

context("Meta Analysis")

options <- jaspTools::analysisOptions("ClassicalMetaAnalysis")
options$covariates <- "contcor2"
options$effectSize <- "contNormal"
options$factors    <- c("facGender", "facExperim")
options$forestPlot <- TRUE
options$funnelPlot <- TRUE
options$funnelPlotRegressionTestAsymmetry <- TRUE
options$method     <- "Restricted ML"
options$modelTerms <- list(list(components = "contcor2"),
                           list(components = "facGender"),
                           list(components = "facExperim"))
options$failSafeN <- TRUE
options$diagnosticPlot <- TRUE
options$profilePlot <- TRUE
options$funnelPlotRankTestAsymmetry <- FALSE
options$coefficientCi <- TRUE
options$covarianceMatrix <- TRUE
options$casewiseDiagnostics <- TRUE
options$residualParameter <- TRUE
options$studyLabel <- "contBinom"
options$trimFillAnalysis <- TRUE
options$effectSizeSe <- "debCollin1"

options$coefficientEstimate <- TRUE
options$coefficientCiLevel <- .95
options$estimateTest <- "z"
options$fitMeasure <- TRUE
options$diagnosticQqPlot <- TRUE

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

test_that("Influence Measures table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_casewiseTable"]][["data"]]
  expect_equal_tables(table,
                      list(262.732350870067, 0.0400378184752688, 1.07230885151213, 0.199763610175039,
                           0.0551419254175412, 1.1, 0.826671964662481, 0.714326031980455,
                           1.02013544871556, 256.178327946014, 0.129653797670661, 0.992489685001572,
                           -0.363356145031213, 0.0532361232571621, 0.1, -1.53026301584699,
                           0.693044256062938, 1.17325184481961, 252.104071340083, 0.130107703282504,
                           0.955799988714369, 0.365882892108392, 0.0448001488250868, 0.2,
                           1.6848043442563, 0.684994293447751, 1.25741507559644, 259.540993791085,
                           0.0624768342258867, 1.00380567459012, 0.250944606537475, 0.0345435263374786,
                           1.2, 1.32453918608363, 0.70174247901759, 1.01909462525274, 263.230540141172,
                           0.014909247768068, 1.06903418273161, -0.121661900735042, 0.0391217340610604,
                           1.3, -0.604582056053913, 0.718254191512592, 1.08744711789683,
                           256.90637912375, 0.0875666622802145, 0.983097211158387, -0.29825995693398,
                           0.0381522318730287, 1.4, -1.49460948337919, 0.69482469344226,
                           1.13683800695382, 264.391499077268, 0.00113847072121011, 1.06171002333134,
                           -0.0336055771280454, 0.0248380518467288, 0.3, -0.209296627571492,
                           0.720495080400654, 0.906538477607375, 263.185696184134, 0.022832125525009,
                           1.07131544837111, -0.15070486684049, 0.0466571914708536, 0.4,
                           -0.681930278940677, 0.716607810291418, 1.00865294840775, 263.503982057869,
                           0.0150143574590837, 1.0633698594597, 0.122195250475624, 0.0374681406173809,
                           0.5, 0.62007207281698, 0.717218478915165, 0.957568702046681,
                           264.303646920765, 0.00491869083920503, 1.08903804851365, -0.0698406163632372,
                           0.0489589452046736, 0.6, -0.305633358500751, 0.720600532353734,
                           0.960061694175131, 263.130014054492, 0.0157520342175195, 1.04526955506304,
                           0.125265510956865, 0.0273714728953213, 0.7, 0.746833568420508,
                           0.715299483591345, 0.94081355402465, 263.923890851722, 0.00651024016783402,
                           1.07064000024066, 0.0803106715475914, 0.0329679112274638, 1.5,
                           0.434799690509734, 0.72050745705593, 1.07800888366839, 263.637416957089,
                           0.0213816529890195, 1.08568632737589, -0.145790569069402, 0.0556091729001072,
                           0.8, -0.599783062488506, 0.717713933250214, 0.9598516578749,
                           264.064019536477, 0.00469439998031469, 1.05768256863823, -0.0682815782236001,
                           0.0257115224456209, 0.9, -0.420585487425781, 0.719151799042604,
                           0.913755734694117, 252.112140337978, 0.166554937076435, 0.887092570380186,
                           -0.415553354189001, 0.0326029174346965, 0.1, -2.25734082389787,
                           0.668058676936457, 0.956162544177124, 262.019669281644, 0.0492079174138656,
                           1.08849500599352, -0.221367831739761, 0.0679451840487333, 0.11,
                           -0.82025156155775, 0.714717406822812, 1.16008969471307, 263.940584701539,
                           0.00984278052869501, 1.07818925856344, 0.0988032106876967, 0.0422108455857725,
                           1.6, 0.469565366081506, 0.719767462515528, 1.03066477221473,
                           262.635998813336, 0.0277884742151193, 1.0540039336839, 0.166447527593902,
                           0.0394506405195474, 0.12, 0.821753833431341, 0.714111619826483,
                           0.986166033035772, 259.7462165447, 0.0649675347550098, 1.00973469328686,
                           -0.255798417913255, 0.0373051108291292, 0.13, -1.29793790855314,
                           0.702593803717153, 1.01716197271916, 261.892920274869, 0.0276194775159346,
                           1.03051207870342, 0.166153419014527, 0.0278737446530384, 0.14,
                           0.981180886648714, 0.711111089152778, 1.02456732152875, 263.410997302875,
                           0.0163818848063185, 1.04745366368733, -0.127806314244881, 0.0308685802106828,
                           0.15, -0.716622116361629, 0.71486267251089, 0.780659988310177,
                           264.486126634818, 9.42765967859871e-05, 1.09693876458671, -0.00966882346617827,
                           0.0566452486183803, 1.7, -0.0376060978734504, 0.720329555584944,
                           0.846581708463617, 264.467216113266, 0.000347663681632075, 1.12078961047271,
                           -0.0185528845994789, 0.0733174843774056, 0.16, -0.0662837042013889,
                           0.721393604591763, 0.949292948169384, 264.084401539423, 0.00582571672299131,
                           1.08177342889251, 0.0760064288879191, 0.0434992819082006, 0.17,
                           0.358511618579171, 0.720327554289507, 0.991719996768945, 249.807617980615,
                           0.296071798669854, 0.862570603808377, 0.556996539324682, 0.0471343702938604,
                           0.18, 2.51526893842518, 0.656354535075111, 0.965213760722877,
                           263.237229906306, 0.0129781716807686, 1.06427327517358, -0.113487732485723,
                           0.0340885708947719, 0.19, -0.605472911645839, 0.718471396576595,
                           1.11383590369921, 264.477139925839, 0.000241363832875931, 1.10271858944973,
                           0.0154535436569728, 0.0579092285640316, 0.2, 0.0620624629963332,
                           0.721464770583211, 0.955843246357338, 261.592349033842, 0.0383826843075627,
                           1.03821523152685, -0.195911090440106, 0.0366654104761845, 1.8,
                           -1.00419180922472, 0.710646361209932, 1.08126598605143, 262.031531803146,
                           0.0523221803493081, 1.05658703904295, 0.228688920569409, 0.0518091933978843,
                           1.9, 0.978321396192137, 0.711127420763697, 0.986008111237554,
                           264.334192024572, 0.00170018192868327, 1.06932394906259, 0.0410260087217109,
                           0.0279703377923599, 0.21, 0.240971183816203, 0.721627084235482,
                           1.02915920952368, 260.090898997263, 0.0586951920070977, 1.00372351040421,
                           -0.243094816746173, 0.0323351912136825, 0.22, -1.32847951049045,
                           0.702367557275806, 0.941311872170127, 264.473062127682, 3.45601878789042e-05,
                           1.08736723880078, 0.00582826919393597, 0.0395764013571677, 0.23,
                           0.0315044745520896, 0.722990864379933, 1.09520218639425, 260.156280370592,
                           0.0443225530934775, 1.01040059762166, 0.211078164318548, 0.0296249670629047,
                           1.1, 1.20721091819925, 0.705019002426001, 1.06577540862248,
                           262.084543331013, 0.03095444230226, 1.03770604219735, 0.175870502580463,
                           0.0332205524089201, 0.24, 0.948941127884395, 0.711519999060467,
                           0.970747228146241, 264.462181817776, 0.000306366892144499, 1.07252279981121,
                           -0.0174049333562665, 0.0297863138786156, 0.25, -0.0986702777455402,
                           0.721946566469843, 1.00752893980872, 263.199487748789, 0.0178212903684757,
                           1.06770348297196, 0.133045213981202, 0.0397098808383198, 1.11,
                           0.653655734739846, 0.71772220224666, 1.09207612142027, 264.414307389591,
                           0.000710358994776927, 1.0677671844022, 0.0265230345696218, 0.0271103785012906,
                           1.12, 0.160102482611091, 0.721460471519471, 0.981144883255629,
                           259.790203136184, 0.0725276301870289, 1.00590558899725, 0.270397742704451,
                           0.0379613916590061, 1.13, 1.3627774206512, 0.701335856457346,
                           0.993106748469139, 264.202563630793, 0.00353560503720366, 1.0671530651487,
                           -0.0592518854324624, 0.0326923949591393, 1.14, -0.324217342937164,
                           0.71964212751066, 0.892076466536199, 263.301053090431, 0.0117573333163135,
                           1.05482541084631, -0.10808505531397, 0.0283239550278417, 0.26,
                           -0.633912819941443, 0.717618997656188, 1.04555961161393, 264.282863064434,
                           0.00251203339343546, 1.06980942367922, -0.0498848915151949,
                           0.0299101371547695, 0.27, -0.282739864658242, 0.721184457990021,
                           1.01000844076643, 259.231442911687, 0.0800389943663721, 0.996362396565014,
                           -0.284340700289489, 0.0373293369426948, 1.15, -1.4444383827718,
                           0.698843144833853, 0.977072351937748, 264.211959185435, 0.00357796893460874,
                           1.07904630904712, -0.0595076833909259, 0.0368126541473998, 0.28,
                           -0.304298802618047, 0.721607860439429, 1.07014601249758, 262.987216670837,
                           0.0303266901175037, 1.07177258641339, -0.173788796983328, 0.0511268003882449,
                           0.29, -0.749147803482661, 0.715388201289679, 0.983653989095089,
                           263.91501713302, 0.00664985056785539, 1.05194732030687, -0.0813134513981273,
                           0.0242324715305451, 1.16, -0.51470019483984, 0.718031767923289,
                           0.881779902966192, 258.216307742723, 0.0850030233094573, 1.00033295743934,
                           0.293231631247393, 0.0419618315044775, 0.3, 1.39710830452012,
                           0.698590578221128, 1.08883920788334, 264.446586118049, 0.000620656638867984,
                           1.09545268540313, -0.024756463092253, 0.0468874546121777, 1.17,
                           -0.111726660749746, 0.722927124078898, 1.10284462812178, 264.018041777372,
                           0.00576819964447564, 1.06477300042041, 0.0756412387925055, 0.0297146665445654,
                           1.18, 0.430969687240779, 0.719889438740922, 0.999570587218623,
                           249.000285930228, 0.181559824467493, 0.843572355106713, -0.436758829752031,
                           0.0298260274797383, 1.19, -2.49536437982044, 0.65517932573377,
                           0.997824926430928, 264.480335012354, 0.000103936465204631, 1.08854696180227,
                           0.0101171093065668, 0.0422944749736182, 0.31, 0.0481546700990743,
                           0.722482445252907, 1.04905179991346, 264.408346779589, 0.000951135479999111,
                           1.05934358954801, -0.0307260165206774, 0.023998454197374, 1.2,
                           -0.194848700543862, 0.720100769284271, 0.864343492689289, 258.368515845456,
                           0.0691111885522944, 0.970133273970689, -0.264665895994432, 0.0268100449674393,
                           1.21, -1.59510609803463, 0.694417443179183, 0.94731200407551,
                           263.000840449961, 0.0311582839178547, 1.07241011399101, 0.176109573586821,
                           0.0506342844037787, 0.32, 0.761665531377413, 0.715710235284731,
                           1.03915875016335, 264.485607271366, 0.000137321650901439, 1.09880850775722,
                           -0.0116419221733311, 0.0494264825407868, 1.22, -0.0485535247105303,
                           0.723040168732542, 1.10048112594451, 244.993636623832, 0.435718059993702,
                           0.793631102358943, 0.68125096457791, 0.0487189327131783, "0.33*",
                           3.03868188160114, 0.63373502700228, 0.912003267964907, 264.397562424106,
                           0.00176404366457001, 1.06896398992258, -0.0418402122071319,
                           0.0319725289485183, 1.23, -0.227584134309606, 0.720339431614264,
                           0.895359586946968, 263.682169614338, 0.0166991829795047, 1.08327845987416,
                           0.128810513059293, 0.0519053135497598, 0.34, 0.551303096189933,
                           0.718199004143768, 0.971586474203684, 264.471276026243, 0.000299985603565483,
                           1.06995157967555, 0.0172455956482921, 0.0318437760394784, 0.35,
                           0.0935650194031671, 0.720639681017737, 0.885500312230464, 264.333344669015,
                           0.00176718059686404, 1.05551047547065, 0.0419102806677818, 0.0238178047538881,
                           0.36, 0.269151514569511, 0.719114746158142, 0.80504829426005,
                           264.365978722454, 0.0014877404704249, 1.0635056169653, 0.0384106859130233,
                           0.0259347060824912, 0.37, 0.233976946388302, 0.720656931083091,
                           0.931843387372788, 262.950252307175, 0.023293447381001, 1.04413964512889,
                           0.152427562334511, 0.0314725911045964, 0.38, 0.844636046239098,
                           0.713788423943177, 0.917615352513552, 262.786058067816, 0.0255309324155376,
                           1.0452986996255, -0.159585299884791, 0.0332126721762813, 0.39,
                           -0.860280337238193, 0.713593174038668, 0.954703676749585, 260.848882894022,
                           0.0747437681320256, 1.03143034511094, -0.273986123720313, 0.0478484920151539,
                           1.24, -1.22308868517711, 0.705487505287832, 0.968284159650685,
                           249.37224560888, 0.163009895357697, 0.872694564502329, 0.413323792806685,
                           0.0333305228438864, 1.25, 2.22332792760769, 0.663345642805233,
                           1.11138539645608, 264.263285345332, 0.00408183844281455, 1.07300861486857,
                           0.0636241017047156, 0.0352159607893979, 1.26, 0.330621622453422,
                           0.720465569605701, 0.966467342682284, 263.547388650994, 0.0162131427195097,
                           1.06577311255296, -0.126958713925477, 0.0389157120710873, 1.27,
                           -0.629820389652029, 0.717434383359289, 0.983361653113583, 257.861519568661,
                           0.100070328526072, 0.964539426610873, 0.31889937208111, 0.0334000114773794,
                           1.28, 1.72260605012161, 0.690910625674687, 0.93054970941149,
                           262.885206032293, 0.0226378429791355, 1.0755650462777, 0.14996441923553,
                           0.0478939862307731, 0.4, 0.669841756057418, 0.717376530507227,
                           1.11597018939174, 263.9311181682, 0.0118276744209341, 1.12528708660025,
                           -0.108095096375888, 0.0746214113506653, 0.41, -0.380284802618594,
                           0.72219617008024, 1.20750228957917, 263.633670771905, 0.00913876368490845,
                           1.07363859297916, 0.0951248108009196, 0.035898770357793, 0.42,
                           0.493211057261931, 0.720446513508, 1.15384630290158, 264.152766390337,
                           0.00528576923429818, 1.07458459499069, -0.0724096968247506,
                           0.0376987141569674, 1.29, -0.365625887153166, 0.720147675639769,
                           0.968324830851101, 262.922668106312, 0.0169256038657695, 1.04418733369507,
                           -0.129855235628153, 0.0274244241123892, 0.43, -0.773723038635124,
                           0.714989687748589, 0.978363651951187, 264.155309044222, 0.00309215698110062,
                           1.07354643115722, 0.0553000972711742, 0.0307631485502674, 1.3,
                           0.31167808646752, 0.721940656629064, 1.11214391584654, 262.277720755017,
                           0.023475745490142, 1.03261283467631, -0.153121187898894, 0.0264947988940786,
                           0.44, -0.928234642676591, 0.712091456209771, 0.973600996531128,
                           253.179693939302, 0.206116599950869, 0.972205811747802, -0.460423506077168,
                           0.0650966047580989, 0.45, -1.73691425077676, 0.683755107393275,
                           1.18247846263982, 264.250555889891, 0.00285924531675716, 1.05872482226843,
                           0.0532835859361663, 0.0250483234782882, 0.46, 0.331467049198659,
                           0.71962635396489, 0.887331840316315, 264.287096049129, 0.00315253252146909,
                           1.06675661988464, -0.0559446519575265, 0.0316431285565131, 1.31,
                           -0.307863825910765, 0.719845627039266, 0.891081194595183, 264.203813246495,
                           0.00441388307908344, 1.06773329986483, 0.066200617267153, 0.0333447104550212,
                           0.47, 0.356027469629469, 0.719604325652675, 0.902876328166279,
                           259.283889896958, 0.0701175534425527, 1.00549028144472, -0.265928515613535,
                           0.0379914266301231, 0.48, -1.33560926775154, 0.70120531529104,
                           1.03491409134237, 264.450442631079, 0.000677088098861326, 1.08508617547386,
                           0.0258967730060505, 0.0428901154205797, 0.49, 0.122363582611671,
                           0.721380593474931, 0.960432884352045, 262.284905947309, 0.0298763914266522,
                           1.04418036083254, -0.172704130056014, 0.0357084345169947, 0.5,
                           -0.897894843186011, 0.712554793380592, 0.977865356709139, 263.326580913546,
                           0.0459927390561056, 1.13941072614198, 0.213742141023718, 0.0999217667730841,
                           0.51, 0.64111746871274, 0.717797896650162, 1.06964746833055,
                           227.862349461133, 0.400100993527829, 0.627364704748626, 0.677764368512727,
                           0.032970833075749, "0.52*", 3.59886579622404, 0.577355414942708,
                           1.11025096934081, 264.422983828242, 0.000606774934210689, 1.06532003298717,
                           -0.0245176416445016, 0.0257088358727732, 1.32, -0.151899096254993,
                           0.721212844094056, 0.954896418186984, 264.210650343259, 0.00318800194189171,
                           1.06227140287373, -0.0562364321411354, 0.0264013638569607, 1.33,
                           -0.34051150352262, 0.720189866667162, 0.951323929225293, 264.146063808404,
                           0.00792457287408484, 1.0852416102957, 0.0887461379005808, 0.0512159741611121,
                           1.34, 0.382063155630509, 0.718909377739538, 0.848936406110151,
                           264.429714720284, 0.00115798749927809, 1.0736205527411, 0.0338743573213564,
                           0.0330364556565167, 0.53, 0.180835325886534, 0.721274933243793,
                           0.966456809635037, 264.347049522363, 0.00148782840131322, 1.08788080390753,
                           -0.0383354650110578, 0.0403447687234004, 1.35, -0.188712314819792,
                           0.722899509307816, 1.12945313877843, 262.239015324698, 0.0405667829919693,
                           1.05896686332706, -0.201218634823186, 0.0483763262407339, 1.36,
                           -0.892662879169897, 0.71279328759091, 1.0057858458384, 264.339042830507,
                           0.00249547211662034, 1.07669071647814, -0.0497100437361629,
                           0.0349748727487329, 0.54, -0.258917851997594, 0.721522866081739,
                           1.02632841888735, 258.98128252755, 0.114434455174354, 1.0305961710837,
                           -0.339824991804473, 0.0613682115506481, 0.55, -1.32898304047584,
                           0.70121109120504, 1.10538894706546, 264.289548545314, 0.00299269543653001,
                           1.09195122599515, -0.0543447470555744, 0.0426950629004374, 1.37,
                           -0.255182034524808, 0.723280164168046, 1.1976778549948, 263.942262202072,
                           0.0259131692586968, 1.13258498678982, 0.160490129135178, 0.0925399977507914,
                           1.38, 0.501882152795277, 0.718380871772597, 0.891464958254635,
                           264.483134323259, 0.000223067552319245, 1.07748641736248, -0.014882056274052,
                           0.0407250818906758, 1.39, -0.0699815779908251, 0.720003379348952,
                           0.821984466864253, 264.477358812021, 0.000102824886037142, 1.06658971138016,
                           0.0100839170365109, 0.0284390778273268, 1.4, 0.059315383267866,
                           0.720746474038474, 0.892556075718011, 264.221965135642, 0.00399736923362332,
                           1.07389749687345, 0.062945400623009, 0.0350651227776714, 0.56,
                           0.328782282406387, 0.72074827307326, 0.996678038437571, 264.461935329477,
                           0.000519052043396647, 1.10766878855957, 0.0226463298088812,
                           0.0584995019584291, 1.41, 0.0907130585447701, 0.722588438082422,
                           1.06664745485891, 264.485958211608, 1.18149369745156e-05, 1.06470799045691,
                           -0.00340463293606924, 0.0285334915283407, 0.57, -0.0174794156711009,
                           0.720209798234173, 0.840484566567, 260.887242493081, 0.0458911671569587,
                           1.03696075095317, -0.214367307801245, 0.0404687705383334, 1.42,
                           -1.04339288337071, 0.70918053539942, 1.08865793243946, 262.431804838242,
                           0.0283445172487908, 1.04522443621758, 0.168194264235212, 0.0354266658559477,
                           0.58, 0.878119135080372, 0.712921459645946, 0.964495696169567))
})

test_that("Coefficients table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_coeffTable"]][["data"]]
  expect_equal_tables(table,
                      list(-0.442978799963177, -0.796105934144409, "intercept", 0.0139453388413607,
                           0.180170215078078, -0.0898516657819454, -2.4586683196843, 0.0627001759624519,
                           -0.150376029750759, "contcor2", 0.564113469510082, 0.108714347030799,
                           0.275776381675662, 0.576742423377559, 0.488477502169315, 0.0606088917506714,
                           "facGender (m)", 0.0252472258519366, 0.218304321878368, 0.916346112587959,
                           2.23759886183782, 0.011079948618749, -0.417996968163601, "facExperim (experimental)",
                           0.95963496153271, 0.218920816042528, 0.440156865401099, 0.0506116723801931
                      ))
})

test_that("Parameter Covariances table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_covMatTable"]][["data"]]
  expect_equal_tables(table,
                      list(-0.00359216662392862, -0.0207831006432576, -0.0204871467233023,
                           0.0324613064012809, "intercept", 0.011818809250333, 0.00308945286134289,
                           0.00252843577029779, -0.00359216662392862, "contcor2", 0.00252843577029779,
                           -0.00715927260823057, 0.0476567769507742, -0.0204871467233023,
                           "facGender (m)", 0.00308945286134289, 0.0479263236967265, -0.00715927260823057,
                           -0.0207831006432576, "facExperim (experimental)"))
})

test_that("File Drawer Analysis table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_failSafeTable"]][["data"]]
  expect_equal_tables(table,
                      list(0.05, 208, "Rosenthal", 0.00196593842759479))
})

test_that("Fixed and Random Effects table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fixRandTable"]][["data"]]
  expect_equal_tables(table,
                      list(3, "Omnibus test of Model Coefficients", 0.154998519713527, 5.24067551299979,
                           96, "Test of Residual Heterogeneity", 1.11540464463198e-17,
                           264.486146695969))
})

test_that("Diagnostic Plots matches", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_diagnosticPlot"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "diagnostic-plots")
})

test_that("Forest plot matches", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_forest"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "forest-plot")
})

test_that("Funnel Plot matches", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_funnel"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "funnel-plot")
})

test_that("Profile plot matches", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_profile"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "profile")
})

test_that("Trim-fill Analysis plot matches", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_trimFill"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "trim-fill-analysis")
})

test_that("Regression test for Funnel plot asymmetry (\"Egger's test\") table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_regTestTable"]][["data"]]
  expect_equal_tables(table,
                      list("sei", 0.99470394721492, 0.00663766656825617))
})

test_that("Residual Heterogeneity Estimates table results match", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_residualTable"]][["data"]]
  expect_equal_tables(table,
                      list(0.71060416156282, 0.429926531732936, "<unicode><unicode><unicode><unicode>",
                           1.0688514723806, 0.842973405015141, 0.655687831008733, "<unicode><unicode>",
                           1.03385273244336, 62.9258791193162, 50.663389411549, "I<unicode><unicode> (%)",
                           71.8546415573073, 2.69729929191932, 2.02689237884956, "H<unicode><unicode>",
                           3.55298370790381))
})

test_that("Analysis handles errors", {
  options <- jaspTools::analysisOptions("ClassicalMetaAnalysis")

  options$effectSize  <- "debInf"
  options$effectSizeSe <- "contGamma"
  results <- jaspTools::runAnalysis("ClassicalMetaAnalysis", "test.csv", options)
  expect_identical(results[["status"]], "validationError", label="Inf dependent check")

  options$effectSize <- "contNormal"
  options$effectSizeSe <- "debInf"
  results <- jaspTools::runAnalysis("ClassicalMetaAnalysis", "test.csv", options)
  expect_identical(results[["status"]], "validationError", label="Inf covariate check")

  options$effectSize <- "debSame"
  options$effectSizeSe <- "contGamma"
  results <- jaspTools::runAnalysis("ClassicalMetaAnalysis", "test.csv", options)
  expect_identical(results[["status"]], "validationError", label="No variance dependent check")

  options$effectSize <- "contNormal"
  options$effectSizeSe <- "debSame"
  results <- jaspTools::runAnalysis("ClassicalMetaAnalysis", "test.csv", options)
  expect_identical(results[["status"]], "validationError", label="No variance covariate check")

  options$effectSize <- "contGamma"
  options$effectSizeSe <- "contcor1"
  results <- jaspTools::runAnalysis("ClassicalMetaAnalysis", "test.csv", options)
  expect_identical(results[["status"]], "validationError", label = "Negative effectSizeSe check")

})

#model interaction tests
options <- jaspTools::analysisOptions("ClassicalMetaAnalysis")
options$covariates <- c("contcor1", "contcor2")
options$effectSize <- "contNormal"
options$factors <- c("facGender", "facExperim")
options$forestPlot <- TRUE
options$funnelPlot <- TRUE
options$funnelPlotRegressionTestAsymmetry <- TRUE
options$method <- "Restricted ML"
options$modelTerms <- list(list(components = "contcor1"),
                           list(components = "contcor2"),
                           list(components = "facGender"),
                           list(components = "facExperim"),
                           list(components = c("contcor1", "contcor2")),
                           list(components = c("contcor1", "facGender")),
                           list(components = c("contcor1", "facExperim")),
                           list(components = c("contcor2", "facGender")),
                           list(components = c("contcor2", "facExperim")),
                           list(components = c("facGender", "facExperim")),
                           list(components = c("contcor1", "contcor2", "facGender")),
                           list(components = c("contcor1", "contcor2", "facExperim")),
                           list(components = c("contcor1", "facGender", "facExperim")),
                           list(components = c("contcor2", "facGender", "facExperim")),
                           list(components = c("contcor1", "contcor2", "facGender", "facExperim")))
options$failSafeN <- TRUE
options$diagnosticPlot <- TRUE
options$profilePlot <- TRUE
options$funnelPlotRankTestAsymmetry <- FALSE
options$coefficientCi <- TRUE
options$covarianceMatrix <- TRUE
options$casewiseDiagnostics <- TRUE
options$studyLabel <- "contBinom"
options$trimFillAnalysis <- TRUE
options$effectSizeSe <- "contGamma"

options$coefficientEstimate <- TRUE
options$coefficientCiLevel <- .95
options$estimateTest <- "z"
options$fitMeasure <- TRUE
options$diagnosticQqPlot <- TRUE
options$residualParameter <- TRUE

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


test_that("Influence Measures table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_casewiseTable"]][["data"]]
  expect_equal_tables(table,
                      list(96.3371703556965, 0.456496281316976, 1.27649506279766, -0.679623585618869,
                           0.341081015672735, 1.1, -0.932891346420732, 0.530801439885553,
                           1.76415541098568, 98.8869537626651, 0.214460469386254, 1.35263522432983,
                           -0.462926817652488, 0.23958627443837, 0.1, -0.824663140989147,
                           0.5472761775865, 0.616549638005037, 98.7836293012193, 0.155565567986494,
                           1.32229378356002, 0.39322940594554, 0.146463806768648, 0.2,
                           0.937026335276387, 0.55496517291785, 1.05589972876348, 97.0944573721634,
                           0.47036090850364, 1.17995854425348, 0.687099824296088, 0.242902270135589,
                           1.2, 1.21055566596263, 0.535756620957678, 0.879081843682491,
                           99.1037587864346, 0.0384890582744572, 1.45753761691511, -0.195822541019073,
                           0.26799274622884, 1.3, -0.328309238028867, 0.550298193961395,
                           1.04618666564716, 99.0600932289584, 0.0281950438082037, 1.07607572896303,
                           -0.167898552504149, 0.0602583977501949, 1.4, -0.663789319470744,
                           0.545868926535264, 0.304649254940967, 99.6340850335343, 0.000332296511019668,
                           1.13490611446419, -0.0151894837403314, 0.0291409526101749, 0.3,
                           -0.0795160239759953, 0.552954450984663, 0.706176227824763, 96.0676246521706,
                           1.17370837636842, 1.59630523429472, -1.0944638594596, 0.466019258615557,
                           0.4, -1.16564848306904, 0.531383730902773, 3.05807895984599,
                           93.2286892187441, 0.573328603156085, 1.35012459102312, 0.762254245606347,
                           0.338135650558741, 0.5, 1.06350403520061, 0.535656951495965,
                           2.959867508508, 99.5178604370425, 0.0106861413113273, 1.17754308322083,
                           -0.103314555305367, 0.125694398261395, 0.6, -0.27309444953793,
                           0.54734600530051, 0.246596041183609, 99.5656476788789, 0.000376930858648799,
                           1.02157596036324, 0.0193582616299253, 0.00697383464961719, 0.7,
                           0.234356427630475, 0.546133783378388, 0.124521235886435, 99.2029169040868,
                           0.0187709703197116, 1.06626147896566, 0.137000209120695, 0.05550260054142,
                           1.5, 0.565926306351903, 0.545532533930859, 0.267977363041949,
                           93.1206764059604, 1.12756082326341, 1.56758687351851, -1.07563719041813,
                           0.494783994065642, "0.8*", -1.07841341580968, 0.525739308899614,
                           2.75272672808099, 99.4210133508834, 0.0113983912800917, 1.42522705898144,
                           -0.102908578591365, 0.112785714314819, 0.9, -0.289869345809962,
                           0.564517470995094, 2.027867800595, 98.5682083618731, 0.0782156209637672,
                           1.04301541288732, -0.279715326863375, 0.09531022742894, 0.1,
                           -0.854726675840007, 0.540213601785798, 0.293283297704831, 99.6320747060504,
                           2.7301314260226e-05, 1.07241375810413, -0.00408545696844653,
                           0.0378942701641663, 0.11, -0.0217070833702994, 0.547522607176888,
                           0.177555444554951, 99.5764305970416, 0.000377291643425515, 1.12541320390989,
                           -0.018408970252163, 0.0519442658855141, 1.6, -0.0903339836460815,
                           0.55028665216978, 0.490241587976079, 99.2930161352079, 0.0349023072917978,
                           1.19928024172504, 0.186616240236588, 0.119173039677954, 0.12,
                           0.507465481758718, 0.549469587486718, 0.558730889179477, 99.0629448765626,
                           0.0231823435583276, 1.06093884396815, -0.152260918404121, 0.0607645834476172,
                           0.13, -0.59809650349968, 0.544664429761423, 0.350666598359688,
                           96.4290438659607, 0.157813441696117, 0.87575501943706, 0.399211433692902,
                           0.0843934957585663, 0.14, 1.28482463436949, 0.527023370259163,
                           1.42089217183844, 99.1675666352809, 0.0301524997043968, 1.0787207586954,
                           -0.173646414487839, 0.074982991687078, 0.15, -0.609723587615874,
                           0.54477661744951, 0.237620583289403, 99.5054046630201, 0.0575353508633493,
                           1.87797032610779, -0.239638888106549, 0.435361694233239, 1.7,
                           -0.273180625888596, 0.549782640953181, 0.51872897763932, 99.3648160106486,
                           0.00600365797825088, 1.02971149303728, -0.0774817553108188,
                           0.0350887856127527, 0.16, -0.404857262747201, 0.544426458933545,
                           0.0773724959165598, 99.6281823087033, 0.00153245562928651, 1.34148720750426,
                           0.0376002818488803, 0.174592237863466, 0.17, 0.0805879001195639,
                           0.553391048642001, 0.828910828967494, 90.9854049688813, 1.84607929505174,
                           0.692576063120245, 1.41016014434955, 0.326118321243338, "0.18*",
                           2.01549039326494, 0.483800460304176, 2.47627536653868, 99.6064601057906,
                           8.21473452450623e-05, 1.04376378751542, 0.00896828250344568,
                           0.0284529816116606, 0.19, 0.0561366069131431, 0.546101364840013,
                           0.0931525802044637, 99.6232033716969, 8.61723687511721e-05,
                           1.03307688159099, 0.00921355512581654, 0.0211176630856855, 0.2,
                           0.0647543248713598, 0.54587422789875, 0.0750449829897274, 99.3336204763962,
                           0.010441833342158, 1.07378001183462, -0.102109309820828, 0.0380977072784802,
                           1.8, -0.514139056120247, 0.547611262901876, 0.332331821838211,
                           99.3650838472059, 0.0150542507763518, 1.0954924088389, 0.122669707561274,
                           0.0697867134428913, 1.9, 0.449079640234325, 0.546500910494261,
                           0.236820858009263, 99.1691992071566, 0.0295506382675599, 1.40252880817806,
                           0.169252029281289, 0.131974424374896, 0.21, 0.438727710096578,
                           0.561360549393711, 2.07762773309507, 99.4190807387288, 0.00200972309037426,
                           1.01664402751083, -0.0448268232355744, 0.0115560470788022, 0.22,
                           -0.416181218913605, 0.545355545571563, 0.127358337416194, 99.628955328974,
                           3.10961250103544e-05, 1.14179238875679, -0.000174083541188705,
                           0.0760760994921192, 0.23, 0.000683162611278819, 0.549353910306294,
                           0.368996044284243, 97.9526231098694, 0.0528303796145737, 1.03042806218711,
                           0.229940934221611, 0.0491530451406111, 1.1, 1.01029892042986,
                           0.543280739497788, 1.07682287939815, 97.6069588769302, 1.14165870955828,
                           2.90390978455085, 1.06054080731773, 0.619264115812464, "0.24*",
                           0.833523219229026, 0.553677799795685, 3.48929736333834, 99.5382412888392,
                           0.000751888352613661, 1.44150052269179, 0.00680577412927626,
                           0.097148981796659, 0.25, 0.0422701215403784, 0.566901721325923,
                           2.03164512796304, 99.5702842214053, 0.000226186802821931, 1.01324355086194,
                           0.0150290453702749, 0.00688068781480822, 1.11, 0.184605842242131,
                           0.54546805548156, 0.080519997727041, 99.6154678514371, 0.000159218669072343,
                           1.05280125566202, 0.0120854086033989, 0.016460159219516, 1.12,
                           0.0962278279608115, 0.547820760669214, 0.247143172174384, 97.3624395764905,
                           0.246769069341781, 1.06990854570643, 0.497399235584502, 0.159716810423891,
                           1.13, 1.13567541074509, 0.536313820499895, 0.704414958003459,
                           99.5844606001605, 0.000596158644937112, 1.03053750418902, -0.0243491617798623,
                           0.0128078199099073, 1.14, -0.214764666977019, 0.546367081796924,
                           0.125584142308918, 99.6137061390605, 0.00122087735052475, 1.3285440426295,
                           -0.030424056523754, 0.0950425615740762, 0.26, -0.0656441341463135,
                           0.560223109068849, 1.33315006499304, 99.5938741790235, 0.00916529487491505,
                           1.48655149966305, -0.0913572793212016, 0.139438947431113, 0.27,
                           -0.222938830278564, 0.56542127182227, 1.91000376904465, 98.4679924337193,
                           0.310243707252932, 1.7824078069519, -0.553165595793847, 0.351239014764223,
                           1.15, -0.750326686301846, 0.557113577898357, 2.20884421575698,
                           99.6260316072155, 0.0227333257484807, 1.99881856360405, -0.145624958973444,
                           0.335092928387113, 0.28, -0.199012432176368, 0.5690934228972,
                           2.61714045841573, 99.6104176549667, 0.0664069667083704, 1.56299086477304,
                           -0.257085202756782, 0.266200758245468, 0.29, -0.419255877416523,
                           0.556098793693554, 0.33343319233723, 99.571307396626, 0.00312879417339476,
                           1.12560832840723, -0.0553006087573252, 0.0402050354610894, 1.16,
                           -0.266621211738127, 0.551319894684875, 0.564317534610873, 99.5804050824252,
                           0.000784011546734139, 1.02949678562434, 0.0279457294729346,
                           0.0123412214716801, 0.3, 0.247738184840747, 0.546323561060829,
                           0.105988152586636, 99.5657312750271, 0.000434468448029113, 1.24161618298609,
                           0.0161849866701029, 0.07860466603684, 1.17, 0.0726056038316265,
                           0.556071328219657, 1.03214069342237, 99.5157594730634, 0.000938046169224952,
                           1.03329034804321, 0.0305768954130851, 0.0140216630203405, 1.18,
                           0.263821452295804, 0.546485541200398, 0.215613316714348, 61.2663424767168,
                           2.07108967579621, 0.00429837622820491, -1.82359502687641, 0.144266789586428,
                           "1.19*", -4.25666643238791, 0.200595920203848, 2.85625632021547,
                           99.3451304550568, 0.127600874599829, 2.46149788893631, 0.350377419125357,
                           0.479683702359611, 0.31, 0.365208049821577, 0.566453772157831,
                           3.20117262754815, 99.6332261985828, 0.00332240080553162, 1.53541576191297,
                           -0.0461572994184263, 0.0974958672139665, 1.2, -0.12037790957634,
                           0.572299781511991, 2.58036083183749, 98.601263435181, 0.335043058972649,
                           1.59983025465177, -0.575260740429679, 0.273690112953904, 1.21,
                           -0.929447783901487, 0.557443050372189, 1.92659360457737, 99.1120521548583,
                           0.497013352753578, 2.18722634696302, -0.704359414366081, 0.521106846753421,
                           "0.32*", -0.675415222916651, 0.548773898023907, 0.931821758340883,
                           99.6124302196893, 0.000991252743101212, 1.09761397512565, -0.0312961827397897,
                           0.058827339433405, 1.22, -0.126119252928827, 0.547628616038572,
                           0.246984087994497, 99.6347572447786, 0.0133261292051028, 2.02655578162516,
                           0.114444209599819, 0.437231266945347, 0.33, 0.128557116644964,
                           0.555684122393195, 0.627108142745137, 99.450090847031, 0.00406165929652207,
                           1.08313064810759, -0.0635945892837411, 0.0399341177025338, 1.23,
                           -0.316959118558204, 0.54816593100777, 0.363737283716105, 99.6227618318863,
                           0.00022546685059272, 1.03098118516384, 0.0148982055028093, 0.0123378249375784,
                           0.34, 0.130487562541352, 0.54644168341365, 0.108023507105491,
                           98.7751707447984, 0.0233634710322405, 1.33110838604415, 0.151793746496233,
                           0.146222396994535, 0.35, 0.383222346301919, 0.555524737754622,
                           1.60867398460893, 99.576515646394, 0.00277740549846082, 1.15350559696259,
                           0.0519371222937254, 0.0581162714457157, 0.36, 0.208109177859316,
                           0.551785169000919, 0.604194737474366, 99.4467755780838, 0.00217429014735891,
                           1.0435655944456, 0.0465878930117798, 0.021769297343813, 0.37,
                           0.319604011503614, 0.546649847287167, 0.286292957964169, 99.501457178244,
                           0.0196688491391593, 1.38877278238256, 0.139097405992478, 0.169801974960015,
                           0.38, 0.308358918542158, 0.55661646480645, 0.961021976172292,
                           99.2675530367414, 0.0550886767629268, 1.23863406309008, -0.234229824919644,
                           0.125409973169987, 0.39, -0.61713087103065, 0.551559255585927,
                           0.877392403328742, 98.5688274927965, 0.211969345798226, 1.27324322095087,
                           -0.460316904339828, 0.205130460495482, 1.24, -0.906166298499748,
                           0.545934957203253, 0.746182036887624, 98.7184626735135, 0.0186227885976608,
                           1.01030129180045, 0.136468538313633, 0.0239462116438353, 1.25,
                           0.868900116498524, 0.543806609165966, 0.264600761540305, 99.6031245851408,
                           0.184182623199955, 3.75170594046661, -0.422891595202222, 0.666165806714429,
                           "1.26*", -0.299165269922118, 0.564489288362896, 2.7823767662687,
                           99.6088353415526, 0.00274556962115147, 1.1117092087688, -0.052241257255033,
                           0.0660890200324689, 1.27, -0.1953293019361, 0.54804189068826,
                           0.261396118118749, 96.2738523954663, 1.0702295363524, 1.269017211009,
                           1.038507991662, 0.302461163622036, 1.28, 1.57986958280957, 0.534897240902579,
                           1.5801608043901, 99.577628702319, 0.00217589801292, 1.06483016208615,
                           0.0466156626925793, 0.0459610476766441, 0.4, 0.212759592416038,
                           0.546250087953023, 0.12315526358838, 99.6227551081177, 0.000118599841272146,
                           1.03521457150618, -0.0107570877833677, 0.0180991797930619, 0.41,
                           -0.0805669043929181, 0.546296415869489, 0.0914822540403977,
                           99.6340978532534, 5.58798661112545e-05, 1.02825406666424, 0.00732448248775069,
                           0.0129983904459344, 0.42, 0.0602817072921072, 0.54616866824168,
                           0.0813726569047265, 99.6341187186811, 0.000879859629407126,
                           1.15217560867823, -0.0284514832789621, 0.0572234014266447, 1.29,
                           -0.105517057545831, 0.551765966768637, 0.542213394621752, 99.4884554624027,
                           0.0345765111193272, 1.46051594996944, -0.182638661079046, 0.124512957796426,
                           0.43, -0.457011040873676, 0.565480738931074, 2.01397393247324,
                           96.4808338363115, 0.0403747962341611, 1.42409799123437, 0.196827752992612,
                           0.120502147420149, 1.3, 0.549280568660405, 0.563799107677805,
                           3.07480319718214, 99.5190477917848, 0.00283444533819313, 1.08533750387021,
                           -0.0528639822709547, 0.0229031279436326, 0.44, -0.3387394106602,
                           0.549790562816901, 0.436842429894619, 99.4020671628105, 0.028553521097423,
                           1.1688035635675, -0.168662860652799, 0.0689105137295757, 0.45,
                           -0.606964815814015, 0.551902620736052, 0.368926820205178, 99.6224394925908,
                           0.00169620299111446, 1.14930403794316, 0.040290609322695, 0.0561570021881634,
                           0.46, 0.158665624420202, 0.551652269916983, 0.537918874608041,
                           99.5562718444709, 0.00859946632947953, 1.29620680294048, -0.0917201837983387,
                           0.132492338870959, 1.31, -0.236470803298107, 0.554630086637897,
                           0.917409636023193, 99.4258231426553, 0.0551837319023138, 1.47153546305942,
                           0.232752676414493, 0.173672466495623, 0.47, 0.495822161529097,
                           0.561100605775342, 1.43633130079509, 99.5840714530907, 0.000126631711881769,
                           1.00454558832528, -0.0112517110705855, 0.00280527149195533,
                           0.48, -0.213008024940962, 0.545096151972286, 0.0263132970805883,
                           99.5322969859414, 0.00270699847829301, 1.05036226318412, 0.0519809735824607,
                           0.028037343198549, 0.49, 0.307299810087722, 0.546654014352046,
                           0.159977126685082, 99.1430224032566, 0.0243941270159084, 1.06560671522521,
                           -0.156190478133343, 0.0661916233652922, 0.5, -0.585982382063428,
                           0.544549221637668, 0.322384477320382, 99.4858259432433, 0.0176309640368555,
                           1.85820250218614, 0.132058514720384, 0.393304518579293, 0.51,
                           0.166387811806029, 0.554685770306653, 0.586520403982654, 78.2604881131105,
                           1.2272330348813, 0.0945186365202983, 1.17223525256392, 0.091318222640909,
                           0.52, 3.63223016187379, 0.36772976334388, 1.76390402293031,
                           98.7561644546767, 0.20955122456515, 1.63258819684821, -0.457310210946004,
                           0.361090324791359, 1.32, -0.6093051346917, 0.548420561438851,
                           1.12485834713176, 99.3864099059091, 0.0289596469932513, 1.66916443498145,
                           -0.164394672641393, 0.190009827771149, 1.33, -0.335059578148082,
                           0.570340948863684, 2.77391452333484, 99.3851483201073, 0.312467997025662,
                           2.43754376670483, 0.558749564850011, 0.567939047357311, "1.34*",
                           0.487276731333661, 0.54919514666715, 0.367346184690901, 99.4884399140513,
                           0.00346540027258657, 1.59246141303086, -0.0520237403161038,
                           0.188477833943534, 0.53, -0.119807121225751, 0.566382967484281,
                           2.14476260304108, 99.6260889556802, 4.07387879535877e-06, 1.01509644461308,
                           0.00187642969731744, 0.00675934204166654, 1.35, 0.0279267254927512,
                           0.545628315805731, 0.0582084948793067, 96.4827931880599, 0.281259163227303,
                           0.921411371627934, -0.532239483756629, 0.137807842274185, 1.36,
                           -1.30848083410423, 0.526339426225538, 0.946292346733219, 99.4909105441175,
                           0.00955389405271385, 1.18454386801651, -0.0973450939460735,
                           0.0887315260451843, 0.54, -0.314371854017346, 0.551231971433898,
                           0.586808053235012, 98.9898760150617, 0.0793888043864291, 1.24037357964499,
                           -0.281430904456412, 0.131818937883485, 0.55, -0.719614763342714,
                           0.550998703618177, 0.544186305993934, 99.5355907412666, 0.000836244171536608,
                           1.94430926571465, -0.0257193799040055, 0.416150984764389, 1.37,
                           -0.0282210271606256, 0.555419497495948, 0.896098693716998, 99.1947522785183,
                           0.101003572393597, 1.46332683826974, 0.31769128878179, 0.291669237773938,
                           1.38, 0.49590296062427, 0.547875112290879, 0.434729782581912,
                           99.5932992335663, 0.00222123852414899, 1.12416334634063, -0.0470428032565756,
                           0.0863565954877701, 1.39, -0.153760784650784, 0.547150976176223,
                           0.200998669805516, 99.4709911091794, 0.0141641891532711, 1.59059376071144,
                           0.116329451174651, 0.228675316214048, 1.4, 0.219516701382983,
                           0.561890864585373, 1.67233787175663, 99.6101282028459, 4.89511951388839e-05,
                           1.01185503718934, 0.00696857811593593, 0.00487016624957594,
                           0.56, 0.104770077072443, 0.545521670727813, 0.0652302740895396,
                           96.6531076025142, 0.189541618700232, 1.94610324798301, 0.433241063435495,
                           0.435891090911215, 1.41, 0.497378899130929, 0.552770756780389,
                           2.43450663477824, 98.2841315594552, 0.0785785146690848, 1.65278031635436,
                           -0.276631766710734, 0.261117411159917, 0.57, -0.474535581347138,
                           0.5616521618466, 2.62984693542172, 99.2035896033499, 0.0275132006462676,
                           1.08075796463495, -0.165875278301942, 0.0838397589656111, 1.42,
                           -0.54722102961504, 0.544143615567333, 0.211417609274386, 99.6192068072974,
                           0.0205765073499802, 1.39070981141705, 0.142141673161286, 0.160393878505634,
                           0.58, 0.314036681062748, 0.557746691131937, 0.982572824775827))
})

test_that("Coefficients table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_coeffTable"]][["data"]]
  expect_equal_tables(table,
                      list(-0.572718566787404, -1.09946121080177, "intercept", 0.0330861402214251,
                           0.268751184139131, -0.0459759227730375, -2.13103644034889, -0.011344235150078,
                           -0.642469295738674, "contcor1", 0.971896648131824, 0.322008497509155,
                           0.619780825438518, -0.0352296142425729, 0.155626762050519, -0.521177801399562,
                           "contcor2", 0.652219592593599, 0.345314794472984, 0.8324313255006,
                           0.450680841196032, 0.810936822812212, -0.191857623947587, "facGender (m)",
                           0.112971369848264, 0.511639219032911, 1.81373126957201, 1.58497783720534,
                           0.264826014631206, -0.800896697966652, "facExperim (experimental)",
                           0.626230075708153, 0.543746066944277, 1.33054872722907, 0.487039871606732,
                           -0.00739141244590683, -0.49584882566078, "contcor1<unicode><unicode><unicode>contcor2",
                           0.976339429043278, 0.249217544269026, 0.481066000768966, -0.0296584755603239,
                           0.383525909051226, -0.9186749397377, "contcor1<unicode><unicode><unicode>facGender (m)",
                           0.56376979016118, 0.664400393770777, 1.68572675784015, 0.577251176620381,
                           0.275164751760064, -0.673036347314896, "contcor1<unicode><unicode><unicode>facExperim (experimental)",
                           0.569508895924281, 0.48378495850712, 1.22336585083502, 0.568774921422064,
                           -0.837947033316145, -2.60129890526181, "contcor2<unicode><unicode><unicode>facGender (m)",
                           0.351658397211503, 0.899685850432921, 0.92540483862952, -0.931377361234404,
                           -0.0547440672776936, -1.47364099110235, "contcor2<unicode><unicode><unicode>facExperim (experimental)",
                           0.939721752166373, 0.723940301364412, 1.36415285654697, -0.0756195879335869,
                           -0.956967290543106, -2.47783031693304, "facGender (m)<unicode><unicode><unicode>facExperim (experimental)",
                           0.217478311350627, 0.775964778816294, 0.56389573584683, -1.233261246732,
                           0.895878849829479, -0.299117432378454, "contcor1<unicode><unicode><unicode>contcor2<unicode><unicode><unicode>facGender (m)",
                           0.141732777207294, 0.609703181496127, 2.09087513203741, 1.46936882899498,
                           0.0123442438993629, -1.50100672553294, "contcor1<unicode><unicode><unicode>contcor2<unicode><unicode><unicode>facExperim (experimental)",
                           0.987244588052306, 0.772132026284057, 1.52569521333167, 0.0159872191272398,
                           -0.105594581512077, -1.81983877265936, "contcor1<unicode><unicode><unicode>facGender (m)<unicode><unicode><unicode>facExperim (experimental)",
                           0.903904491260768, 0.874630450960592, 1.60864960963521, -0.12073051126462,
                           0.441981212201374, -1.83832285577444, "contcor2<unicode><unicode><unicode>facGender (m)<unicode><unicode><unicode>facExperim (experimental)",
                           0.704026240849918, 1.16344181628299, 2.72228528017719, 0.379891117901739,
                           -0.591170761891612, -2.65383196042148, "contcor1<unicode><unicode><unicode>contcor2<unicode><unicode><unicode>facGender (m)<unicode><unicode><unicode>facExperim (experimental)",
                           0.574295124344442, 1.05239749597266, 1.47149043663825, -0.561737142243226
                      ))
})

test_that("Parameter Covariances table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_covMatTable"]][["data"]]
  expect_equal_tables(table,
                      list(0.0135925892343855, -0.030354391324863, 0.0303543913248631, 0.030354391324863,
                           -0.0303543913248631, -0.0135925892343855, -0.0135925892343855,
                           0.0135925892343855, 0.00155085613023708, -0.00155085613023707,
                           -0.00155085613023709, 0.00155085613023705, -0.0722271989761851,
                           -0.0722271989761851, 0.0722271989761851, 0.0722271989761851,
                           "intercept", 0.103689472468104, -0.0324857254108197, 0.0324857254108198,
                           0.0324857254108198, -0.0324857254108199, -0.103689472468104,
                           -0.103689472468104, 0.103689472468104, -0.0478536338503915,
                           0.0478536338503915, 0.0478536338503915, -0.0478536338503915,
                           -0.0135925892343854, -0.0135925892343856, 0.0135925892343855,
                           0.0135925892343855, "contcor1", -0.0478536338503915, -0.029279621587305,
                           0.0292796215873049, 0.0292796215873051, -0.0292796215873049,
                           0.0478536338503915, 0.0478536338503917, -0.0478536338503917,
                           0.119242307281919, -0.119242307281919, -0.119242307281919, 0.119242307281919,
                           -0.00155085613023713, -0.00155085613023705, 0.00155085613023709,
                           0.00155085613023708, "contcor2", -0.0135925892343856, 0.0303543913248631,
                           -0.0303543913248633, -0.153470866117865, 0.153470866117865,
                           0.0135925892343856, -0.0534785573193151, 0.0534785573193152,
                           -0.00155085613023705, 0.00155085613023687, 0.12474135270184,
                           -0.12474135270184, 0.0722271989761853, 0.261774690452607, -0.261774690452607,
                           -0.0722271989761851, "facGender (m)", -0.0135925892343854, 0.030354391324863,
                           -0.216078078653158, -0.0303543913248632, 0.216078078653158,
                           -0.00962318199687896, 0.0135925892343852, 0.00962318199687922,
                           -0.00155085613023713, -0.066597094865394, 0.00155085613023769,
                           0.0665970948653935, 0.29565978531737, 0.0722271989761853, -0.29565978531737,
                           -0.0722271989761851, "facExperim (experimental)", -0.0324857254108197,
                           0.0621093843714837, -0.0621093843714838, -0.0621093843714839,
                           0.0621093843714839, 0.0324857254108197, 0.0324857254108197,
                           -0.0324857254108197, -0.029279621587305, 0.029279621587305,
                           0.0292796215873051, -0.0292796215873051, 0.030354391324863,
                           0.0303543913248631, -0.0303543913248631, -0.030354391324863,
                           "contcor1<unicode><unicode><unicode>contcor2", -0.103689472468104, 0.0324857254108197,
                           -0.0324857254108197, -0.0390061038181272, 0.0390061038181271,
                           0.103689472468104, 0.441427883242763, -0.441427883242764, 0.0478536338503917,
                           -0.0478536338503913, -0.329079692471366, 0.329079692471366,
                           0.0135925892343852, -0.0534785573193151, 0.0534785573193155,
                           -0.0135925892343855, "contcor1<unicode><unicode><unicode>facGender (m)", -0.103689472468104,
                           0.0324857254108197, -0.086623183012083, -0.0324857254108199,
                           0.0866231830120831, 0.234047886077736, 0.103689472468104, -0.234047886077736,
                           0.0478536338503915, -0.141715989713044, -0.0478536338503914,
                           0.141715989713043, -0.00962318199687896, 0.0135925892343856,
                           0.00962318199687883, -0.0135925892343855, "contcor1<unicode><unicode><unicode>facExperim (experimental)",
                           0.0478536338503915, 0.0292796215873051, -0.0292796215873053,
                           -0.322505604097216, 0.322505604097216, -0.0478536338503914,
                           -0.329079692471366, 0.329079692471367, -0.119242307281919, 0.119242307281918,
                           0.809434629469209, -0.809434629469209, 0.00155085613023769,
                           0.12474135270184, -0.12474135270184, -0.00155085613023709, "contcor2<unicode><unicode><unicode>facGender (m)",
                           0.0478536338503915, 0.029279621587305, 0.0591596914802318, -0.0292796215873048,
                           -0.059159691480232, -0.141715989713044, -0.0478536338503913,
                           0.141715989713043, -0.119242307281919, 0.524089559939596, 0.119242307281918,
                           -0.524089559939596, -0.066597094865394, 0.00155085613023687,
                           0.0665970948653942, -0.00155085613023707, "contcor2<unicode><unicode><unicode>facExperim (experimental)",
                           0.0135925892343855, -0.0303543913248631, 0.216078078653158,
                           0.153470866117865, -0.428872615422987, 0.00962318199687883,
                           0.0534785573193155, -0.131087553796561, 0.00155085613023709,
                           0.0665970948653942, -0.12474135270184, 0.0749568287842243, -0.29565978531737,
                           -0.261774690452607, 0.60212133796342, 0.0722271989761851, "facGender (m)<unicode><unicode><unicode>facExperim (experimental)",
                           0.0324857254108198, -0.0621093843714839, 0.0621093843714841,
                           0.3717379695265, -0.3717379695265, -0.0324857254108199, -0.0390061038181272,
                           0.0390061038181273, 0.0292796215873051, -0.0292796215873048,
                           -0.322505604097216, 0.322505604097216, -0.0303543913248632,
                           -0.153470866117865, 0.153470866117865, 0.030354391324863, "contcor1<unicode><unicode><unicode>contcor2<unicode><unicode><unicode>facGender (m)",
                           0.0324857254108198, -0.0621093843714838, 0.596187866013523,
                           0.0621093843714841, -0.596187866013524, -0.086623183012083,
                           -0.0324857254108197, 0.0866231830120827, 0.0292796215873049,
                           0.0591596914802318, -0.0292796215873053, -0.0591596914802314,
                           -0.216078078653158, -0.0303543913248633, 0.216078078653158,
                           0.0303543913248631, "contcor1<unicode><unicode><unicode>contcor2<unicode><unicode><unicode>facExperim (experimental)",
                           0.103689472468104, -0.0324857254108197, 0.0866231830120827,
                           0.0390061038181273, -0.0129567418193662, -0.234047886077736,
                           -0.441427883242764, 0.764978425747528, -0.0478536338503917,
                           0.141715989713043, 0.329079692471367, -0.506301910727773, 0.00962318199687922,
                           0.0534785573193152, -0.131087553796561, 0.0135925892343855,
                           "contcor1:facGender (m)<unicode><unicode><unicode>facExperim (experimental)", -0.0478536338503915,
                           -0.0292796215873051, -0.0591596914802314, 0.322505604097216,
                           -0.219580324628296, 0.141715989713043, 0.329079692471366, -0.506301910727773,
                           0.119242307281919, -0.524089559939596, -0.809434629469209, 1.35359685987586,
                           0.0665970948653935, -0.12474135270184, 0.0749568287842243, 0.00155085613023705,
                           "contcor2:facGender (m)<unicode><unicode><unicode>facExperim (experimental)", -0.0324857254108199,
                           0.0621093843714839, -0.596187866013524, -0.3717379695265, 1.10754048952954,
                           0.0866231830120831, 0.0390061038181271, -0.0129567418193662,
                           -0.0292796215873049, -0.059159691480232, 0.322505604097216,
                           -0.219580324628296, 0.216078078653158, 0.153470866117865, -0.428872615422987,
                           -0.0303543913248631, "contcor1<unicode><unicode><unicode>contcor2<unicode><unicode><unicode>facGender (m)<unicode><unicode><unicode>facExperim (experimental)"
                      ))
})

test_that("File Drawer Analysis table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_failSafeTable"]][["data"]]
  expect_equal_tables(table,
                      list(0.05, 0, "Rosenthal", 0.0813278786958635))
})

test_that("Fixed and Random Effects table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_fixRandTable"]][["data"]]
  expect_equal_tables(table,
                      list(15, "Omnibus test of Model Coefficients", 0.216907507488967, 18.9303488095121,
                           84, "Test of Residual Heterogeneity", 0.117156071611725, 99.6347772817611
                      ))
})

test_that("Diagnostic Plots matches - model interactions", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_diagnosticPlot"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "diagnostic-plots-model")
})

test_that("Forest plot matches - model interactions", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_forest"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "forest-plot-model")
})

test_that("Funnel Plot matches - model interactions", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_funnel"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "funnel-plot-model")
})

test_that("Profile plot matches - model interactions", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_profile"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "profile-model")
})

test_that("Trim-fill Analysis plot matches - model interactions", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_trimFill"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "trim-fill-analysis-model")
})

test_that("Regression test for Funnel plot asymmetry (\"Egger's test\") table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_regTestTable"]][["data"]]
  expect_equal_tables(table,
                      list("sei", 0.794904131826642, -0.259947679937865))
})

test_that("Residual Heterogeneity Estimates table results match - model interactions", {
  table <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_residualTable"]][["data"]]
  expect_equal_tables(table,
                      list(0.544954299586419, 0, "<unicode><unicode><unicode><unicode>",
                           0.24418480479452, 0.738210200137074, 0, "<unicode><unicode>",
                           0.494150589187668, 34.1721304558822, 0, "I<unicode><unicode> (%)",
                           18.8710710587465, 1.51911341947623, 1, "H<unicode><unicode>",
                           1.23260594346576))
})


# test the diagnostic plot without the Q-Q plot
options <- jaspTools::analysisOptions("ClassicalMetaAnalysis")
options$.meta <- list(covariates = list(containsColumn = TRUE), effectSize = list(
  containsColumn = TRUE), factors = list(containsColumn = TRUE),
  studyLabel = list(containsColumn = TRUE), effectSizeSe = list(
    containsColumn = TRUE))
options$effectSize <- "ES"
options$method <- "Fixed Effects"
options$diagnosticPlot <- TRUE
options$diagnosticQqPlot <- FALSE
options$coefficientEstimate <- FALSE
options$residualParameter <- FALSE
options$effectSizeSe <- "SE"
options$funnelPlot <- TRUE

options$coefficientCiLevel <- .95
options$estimateTest <- "z"
options$fitMeasure <- TRUE
options$covarianceMatrix <- TRUE
options$funnelPlotRankTestAsymmetry <- TRUE
options$funnelPlotRegressionTestAsymmetry <- FALSE
options$casewiseDiagnostics <- TRUE
options$failSafeN <- FALSE
options$forestPlot <- FALSE
options$profilePlot <- FALSE
options$trimFillAnalysis <- FALSE

set.seed(1)
results <- jaspTools::runAnalysis("ClassicalMetaAnalysis", "BCG Vaccine", options)

test_that("Diagnostic Plots matches without Q-Q plot", {
  plotName <- results[["results"]][["modelContainer"]][["collection"]][["modelContainer_plots"]][["collection"]][["modelContainer_plots_diagnosticPlot"]][["data"]]
  testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]]
  expect_equal_plots(testPlot, "diagnostic-plots-no-qq")
})
jasp-stats/jaspMetaAnalysis documentation built on April 5, 2025, 4:03 p.m.