Skip to content

Commit

Permalink
fixed unit-tests part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
vandenman committed Mar 28, 2019
1 parent 571bec1 commit 7095248
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 80 deletions.
39 changes: 20 additions & 19 deletions JASP-Tests/R/tests/testthat/test-ancovabayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ context("Bayesian ANCOVA")

initOpts <- function() {
options <- jasptools::analysisOptions("AncovaBayesian")
options$sampleMode <- "manual"
options$fixedSamplesNumber <- 50
options$sampleModeNumAcc <- "manual"
options$fixedNumAcc <- 50
return(options)
}

Expand All @@ -28,17 +28,18 @@ test_that("Main table results match", {
)

refTables <- list(
nullModelTop = list(2.0810402340829, 3.45565802495949, "facGender", 0.25, 0.535291369462089,
2.54299550940088, 1, 1.03889716184925, "Null model (incl. facFive)",
0.25, 0.257222979496111, 0.554492327691682, 0.499065271632886,
"facGender + contGamma", 0.25, 0.142628168636589, 1.52356717742169,
0.252144977607616, 0.208067159341743, "contGamma", 0.25, 0.0648574824052112,
1.09719511907165),
bestModelTop = list(1, 3.1778383618232, "facGender", 0.25, 0.514393251442299, 0.512506394916977,
1.07403793058239, "Null model (incl. facFive)", 0.25, 0.263629830866315,
1.45815184582002, 0.290516285547582, 0.527086446737985, "facGender + contGamma",
0.25, 0.14943961671976, 2.72502064669284, 0.141015265593473,
0.234631433849418, "contGamma", 0.25, 0.0725373009716262, 7.06028559007371)
nullModelTop = list(1.83701195521646, 3.11340404608183, "facGender", 0.25, 0.509275032798994,
29.6656710072444, 1, 1.15069866070698, "Null model (incl. facFive)",
0.25, 0.277230113474675, "", 0.502295526791326, 0.485338413495893,
"facGender + contGamma", 0.25, 0.139251445890181, 9.83211717425022,
0.267804268827858, 0.24059264108273, "contGamma", 0.25, 0.0742434078361496,
15.885810482332),
bestModelTop = list(1, 3.52818212286609, "facGender", 0.25, 0.540453997217391, "",
0.485506904639836, 1.0672128467728, "Null model (incl. facFive)",
0.25, 0.262394147289242, 10.5414217188718, 0.230284849014787,
0.426450425012883, "facGender + contGamma", 0.25, 0.124458367148645,
14.932174588461, 0.134504488298719, 0.235176246789085, "contGamma",
0.25, 0.0726934883447225, 15.235554204653)
)

for (order in c("nullModelTop", "bestModelTop")) {
Expand All @@ -63,12 +64,12 @@ test_that("Effects table results match", {
)

refTables <- list(
allModels = list(0.194541140104503, "contGamma", 0.6, 0.22589337738806, 0.215301593138521,
"contBinom", 0.6, 0.244114899538536, 0.139109048927543, "contGamma<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>contBinom",
0.2, 0.033608452273947),
matchedModels = list(0.2488203279531, "contGamma", 0.4, 0.192486007853074, 0.278924648376759,
"contBinom", 0.4, 0.210695472488687, 0.777915623551311, "contGamma<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>contBinom",
0.2, 0.0339196100618932)
allModels = list(0.195147508378383, "contGamma", 0.6, 0.226438035053418, 0.215922578651088,
"contBinom", 0.6, 0.24464673662928, 0.148059370442442, "contGamma<unicode><unicode><unicode>contBinom",
0.2, 0.0356936478531284),
matchedModels = list(0.251463756140854, "contGamma", 0.4, 0.193766080181002, 0.281631799589675,
"contBinom", 0.4, 0.211903947712592, 0.784742840790345, "contGamma<unicode><unicode><unicode>contBinom",
0.2, 0.0356812041725068)
)

for (effectsType in c("allModels", "matchedModels")) {
Expand Down
45 changes: 23 additions & 22 deletions JASP-Tests/R/tests/testthat/test-anovabayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ context("Bayesian ANOVA")

initOpts <- function() {
options <- jasptools::analysisOptions("AnovaBayesian")
options$sampleMode <- "manual"
options$fixedSamplesNumber <- 50
options$sampleModeNumAcc <- "manual"
options$fixedNumAcc <- 50
return(options)
}

Expand All @@ -28,20 +28,21 @@ test_that("Main table results match", {
)

refTables <- list(
nullModelTop = list(2.03396231183419, 4.36594897914025, "facGender", 0.2, 0.521871337014648,
0.969106320600043, 1, 1.38052893828542, "Null model (incl. facExperim)",
0.2, 0.256578666172056, 0.432501410293758, 0.499288951910149,
"facGender + facFive", 0.2, 0.110970634970706, 1.41647769133671,
0.21724304954363, 0.236121101672541, "facGender + facFive + facGender<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facFive",
0.2, 0.0557399318870544, 1.83775875304445, 0.213733397143635,
0.232085136403676, "facFive", 0.2, 0.0548394299555363, 1.04177436451923),
bestModelTop = list(1, 4.18686558133661, "facGender", 0.2, 0.511412522868496, 0.510943003733483,
1.41493752908138, "Null model (incl. facExperim)", 0.2, 0.261302650581348,
2.3021061884882, 0.223966148027088, 0.517421342346211, "facGender + facFive",
0.2, 0.114539092799672, 4.15307380646848, 0.111744890960883,
0.242446197872535, "facFive", 0.2, 0.0571477366039704, 2.59068727917517,
0.108714579053848, 0.235484452504449, "facGender + facFive + facGender<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facFive",
0.2, 0.0555979971465146, 3.03025679917061)
nullModelTop = list(2.02979323789675, 4.26708821602261, "facGender", 0.2, 0.5161537054549,
13.7355911669483, 1, 1.36400693663762, "Null model (incl. facExperim)",
0.2, 0.254288809233464, "", 0.395602125048142, 0.447395505374489,
"facGender + facFive", 0.2, 0.10059719330872, 9.31843477414318,
0.283048448817154, 0.310233602217543, "facGender + facFive + facGender<unicode><unicode><unicode>facFive",
0.2, 0.0719760530050931, 27.3699066120891, 0.224092594438576,
0.241710653647034, "facFive", 0.2, 0.0569842389978229, 12.4382643482552),
bestModelTop = list(1, 5.89338824855042, "facGender", 0.2, 0.595689575754183, "",
0.387257922203485, 1.19943409151523, "Null model (incl. facExperim)",
0.2, 0.230685507384841, 20.3818205689193, 0.144085444036832,
0.375554724086775, "facGender + facFive", 0.2, 0.0858301970306536,
21.4710504386786, 0.0777010838721742, 0.194128270632499, "facFive",
0.2, 0.0462857256874556, 21.0528996183454, 0.0696822570553021,
0.173226431502077, "facGender + facFive + facGender<unicode><unicode><unicode>facFive",
0.2, 0.0415089941428668, 21.7314934303167)
)

for (order in c("nullModelTop", "bestModelTop")) {
Expand All @@ -65,12 +66,12 @@ test_that("Effects table results match", {
)

refTables <- list(
allModels = list(0.101833665496691, "facFive", 0.6, 0.132509592038855, 0.184940107557576,
"contBinom", 0.6, 0.217166083167955, 0.0176366361186621, "facFive<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>contBinom",
0.2, 0.0043898036871001),
matchedModels = list(0.146995523754444, "facFive", 0.4, 0.127601379108464, 0.271032837792626,
"contBinom", 0.4, 0.2123137507459, 0.174704371549221, "facFive<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>contBinom",
0.2, 0.00433559523354601)
allModels = list(0.099907027453377, "facFive", 0.6, 0.130329318915725, 0.182805120830185,
"contBinom", 0.6, 0.215198578129191, 0.0164190701020927, "facFive<unicode><unicode><unicode>contBinom",
0.2, 0.0040879872880584),
matchedModels = list(0.144492921488286, "facFive", 0.4, 0.125726268310479, 0.268259601459664,
"contBinom", 0.4, 0.210639434646253, 0.182973144016417, "facFive<unicode><unicode><unicode>contBinom",
0.2, 0.00415312636511842)
)

for (effectsType in c("allModels", "matchedModels")) {
Expand Down
80 changes: 41 additions & 39 deletions JASP-Tests/R/tests/testthat/test-anovarepeatedmeasuresbayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ context("Bayesian Repeated Measures ANOVA")

initOpts <- function() {
options <- jasptools::analysisOptions("AnovaRepeatedMeasuresBayesian")
options$sampleMode <- "manual"
options$fixedSamplesNumber <- 50
options$sampleModeNumAcc <- "manual"
options$fixedNumAcc <- 50
return(options)
}

Expand All @@ -32,37 +32,39 @@ test_that("Main table results match", {
options$priorRandomEffects <- 0.8

refTables <- list(
nullModelTop = list(3.62496733116162e+23, 5.73145848262438, "RM Factor 1 + facGender",
0.1, 0.389062528288327, 1.72433512753681, 3.46448419993762e+23,
5.32751662817302, "RM Factor 1", 0.1, 0.37183810470666, 3.74201005842137,
8.9411204428442e+22, 0.955353109807862, "RM Factor 1 + facGender + contcor1",
0.1, 0.0959637593232787, 16.4218696956561, 6.81640452356858e+22,
0.710408526266743, "RM Factor 1 + contcor1", 0.1, 0.0731594890518848,
4.65091229160849, 5.48567012520599e+22, 0.5630423677071, "RM Factor 1 + facGender + RM Factor 1<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facGender",
0.1, 0.0588769082115965, 8.02076448534254, 1.03413390502686e+22,
0.101014070184426, "RM Factor 1 + facGender + contcor1 + RM Factor 1<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facGender",
0.1, 0.0110992104182495, 4.18450741833095, 1, 9.65957051390276e-24,
"Null model (incl. subject)", 0.1, 1.07328561265586e-24, 0.449149895733824,
4.33859508915294e-24, "facGender", 0.1, 4.82066121016992e-25,
3.63958095837114, 0.199117747695815, 1.92339192443722e-24, "contcor1",
0.1, 2.13710213826357e-25, 2.50946236929854, 0.0827555999423614,
7.99383553063569e-25, "facGender + contcor1", 0.1, 8.88203947848407e-26,
1.53533237565983),
bestModelTop = list(1, 6.50874645747621, "RM Factor 1 + facGender", 0.1, 0.419682304777031,
0.836215528978976, 4.86631035203809, "RM Factor 1", 0.1, 0.350944860492241,
1.97072663295012, 0.215841804977564, 0.896471757374706, "RM Factor 1 + facGender + contcor1",
0.1, 0.0905849861802185, 6.6431450159699, 0.170299127246734,
0.692756111371905, "RM Factor 1 + contcor1", 0.1, 0.071471530224426,
2.19671475265757, 0.133248845838306, 0.533112456797527, "RM Factor 1 + facGender + RM Factor 1<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facGender",
0.1, 0.0559221827302997, 2.962819662002, 0.0271494305718735,
0.103729124066941, "RM Factor 1 + facGender + contcor1 + RM Factor 1<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facGender",
0.1, 0.0113941355957878, 4.60008794602492, 2.70717632857682e-24,
1.02253860091345e-23, "Null model (incl. subject)", 0.1, 1.13615400101494e-24,
1.77842089287593, 1.18358526138156e-24, 4.47056811357066e-24,
"facGender", 0.1, 4.96729790396738e-25, 2.11365788695685, 5.27151495518567e-25,
1.99112539145302e-24, "contcor1", 0.1, 2.21236154605891e-25,
2.06808792667175, 2.66915441617695e-25, 1.00817718946824e-24,
"facGender + contcor1", 0.1, 1.12019687718693e-25, 13.9884843562539)
nullModelTop = list(3.47351082631419e+23, 7.78290269354818, "RM Factor 1 + facGender",
0.1, 0.463739964156508, 9.48562551500826, 2.25207823390771e+23,
3.86945112370334, "RM Factor 1", 0.1, 0.300669475839298, 39.106368292494,
6.71141299730886e+22, 0.885790984667994, "RM Factor 1 + contcor1",
0.1, 0.0896024391009056, 12.887989220175, 5.74376683392463e+22,
0.74747150859863, "RM Factor 1 + facGender + contcor1", 0.1,
0.0766836310256722, 15.7870140533192, 4.50189687402267e+22,
0.575524732870682, "RM Factor 1 + facGender + RM Factor 1<unicode><unicode><unicode>facGender",
0.1, 0.0601037278818813, 12.5735601755857, 6.89156615187532e+21,
0.0835758191825197, "RM Factor 1 + facGender + contcor1 + RM Factor 1<unicode><unicode><unicode>facGender",
0.1, 0.00920076199573587, 11.0628049253349, 1, 1.2015680635829e-23,
"Null model (incl. subject)", 0.1, 1.33507562620322e-24, "",
0.41104359340273, 4.93896854573074e-24, "facGender", 0.1, 5.4877428285897e-25,
7.7632364395313, 0.23874600738579, 2.86869577782693e-24, "contcor1",
0.1, 3.18743975314103e-25, 16.2455760987563, 0.0921852605167578,
1.10766864970006e-24, "facGender + contcor1", 0.1, 1.23074294411118e-25,
13.7488070754201),
bestModelTop = list(1, 6.76784490026738, "RM Factor 1 + facGender", 0.1, 0.429218129875987,
"", 0.812461183408298, 4.81900629644283, "RM Factor 1", 0.1,
0.348723069739341, 11.0954981789983, 0.23781134935476, 1.02308586890581,
"RM Factor 1 + facGender + contcor1", 0.1, 0.102072942633335,
32.3366579475681, 0.192584660287367, 0.810984063552273, "RM Factor 1 + contcor1",
0.1, 0.0826608277313462, 19.6531747475726, 0.0565717639157407,
0.223973070906526, "RM Factor 1 + facGender + RM Factor 1<unicode><unicode><unicode>facGender",
0.1, 0.0242816267117001, 57.5970296697693, 0.0303887520130162,
0.118942038756438, "RM Factor 1 + facGender + contcor1 + RM Factor 1<unicode><unicode><unicode>facGender",
0.1, 0.013043403308292, 18.7536418861197, 2.8910010651933e-24,
1.11678306360458e-23, "Null model (incl. subject)", 0.1, 1.24087007067176e-24,
10.0789044176123, 1.2418397001326e-24, 4.79718102327006e-24,
"facGender", 0.1, 5.33020113696672e-25, 11.1219692156722, 5.61029992468607e-25,
2.16723819754544e-24, "contcor1", 0.1, 2.40804244171715e-25,
12.5004991737756, 2.26151580646109e-25, 8.73615226620796e-25,
"facGender + contcor1", 0.1, 9.70683585134215e-26, 15.8888961021958)
)

for (order in c("nullModelTop", "bestModelTop")) {
Expand All @@ -88,12 +90,12 @@ test_that("Effects table results match", {
options$effects <- TRUE

refTables <- list(
allModels = list(1501199875790165, "RM Factor 1", 0.6, 1, 1.23554633080451, "facGender",
0.6, 0.649531010694943, 0.541809634931422, "RM Factor 1<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facGender",
0.2, 0.11929377901802),
matchedModels = list(7.95624688797966e+23, "RM Factor 1", 0.4, 0.88070622098198, 1.51293623075847,
"facGender", 0.4, 0.530237231676923, 0.224981898462208, "RM Factor 1<unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode><unicode>facGender",
0.2, 0.11929377901802)
allModels = list(1000799917193443, "RM Factor 1", 0.6, 0.999999999999999, 2.08122183080565,
"facGender", 0.6, 0.757389476581779, 0.343504623304608, "RM Factor 1<unicode><unicode><unicode>facGender",
0.2, 0.0790846685097493),
matchedModels = list(1.02806369879075e+24, "RM Factor 1", 0.4, 0.92091533149025, 2.79585896982196,
"facGender", 0.4, 0.67830480807203, 0.116591637813293, "RM Factor 1<unicode><unicode><unicode>facGender",
0.2, 0.0790846685097493)
)

effectsTypes <- c("allModels", "matchedModels")
Expand Down

0 comments on commit 7095248

Please sign in to comment.