R Under development (unstable) (2019-06-28 r76750) -- "Unsuffered Consequences" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "BayesSingleSub" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('BayesSingleSub') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("BayesSingleSub-package") > ### * BayesSingleSub-package > > flush(stderr()); flush(stdout()) > > ### Name: BayesSingleSub-package > ### Title: Functions to obtain Bayes factor hypothesis tests and posterior > ### samples of parameters for single case data. > ### Aliases: BayesSingleSub-package BayesSingleSub > ### Keywords: htest > > ### ** Examples > > ## See specific functions for examples > > > > cleanEx() > nameEx("trendtest.Gibbs.AR") > ### * trendtest.Gibbs.AR > > flush(stderr()); flush(stdout()) > > ### Name: trendtest.Gibbs.AR > ### Title: Obtain Bayesian trend test and posterior distributions for > ### single case data > ### Aliases: trendtest.Gibbs.AR > ### Keywords: htest models > > ### ** Examples > > ## Define data > data = c(87.5, 82.5, 53.4, 72.3, 94.2, 96.6, 57.4, 78.1, 47.2, + 80.7, 82.1, 73.7, 49.3, 79.3, 73.3, 57.3, 31.7, 50.4, 77.8, + 67, 40.5, 1.6, 38.6, 3.2, 24.1) > > ## Obtain log Bayes factors > logBFs = trendtest.Gibbs.AR(data[1:10], data[11:25]) | | | 0%trendAR.c:104:10: runtime error: variable length array bound evaluates to non-positive value 0 #0 0x7f44c117111f in gibbsTwoSampleAR_trend /data/gannet/ripley/R/packages/tests-gcc-SAN/BayesSingleSub/src/trendAR.c:104 #1 0x7f44c1188c3e in RgibbsTwoSampleAR_trend /data/gannet/ripley/R/packages/tests-gcc-SAN/BayesSingleSub/src/trendAR.c:412 #2 0x56b5ae in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:684 #3 0x575a5b in do_dotcall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:1252 #4 0x618854 in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:6775 #5 0x64660f in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:620 #6 0x64bd15 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1780 #7 0x64e308 in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1706 #8 0x646b13 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:743 #9 0x653061 in do_set /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2808 #10 0x647199 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:695 #11 0x6c0f8e in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:260 #12 0x6c0f8e in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:200 #13 0x6c1640 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:310 #14 0x6c1774 in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1108 #15 0x4181a8 in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29 #16 0x7f44d23e911a in __libc_start_main (/lib64/libc.so.6+0x2311a) #17 0x41a8d9 in _start (/data/gannet/ripley/R/gcc-SAN/bin/exec/R+0x41a8d9) | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100% rho acceptance rate: 0.3363363 > > ## Obtain log Bayes factors, chains, and log interval null Bayes factors > output = trendtest.Gibbs.AR(data[1:10], data[11:25], + return.chains = TRUE, intArea = c(-0.2,0.2), + slpArea = c(-0.2, 0.2)) | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100% rho acceptance rate: 0.3053053 > > ## Look at the posterior distribution of the mean > plot(output$chains[,1]) > > ## Obtain summary statistics of posterior distributions > summary(output$chains) Iterations = 1:1000 Thinning interval = 1 Number of chains = 1 Sample size per chain = 1000 1. Empirical mean and standard deviation for each variable, plus standard error of the mean: Mean SD Naive SE Time-series SE mu0 75.5736 9.1051 0.287930 0.28793 sig*delta 8.3061 13.2602 0.419324 0.47279 beta0 -2.5159 1.0754 0.034007 0.03790 sig*beta1 -3.0918 2.6444 0.083624 0.08780 sig2 352.5117 114.0723 3.607282 4.66151 g1 5.3231 24.9215 0.788088 0.78809 g2 2.7065 9.0609 0.286530 0.28653 rho 0.1454 0.1141 0.003608 0.01069 2. Quantiles for each variable: 2.5% 25% 50% 75% 97.5% mu0 56.865414 6.967e+01 75.1924 81.4122 94.0082 sig*delta -16.239932 -3.485e-04 7.5137 16.5441 35.9543 beta0 -4.660557 -3.220e+00 -2.4884 -1.8214 -0.5019 sig*beta1 -8.570379 -4.736e+00 -2.9982 -1.3467 1.9295 sig2 200.360034 2.721e+02 330.0167 406.1538 632.9479 g1 0.163874 5.010e-01 1.1181 2.6421 36.6357 g2 0.131828 3.792e-01 0.7593 1.6828 20.0028 rho 0.004824 5.544e-02 0.1312 0.2104 0.4253 > > > > cleanEx() > nameEx("trendtest.MC.AR") > ### * trendtest.MC.AR > > flush(stderr()); flush(stdout()) > > ### Name: trendtest.MC.AR > ### Title: Obtain Bayesian trend test or single case data > ### Aliases: trendtest.MC.AR > ### Keywords: htest models > > ### ** Examples > > ## Define data > data = c(87.5, 82.5, 53.4, 72.3, 94.2, 96.6, 57.4, 78.1, 47.2, + 80.7, 82.1, 73.7, 49.3, 79.3, 73.3, 57.3, 31.7, 50.4, 77.8, + 67, 40.5, 1.6, 38.6, 3.2, 24.1) > > ## Obtain log Bayes factors > logBFs = trendtest.MC.AR(data[1:10], data[11:25]) | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100% > > > > cleanEx() > nameEx("ttest.Gibbs.AR") > ### * ttest.Gibbs.AR > > flush(stderr()); flush(stdout()) > > ### Name: ttest.Gibbs.AR > ### Title: Obtain Bayesian t test and posterior distributions for single > ### case data > ### Aliases: ttest.Gibbs.AR > ### Keywords: htest models > > ### ** Examples > > ## Define data > data = c(87.5, 82.5, 53.4, 72.3, 94.2, 96.6, 57.4, 78.1, 47.2, + 80.7, 82.1, 73.7, 49.3, 79.3, 73.3, 57.3, 31.7, 50.4, 77.8, + 67, 40.5, 1.6, 38.6, 3.2, 24.1) > > ## Obtain log Bayes factor > logBF = ttest.Gibbs.AR(data[1:10], data[11:25]) | | | 0%notrendAR.c:248:10: runtime error: variable length array bound evaluates to non-positive value 0 #0 0x7f44c11709d5 in gibbsTwoSampleAR /data/gannet/ripley/R/packages/tests-gcc-SAN/BayesSingleSub/src/notrendAR.c:248 #1 0x7f44c117c5dd in RgibbsTwoSampleAR /data/gannet/ripley/R/packages/tests-gcc-SAN/BayesSingleSub/src/notrendAR.c:417 #2 0x56bad3 in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:655 #3 0x575a5b in do_dotcall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:1252 #4 0x618854 in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:6775 #5 0x64660f in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:620 #6 0x64bd15 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1780 #7 0x64e308 in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1706 #8 0x646b13 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:743 #9 0x653061 in do_set /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2808 #10 0x647199 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:695 #11 0x6c0f8e in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:260 #12 0x6c0f8e in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:200 #13 0x6c1640 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:310 #14 0x6c1774 in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1108 #15 0x4181a8 in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29 #16 0x7f44d23e911a in __libc_start_main (/lib64/libc.so.6+0x2311a) #17 0x41a8d9 in _start (/data/gannet/ripley/R/gcc-SAN/bin/exec/R+0x41a8d9) | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100% rho acceptance rate: 0.4984985 > > ## Obtain log Bayes factor, chains, and log interval null Bayes factor > output = ttest.Gibbs.AR(data[1:10], data[11:25], return.chains = TRUE, areaNull = c(-0.2, 0.2)) | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100% rho acceptance rate: 0.4824825 > > ## Look at the posterior distribution of the mean > plot(output$chains[,1]) > > ## Obtain summary statistics of posterior distributions > summary(output$chains) Iterations = 1:1000 Thinning interval = 1 Number of chains = 1 Sample size per chain = 1000 1. Empirical mean and standard deviation for each variable, plus standard error of the mean: Mean SD Naive SE Time-series SE mu0 61.8917 6.8475 0.216538 0.21654 delta -0.8323 0.5301 0.016764 0.02112 sig2 535.9543 170.1330 5.380078 5.82518 g 10.0421 91.2572 2.885804 2.88580 rho 0.2734 0.1452 0.004592 0.00900 2. Quantiles for each variable: 2.5% 25% 50% 75% 97.5% mu0 48.29719 57.4547 61.8072 66.3148 74.7035 delta -1.89151 -1.1962 -0.8288 -0.4705 0.1486 sig2 300.35382 413.4488 510.6319 615.4352 959.0117 g 0.20008 0.6278 1.3591 3.5755 39.4879 rho 0.01859 0.1641 0.2611 0.3811 0.5532 > > > > cleanEx() > nameEx("ttest.MCGQ.AR") > ### * ttest.MCGQ.AR > > flush(stderr()); flush(stdout()) > > ### Name: ttest.MCGQ.AR > ### Title: Obtain Bayesian t test for single case data > ### Aliases: ttest.MCGQ.AR > ### Keywords: htest models > > ### ** Examples > > ## Define data > data = c(87.5, 82.5, 53.4, 72.3, 94.2, 96.6, 57.4, 78.1, 47.2, + 80.7, 82.1, 73.7, 49.3, 79.3, 73.3, 57.3, 31.7, 50.4, 77.8, + 67, 40.5, 1.6, 38.6, 3.2, 24.1) > > ## Obtain log Bayes factor > logBF = ttest.MCGQ.AR(data[1:10], data[11:25]) > > > > ### *