R Under development (unstable) (2023-12-04 r85659 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. 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. > library(bfp) > > ## setting > > beta0 <- 1 > alpha1 <- 1 > alpha2 <- 3 > delta1 <- 1 > > sigma <- 2 # sigma2 = 4 > n <- 15 > k <- 2L > > ## simulate data > > set.seed (123) > > x <- matrix (runif (n * k, 1, 4), nrow = n, ncol = k) # predictor values > w <- matrix (rbinom (n * 1, size = 1, prob = 0.5), nrow = n, ncol = 1) > > x1tr <- alpha1 * x[,1]^2 > x2tr <- alpha2 * (x[,2])^(1/2) > w1tr <- delta1 * w[,1] > > predictorTerms <- + x1tr + + x2tr + + w1tr > > trueModel <- list (powers = list (x1 = 2, x2 = 0.5), + ucTerms = as.integer (1) + ) > > covariateData <- data.frame (x1 = x[,1], + x2 = x[,2], + w = w) > > covariateData$y <- predictorTerms + rnorm (n, 0, sigma) > covariateData x1 x2 w y 1 1.862733 3.699475 1 8.068580 2 3.364915 1.738263 1 16.107105 3 2.226931 1.126179 1 11.284089 4 3.649052 1.983762 1 18.250178 5 3.821402 3.863511 0 18.168767 6 1.136669 3.668618 0 5.401077 7 2.584316 3.078410 1 14.312183 8 3.677257 2.921520 0 18.009844 9 2.654305 3.982809 0 10.409384 10 2.369844 2.967117 0 9.584542 11 3.870500 3.125591 0 20.025752 12 2.360002 2.632198 0 12.210299 13 3.032712 2.782426 0 13.898731 14 2.717900 1.867479 0 12.146236 15 1.308774 1.441341 0 -1.140080 > > exhaustive <- BayesMfp (y ~ bfp (x1, max=1) + bfp(x2, max=1), + data = covariateData, + priorSpecs = + list (a = 3.5, + modelPrior="flat"), + method = "exhaustive", + nModels = 100 + ) Starting with computation of every model... 0%______________________________________________________________________________________________100% --------------------------------------------------------------------------------- Actual number of possible models: 81 Number of non-identifiable models: 0 Number of saved possible models: 81 > attr(exhaustive, "logNormConst") [1] 12.04616 > summary(exhaustive) ------------------------------ BayesMfp-Output ------------------------------ Original call: BayesMfp(formula = y ~ bfp(x1, max = 1) + bfp(x2, max = 1), data = covariateData, priorSpecs = list(a = 3.5, modelPrior = "flat"), method = "exhaustive", nModels = 100) 81 multivariable fractional polynomial model(s) of total (visited/cached)81 for following covariates: fixed: (Intercept) uncertain fixed form: fractional polynomial: shift scale maxDegree cardPowerset x1 0 1 1 8 x2 0 1 1 8 Distribution of posterior probabilities: normalized frequency Min. :3.520e-06 Min. :2.147e+09 1st Qu.:8.698e-04 1st Qu.:2.147e+09 Median :4.529e-03 Median :2.147e+09 Mean :1.235e-02 Mean :2.147e+09 3rd Qu.:2.033e-02 3rd Qu.:2.147e+09 Max. :1.317e-01 Max. :2.147e+09 Overall inclusion probabilities for covariates in question: x1 x2 0.9999630 0.6337539 Inclusion probabilities for covariates in question for this model selection: x1 x2 0.9999630 0.6337539 Overview: posterior logMargLik logPrior postExpectedg postExpectedShrinkage 1 1.316673e-01 -33.01089 0 177.014280 0.9660069 2 1.147544e-01 -33.14837 0 172.127635 0.9650484 3 6.891219e-02 -33.65833 0 154.984283 0.9612121 4 2.912484e-02 -34.51957 0 57.015785 0.9503560 5 2.894184e-02 -34.52588 0 56.934522 0.9502866 6 2.877918e-02 -34.53151 0 56.861938 0.9502244 7 2.832026e-02 -34.54759 0 56.655348 0.9500465 8 2.793634e-02 -34.56124 0 56.480423 0.9498949 9 2.639891e-02 -34.61784 0 55.759777 0.9492606 10 2.543902e-02 -34.65488 0 55.292404 0.9488406 11 2.447073e-02 -34.69369 0 54.806220 0.9483963 12 2.362256e-02 -34.72896 0 54.367358 0.9479886 13 2.343527e-02 -34.73692 0 54.268730 0.9478961 14 2.343286e-02 -34.73703 0 54.267458 0.9478949 15 2.294658e-02 -34.75800 0 54.008347 0.9476502 16 2.288135e-02 -34.76084 0 53.973251 0.9476169 17 2.158060e-02 -34.81937 0 53.255884 0.9469267 18 2.116644e-02 -34.83875 0 53.020117 0.9466958 19 2.088324e-02 -34.85222 0 120.293438 0.9501499 20 2.065810e-02 -34.86306 0 120.010068 0.9500336 21 2.033069e-02 -34.87903 0 52.532730 0.9462123 22 1.740258e-02 -35.03455 0 50.685697 0.9442976 23 1.725509e-02 -35.04306 0 50.586171 0.9441905 24 1.724016e-02 -35.04392 0 50.576059 0.9441796 25 1.685224e-02 -35.06668 0 50.310759 0.9438922 26 1.677742e-02 -35.07113 0 50.259019 0.9438358 27 1.564022e-02 -35.14132 0 49.448639 0.9429375 28 1.530044e-02 -35.16328 0 49.197238 0.9426530 29 1.439532e-02 -35.22426 0 48.504744 0.9418545 30 6.100135e-03 -36.08285 0 39.554905 0.9291147 31 6.095732e-03 -36.08358 0 39.547972 0.9291027 32 6.010559e-03 -36.09765 0 39.413044 0.9288681 33 5.992434e-03 -36.10067 0 39.384132 0.9288176 34 5.848305e-03 -36.12501 0 39.151656 0.9284092 35 5.567020e-03 -36.17430 0 38.684221 0.9275737 36 5.417654e-03 -36.20150 0 38.428164 0.9271078 37 5.297403e-03 -36.22395 0 88.319723 0.9324439 38 4.991409e-03 -36.28345 0 37.664539 0.9256825 39 4.563443e-03 -36.37309 0 36.842569 0.9240853 40 4.547613e-03 -36.37656 0 36.810984 0.9240226 41 4.529485e-03 -36.38056 0 36.774704 0.9239504 42 4.489914e-03 -36.38933 0 36.695098 0.9237916 43 4.407844e-03 -36.40778 0 36.528163 0.9234563 44 4.352481e-03 -36.42042 0 36.414119 0.9232256 45 4.242517e-03 -36.44601 0 36.184065 0.9227560 46 4.143141e-03 -36.46971 0 35.971957 0.9223179 47 3.526959e-03 -36.63073 0 80.196740 0.9257735 48 1.844125e-03 -37.27916 0 29.267119 0.9054076 49 1.835821e-03 -37.28367 0 29.232517 0.9053015 50 1.825920e-03 -37.28908 0 29.191097 0.9051743 51 1.785193e-03 -37.31164 0 29.018761 0.9046413 52 1.748528e-03 -37.33239 0 28.860862 0.9041478 53 1.728964e-03 -37.34364 0 28.775501 0.9038789 54 1.599126e-03 -37.42171 0 28.188219 0.9019881 55 1.479201e-03 -37.49966 0 27.610277 0.9000549 56 9.052050e-04 -37.99076 0 24.157026 0.8867523 57 9.033896e-04 -37.99277 0 24.143550 0.8866937 58 8.949747e-04 -38.00212 0 24.080800 0.8864197 59 8.884933e-04 -38.00939 0 24.032140 0.8862064 60 8.826477e-04 -38.01599 0 23.988005 0.8860123 61 8.697623e-04 -38.03070 0 23.889874 0.8855783 62 8.523420e-04 -38.05093 0 23.755309 0.8849780 63 8.515427e-04 -38.05187 0 23.749081 0.8849501 64 5.406365e-04 -38.50617 0 49.243080 0.8817838 65 2.533206e-04 -39.26426 0 16.550139 0.8407284 66 2.514995e-04 -39.27148 0 16.512016 0.8404083 67 2.493349e-04 -39.28012 0 16.466412 0.8400238 68 2.426452e-04 -39.30732 0 16.323409 0.8388066 69 2.342123e-04 -39.34269 0 16.138513 0.8372065 70 2.250451e-04 -39.38262 0 15.931292 0.8353770 71 2.074898e-04 -39.46384 0 15.514571 0.8315777 72 1.933449e-04 -39.53444 0 15.157481 0.8281877 73 5.867050e-06 -43.02957 0 0.000000 0.0000000 74 4.358446e-06 -43.32680 0 4.907128 0.4802698 75 4.188441e-06 -43.36659 0 4.730201 0.4737063 76 4.058366e-06 -43.39814 0 4.592484 0.4684647 77 3.922687e-06 -43.43214 0 4.446607 0.4627791 78 3.798380e-06 -43.46434 0 4.310915 0.4573615 79 3.696118e-06 -43.49164 0 4.197792 0.4527453 80 3.568390e-06 -43.52681 0 4.054568 0.4467646 81 3.523467e-06 -43.53947 0 4.003677 0.4446015 R2 x1 x2 1 0.8855796032 0.5 2 0.8827286457 1 3 0.8714956694 0 4 0.8923307406 0.5 0 5 0.8921959767 0.5 0.5 6 0.8920753199 0.5 -0.5 7 0.8917304232 0.5 1 8 0.8914366613 0.5 -1 9 0.8902094303 0.5 2 10 0.8893985658 0.5 -2 11 0.8885422536 0.5 3 12 0.8877578169 1 0 13 0.8875800042 1 -0.5 14 0.8875777082 1 0.5 15 0.8871078483 1 1 16 0.8870439046 1 -1 17 0.8857208260 1 2 18 0.8852791905 1 -2 19 0.8405967510 2 20 0.8402830274 -0.5 21 0.8843553135 1 3 22 0.8807147664 0 0 23 0.8805120742 0 0.5 24 0.8804914426 0 -0.5 25 0.8799475721 0 1 26 0.8798409267 0 -1 27 0.8781455016 0 2 28 0.8776097649 0 -2 29 0.8761093840 0 3 30 0.8527815002 -0.5 0 31 0.8527600186 -0.5 -0.5 32 0.8523407163 -0.5 0.5 33 0.8522505566 -0.5 -1 34 0.8515215849 -0.5 1 35 0.8500338291 -0.5 -2 36 0.8492061223 -0.5 2 37 0.7951978331 -1 38 0.8466824461 -0.5 3 39 0.8438696580 2 -0.5 40 0.8437595084 2 0 41 0.8436327937 2 -1 42 0.8433540344 2 0.5 43 0.8427662270 2 1 44 0.8423621122 2 -2 45 0.8415405432 2 2 46 0.8407754285 2 3 47 0.7792158329 3 48 0.8120814915 -1 -0.5 49 0.8119064610 -1 -1 50 0.8116965142 -1 0 51 0.8108179137 -1 0.5 52 0.8100056502 -1 -2 53 0.8095636171 -1 1 54 0.8064655005 -1 2 55 0.8033161521 -1 3 56 0.7821166185 3 -1 57 0.7820248709 3 -0.5 58 0.7815966083 3 0 59 0.7812633373 3 -2 60 0.7809601732 3 0.5 61 0.7802830569 3 1 62 0.7793476545 3 2 63 0.7793041671 3 3 64 0.6855326620 -2 65 0.7139258301 -2 -1 66 0.7134740624 -2 -2 67 0.7129317180 -2 -0.5 68 0.7112173058 -2 0 69 0.7089692289 -2 0.5 70 0.7064065474 -2 1 71 0.7011097381 -2 2 72 0.6964114946 -2 3 73 0.0000000000 74 0.0646459314 -2 75 0.0531804586 -1 76 0.0439094354 -0.5 77 0.0337331221 0 78 0.0239151107 0.5 79 0.0154525450 1 80 0.0043504219 2 81 0.0002953391 3 > > truedata <- as.data.frame(exhaustive) > truedata posterior logMargLik logPrior postExpectedg postExpectedShrinkage 1 1.316673e-01 -33.01089 0 177.014280 0.9660069 2 1.147544e-01 -33.14837 0 172.127635 0.9650484 3 6.891219e-02 -33.65833 0 154.984283 0.9612121 4 2.912484e-02 -34.51957 0 57.015785 0.9503560 5 2.894184e-02 -34.52588 0 56.934522 0.9502866 6 2.877918e-02 -34.53151 0 56.861938 0.9502244 7 2.832026e-02 -34.54759 0 56.655348 0.9500465 8 2.793634e-02 -34.56124 0 56.480423 0.9498949 9 2.639891e-02 -34.61784 0 55.759777 0.9492606 10 2.543902e-02 -34.65488 0 55.292404 0.9488406 11 2.447073e-02 -34.69369 0 54.806220 0.9483963 12 2.362256e-02 -34.72896 0 54.367358 0.9479886 13 2.343527e-02 -34.73692 0 54.268730 0.9478961 14 2.343286e-02 -34.73703 0 54.267458 0.9478949 15 2.294658e-02 -34.75800 0 54.008347 0.9476502 16 2.288135e-02 -34.76084 0 53.973251 0.9476169 17 2.158060e-02 -34.81937 0 53.255884 0.9469267 18 2.116644e-02 -34.83875 0 53.020117 0.9466958 19 2.088324e-02 -34.85222 0 120.293438 0.9501499 20 2.065810e-02 -34.86306 0 120.010068 0.9500336 21 2.033069e-02 -34.87903 0 52.532730 0.9462123 22 1.740258e-02 -35.03455 0 50.685697 0.9442976 23 1.725509e-02 -35.04306 0 50.586171 0.9441905 24 1.724016e-02 -35.04392 0 50.576059 0.9441796 25 1.685224e-02 -35.06668 0 50.310759 0.9438922 26 1.677742e-02 -35.07113 0 50.259019 0.9438358 27 1.564022e-02 -35.14132 0 49.448639 0.9429375 28 1.530044e-02 -35.16328 0 49.197238 0.9426530 29 1.439532e-02 -35.22426 0 48.504744 0.9418545 30 6.100135e-03 -36.08285 0 39.554905 0.9291147 31 6.095732e-03 -36.08358 0 39.547972 0.9291027 32 6.010559e-03 -36.09765 0 39.413044 0.9288681 33 5.992434e-03 -36.10067 0 39.384132 0.9288176 34 5.848305e-03 -36.12501 0 39.151656 0.9284092 35 5.567020e-03 -36.17430 0 38.684221 0.9275737 36 5.417654e-03 -36.20150 0 38.428164 0.9271078 37 5.297403e-03 -36.22395 0 88.319723 0.9324439 38 4.991409e-03 -36.28345 0 37.664539 0.9256825 39 4.563443e-03 -36.37309 0 36.842569 0.9240853 40 4.547613e-03 -36.37656 0 36.810984 0.9240226 41 4.529485e-03 -36.38056 0 36.774704 0.9239504 42 4.489914e-03 -36.38933 0 36.695098 0.9237916 43 4.407844e-03 -36.40778 0 36.528163 0.9234563 44 4.352481e-03 -36.42042 0 36.414119 0.9232256 45 4.242517e-03 -36.44601 0 36.184065 0.9227560 46 4.143141e-03 -36.46971 0 35.971957 0.9223179 47 3.526959e-03 -36.63073 0 80.196740 0.9257735 48 1.844125e-03 -37.27916 0 29.267119 0.9054076 49 1.835821e-03 -37.28367 0 29.232517 0.9053015 50 1.825920e-03 -37.28908 0 29.191097 0.9051743 51 1.785193e-03 -37.31164 0 29.018761 0.9046413 52 1.748528e-03 -37.33239 0 28.860862 0.9041478 53 1.728964e-03 -37.34364 0 28.775501 0.9038789 54 1.599126e-03 -37.42171 0 28.188219 0.9019881 55 1.479201e-03 -37.49966 0 27.610277 0.9000549 56 9.052050e-04 -37.99076 0 24.157026 0.8867523 57 9.033896e-04 -37.99277 0 24.143550 0.8866937 58 8.949747e-04 -38.00212 0 24.080800 0.8864197 59 8.884933e-04 -38.00939 0 24.032140 0.8862064 60 8.826477e-04 -38.01599 0 23.988005 0.8860123 61 8.697623e-04 -38.03070 0 23.889874 0.8855783 62 8.523420e-04 -38.05093 0 23.755309 0.8849780 63 8.515427e-04 -38.05187 0 23.749081 0.8849501 64 5.406365e-04 -38.50617 0 49.243080 0.8817838 65 2.533206e-04 -39.26426 0 16.550139 0.8407284 66 2.514995e-04 -39.27148 0 16.512016 0.8404083 67 2.493349e-04 -39.28012 0 16.466412 0.8400238 68 2.426452e-04 -39.30732 0 16.323409 0.8388066 69 2.342123e-04 -39.34269 0 16.138513 0.8372065 70 2.250451e-04 -39.38262 0 15.931292 0.8353770 71 2.074898e-04 -39.46384 0 15.514571 0.8315777 72 1.933449e-04 -39.53444 0 15.157481 0.8281877 73 5.867050e-06 -43.02957 0 0.000000 0.0000000 74 4.358446e-06 -43.32680 0 4.907128 0.4802698 75 4.188441e-06 -43.36659 0 4.730201 0.4737063 76 4.058366e-06 -43.39814 0 4.592484 0.4684647 77 3.922687e-06 -43.43214 0 4.446607 0.4627791 78 3.798380e-06 -43.46434 0 4.310915 0.4573615 79 3.696118e-06 -43.49164 0 4.197792 0.4527453 80 3.568390e-06 -43.52681 0 4.054568 0.4467646 81 3.523467e-06 -43.53947 0 4.003677 0.4446015 R2 x1 x2 1 0.8855796032 0.5 2 0.8827286457 1 3 0.8714956694 0 4 0.8923307406 0.5 0 5 0.8921959767 0.5 0.5 6 0.8920753199 0.5 -0.5 7 0.8917304232 0.5 1 8 0.8914366613 0.5 -1 9 0.8902094303 0.5 2 10 0.8893985658 0.5 -2 11 0.8885422536 0.5 3 12 0.8877578169 1 0 13 0.8875800042 1 -0.5 14 0.8875777082 1 0.5 15 0.8871078483 1 1 16 0.8870439046 1 -1 17 0.8857208260 1 2 18 0.8852791905 1 -2 19 0.8405967510 2 20 0.8402830274 -0.5 21 0.8843553135 1 3 22 0.8807147664 0 0 23 0.8805120742 0 0.5 24 0.8804914426 0 -0.5 25 0.8799475721 0 1 26 0.8798409267 0 -1 27 0.8781455016 0 2 28 0.8776097649 0 -2 29 0.8761093840 0 3 30 0.8527815002 -0.5 0 31 0.8527600186 -0.5 -0.5 32 0.8523407163 -0.5 0.5 33 0.8522505566 -0.5 -1 34 0.8515215849 -0.5 1 35 0.8500338291 -0.5 -2 36 0.8492061223 -0.5 2 37 0.7951978331 -1 38 0.8466824461 -0.5 3 39 0.8438696580 2 -0.5 40 0.8437595084 2 0 41 0.8436327937 2 -1 42 0.8433540344 2 0.5 43 0.8427662270 2 1 44 0.8423621122 2 -2 45 0.8415405432 2 2 46 0.8407754285 2 3 47 0.7792158329 3 48 0.8120814915 -1 -0.5 49 0.8119064610 -1 -1 50 0.8116965142 -1 0 51 0.8108179137 -1 0.5 52 0.8100056502 -1 -2 53 0.8095636171 -1 1 54 0.8064655005 -1 2 55 0.8033161521 -1 3 56 0.7821166185 3 -1 57 0.7820248709 3 -0.5 58 0.7815966083 3 0 59 0.7812633373 3 -2 60 0.7809601732 3 0.5 61 0.7802830569 3 1 62 0.7793476545 3 2 63 0.7793041671 3 3 64 0.6855326620 -2 65 0.7139258301 -2 -1 66 0.7134740624 -2 -2 67 0.7129317180 -2 -0.5 68 0.7112173058 -2 0 69 0.7089692289 -2 0.5 70 0.7064065474 -2 1 71 0.7011097381 -2 2 72 0.6964114946 -2 3 73 0.0000000000 74 0.0646459314 -2 75 0.0531804586 -1 76 0.0439094354 -0.5 77 0.0337331221 0 78 0.0239151107 0.5 79 0.0154525450 1 80 0.0043504219 2 81 0.0002953391 3 > > post <- exp(truedata$logMargLik + truedata$logPrior) > normConst <- sum(post) > post / normConst [1] 1.316673e-01 1.147544e-01 6.891219e-02 2.912484e-02 2.894184e-02 [6] 2.877918e-02 2.832026e-02 2.793634e-02 2.639891e-02 2.543902e-02 [11] 2.447073e-02 2.362256e-02 2.343527e-02 2.343286e-02 2.294658e-02 [16] 2.288135e-02 2.158060e-02 2.116644e-02 2.088324e-02 2.065810e-02 [21] 2.033069e-02 1.740258e-02 1.725509e-02 1.724016e-02 1.685224e-02 [26] 1.677742e-02 1.564022e-02 1.530044e-02 1.439532e-02 6.100135e-03 [31] 6.095732e-03 6.010559e-03 5.992434e-03 5.848305e-03 5.567020e-03 [36] 5.417654e-03 5.297403e-03 4.991409e-03 4.563443e-03 4.547613e-03 [41] 4.529485e-03 4.489914e-03 4.407844e-03 4.352481e-03 4.242517e-03 [46] 4.143141e-03 3.526959e-03 1.844125e-03 1.835821e-03 1.825920e-03 [51] 1.785193e-03 1.748528e-03 1.728964e-03 1.599126e-03 1.479201e-03 [56] 9.052050e-04 9.033896e-04 8.949747e-04 8.884933e-04 8.826477e-04 [61] 8.697623e-04 8.523420e-04 8.515427e-04 5.406365e-04 2.533206e-04 [66] 2.514995e-04 2.493349e-04 2.426452e-04 2.342123e-04 2.250451e-04 [71] 2.074898e-04 1.933449e-04 5.867050e-06 4.358446e-06 4.188441e-06 [76] 4.058366e-06 3.922687e-06 3.798380e-06 3.696118e-06 3.568390e-06 [81] 3.523467e-06 > > set.seed(2) > simulation <- BayesMfp (y ~ bfp (x1, max=1) + bfp(x2, max=1), + data = covariateData, + priorSpecs = + list (a = 3.5, + modelPrior="flat"), + method = "sampling", + nModels = 100, + chainlength=1000000 + ) Starting sampler... 0%______________________________________________________________________________________________100% ---------------------------------------------------------------------------------------------------- Number of non-identifiable model proposals: 0 Number of total cached models: 81 Number of returned models: 81 > attr(simulation, "logNormConst") [1] 12.04616 > summary(simulation) ------------------------------ BayesMfp-Output ------------------------------ Original call: BayesMfp(formula = y ~ bfp(x1, max = 1) + bfp(x2, max = 1), data = covariateData, priorSpecs = list(a = 3.5, modelPrior = "flat"), method = "sampling", nModels = 100, chainlength = 1e+06) 81 multivariable fractional polynomial model(s) of total (visited/cached)81 (during 1e+06 sampling jumps) for following covariates: fixed: (Intercept) uncertain fixed form: fractional polynomial: shift scale maxDegree cardPowerset x1 0 1 1 8 x2 0 1 1 8 Distribution of posterior probabilities: normalized frequency Min. :3.520e-06 Min. :0.000000 1st Qu.:8.698e-04 1st Qu.:0.000827 Median :4.529e-03 Median :0.004518 Mean :1.235e-02 Mean :0.012346 3rd Qu.:2.033e-02 3rd Qu.:0.020524 Max. :1.317e-01 Max. :0.131264 Overall inclusion probabilities for covariates in question: x1 x2 0.9999630 0.6337539 Inclusion probabilities for covariates in question for this model selection: x1 x2 0.9999630 0.6337539 Overview: posterior frequency logMargLik logPrior postExpectedg 1 1.316673e-01 0.131264 -33.01089 0 177.014280 2 1.147544e-01 0.116670 -33.14837 0 172.127635 3 6.891219e-02 0.067876 -33.65833 0 154.984283 4 2.912484e-02 0.028542 -34.51957 0 57.015785 5 2.894184e-02 0.028975 -34.52588 0 56.934522 6 2.877918e-02 0.028722 -34.53151 0 56.861938 7 2.832026e-02 0.028306 -34.54759 0 56.655348 8 2.793634e-02 0.027202 -34.56124 0 56.480423 9 2.639891e-02 0.026453 -34.61784 0 55.759777 10 2.543902e-02 0.025348 -34.65488 0 55.292404 11 2.447073e-02 0.023733 -34.69369 0 54.806220 12 2.362256e-02 0.023779 -34.72896 0 54.367358 13 2.343527e-02 0.023667 -34.73692 0 54.268730 14 2.343286e-02 0.023452 -34.73703 0 54.267458 15 2.294658e-02 0.023313 -34.75800 0 54.008347 16 2.288135e-02 0.022313 -34.76084 0 53.973251 17 2.158060e-02 0.022526 -34.81937 0 53.255884 18 2.116644e-02 0.020601 -34.83875 0 53.020117 19 2.088324e-02 0.020969 -34.85222 0 120.293438 20 2.065810e-02 0.021471 -34.86306 0 120.010068 21 2.033069e-02 0.020524 -34.87903 0 52.532730 22 1.740258e-02 0.017324 -35.03455 0 50.685697 23 1.725509e-02 0.016776 -35.04306 0 50.586171 24 1.724016e-02 0.017410 -35.04392 0 50.576059 25 1.685224e-02 0.016928 -35.06668 0 50.310759 26 1.677742e-02 0.016221 -35.07113 0 50.259019 27 1.564022e-02 0.015237 -35.14132 0 49.448639 28 1.530044e-02 0.015389 -35.16328 0 49.197238 29 1.439532e-02 0.013951 -35.22426 0 48.504744 30 6.100135e-03 0.006170 -36.08285 0 39.554905 31 6.095732e-03 0.006089 -36.08358 0 39.547972 32 6.010559e-03 0.006112 -36.09765 0 39.413044 33 5.992434e-03 0.006326 -36.10067 0 39.384132 34 5.848305e-03 0.005858 -36.12501 0 39.151656 35 5.567020e-03 0.005855 -36.17430 0 38.684221 36 5.417654e-03 0.005611 -36.20150 0 38.428164 37 5.297403e-03 0.005414 -36.22395 0 88.319723 38 4.991409e-03 0.005152 -36.28345 0 37.664539 39 4.563443e-03 0.004778 -36.37309 0 36.842569 40 4.547613e-03 0.004434 -36.37656 0 36.810984 41 4.529485e-03 0.004647 -36.38056 0 36.774704 42 4.489914e-03 0.004518 -36.38933 0 36.695098 43 4.407844e-03 0.004504 -36.40778 0 36.528163 44 4.352481e-03 0.004327 -36.42042 0 36.414119 45 4.242517e-03 0.004410 -36.44601 0 36.184065 46 4.143141e-03 0.004351 -36.46971 0 35.971957 47 3.526959e-03 0.003331 -36.63073 0 80.196740 48 1.844125e-03 0.001828 -37.27916 0 29.267119 49 1.835821e-03 0.001681 -37.28367 0 29.232517 50 1.825920e-03 0.001848 -37.28908 0 29.191097 51 1.785193e-03 0.001817 -37.31164 0 29.018761 52 1.748528e-03 0.001813 -37.33239 0 28.860862 53 1.728964e-03 0.001667 -37.34364 0 28.775501 54 1.599126e-03 0.001652 -37.42171 0 28.188219 55 1.479201e-03 0.001503 -37.49966 0 27.610277 56 9.052050e-04 0.000908 -37.99076 0 24.157026 57 9.033896e-04 0.000926 -37.99277 0 24.143550 58 8.949747e-04 0.000816 -38.00212 0 24.080800 59 8.884933e-04 0.000922 -38.00939 0 24.032140 60 8.826477e-04 0.000827 -38.01599 0 23.988005 61 8.697623e-04 0.000882 -38.03070 0 23.889874 62 8.523420e-04 0.000884 -38.05093 0 23.755309 63 8.515427e-04 0.000757 -38.05187 0 23.749081 64 5.406365e-04 0.000531 -38.50617 0 49.243080 65 2.533206e-04 0.000288 -39.26426 0 16.550139 66 2.514995e-04 0.000279 -39.27148 0 16.512016 67 2.493349e-04 0.000272 -39.28012 0 16.466412 68 2.426452e-04 0.000258 -39.30732 0 16.323409 69 2.342123e-04 0.000211 -39.34269 0 16.138513 70 2.250451e-04 0.000195 -39.38262 0 15.931292 71 2.074898e-04 0.000203 -39.46384 0 15.514571 72 1.933449e-04 0.000184 -39.53444 0 15.157481 73 5.867050e-06 0.000005 -43.02957 0 0.000000 74 4.358446e-06 0.000002 -43.32680 0 4.907128 75 4.188441e-06 0.000000 -43.36659 0 4.730201 76 4.058366e-06 0.000004 -43.39814 0 4.592484 77 3.922687e-06 0.000000 -43.43214 0 4.446607 78 3.798380e-06 0.000003 -43.46434 0 4.310915 79 3.696118e-06 0.000003 -43.49164 0 4.197792 80 3.568390e-06 0.000001 -43.52681 0 4.054568 81 3.523467e-06 0.000002 -43.53947 0 4.003677 postExpectedShrinkage R2 x1 x2 1 0.9660069 0.8855796032 0.5 2 0.9650484 0.8827286457 1 3 0.9612121 0.8714956694 0 4 0.9503560 0.8923307406 0.5 0 5 0.9502866 0.8921959767 0.5 0.5 6 0.9502244 0.8920753199 0.5 -0.5 7 0.9500465 0.8917304232 0.5 1 8 0.9498949 0.8914366613 0.5 -1 9 0.9492606 0.8902094303 0.5 2 10 0.9488406 0.8893985658 0.5 -2 11 0.9483963 0.8885422536 0.5 3 12 0.9479886 0.8877578169 1 0 13 0.9478961 0.8875800042 1 -0.5 14 0.9478949 0.8875777082 1 0.5 15 0.9476502 0.8871078483 1 1 16 0.9476169 0.8870439046 1 -1 17 0.9469267 0.8857208260 1 2 18 0.9466958 0.8852791905 1 -2 19 0.9501499 0.8405967510 2 20 0.9500336 0.8402830274 -0.5 21 0.9462123 0.8843553135 1 3 22 0.9442976 0.8807147664 0 0 23 0.9441905 0.8805120742 0 0.5 24 0.9441796 0.8804914426 0 -0.5 25 0.9438922 0.8799475721 0 1 26 0.9438358 0.8798409267 0 -1 27 0.9429375 0.8781455016 0 2 28 0.9426530 0.8776097649 0 -2 29 0.9418545 0.8761093840 0 3 30 0.9291147 0.8527815002 -0.5 0 31 0.9291027 0.8527600186 -0.5 -0.5 32 0.9288681 0.8523407163 -0.5 0.5 33 0.9288176 0.8522505566 -0.5 -1 34 0.9284092 0.8515215849 -0.5 1 35 0.9275737 0.8500338291 -0.5 -2 36 0.9271078 0.8492061223 -0.5 2 37 0.9324439 0.7951978331 -1 38 0.9256825 0.8466824461 -0.5 3 39 0.9240853 0.8438696580 2 -0.5 40 0.9240226 0.8437595084 2 0 41 0.9239504 0.8436327937 2 -1 42 0.9237916 0.8433540344 2 0.5 43 0.9234563 0.8427662270 2 1 44 0.9232256 0.8423621122 2 -2 45 0.9227560 0.8415405432 2 2 46 0.9223179 0.8407754285 2 3 47 0.9257735 0.7792158329 3 48 0.9054076 0.8120814915 -1 -0.5 49 0.9053015 0.8119064610 -1 -1 50 0.9051743 0.8116965142 -1 0 51 0.9046413 0.8108179137 -1 0.5 52 0.9041478 0.8100056502 -1 -2 53 0.9038789 0.8095636171 -1 1 54 0.9019881 0.8064655005 -1 2 55 0.9000549 0.8033161521 -1 3 56 0.8867523 0.7821166185 3 -1 57 0.8866937 0.7820248709 3 -0.5 58 0.8864197 0.7815966083 3 0 59 0.8862064 0.7812633373 3 -2 60 0.8860123 0.7809601732 3 0.5 61 0.8855783 0.7802830569 3 1 62 0.8849780 0.7793476545 3 2 63 0.8849501 0.7793041671 3 3 64 0.8817838 0.6855326620 -2 65 0.8407284 0.7139258301 -2 -1 66 0.8404083 0.7134740624 -2 -2 67 0.8400238 0.7129317180 -2 -0.5 68 0.8388066 0.7112173058 -2 0 69 0.8372065 0.7089692289 -2 0.5 70 0.8353770 0.7064065474 -2 1 71 0.8315777 0.7011097381 -2 2 72 0.8281877 0.6964114946 -2 3 73 0.0000000 0.0000000000 74 0.4802698 0.0646459314 -2 75 0.4737063 0.0531804586 -1 76 0.4684647 0.0439094354 -0.5 77 0.4627791 0.0337331221 0 78 0.4573615 0.0239151107 0.5 79 0.4527453 0.0154525450 1 80 0.4467646 0.0043504219 2 81 0.4446015 0.0002953391 3 > > p1 <- posteriors(exhaustive) > p2 <- posteriors(simulation, 2) > > plot(log(p1), log(p2)) > abline(0, 1) > > d1 <- as.data.frame(exhaustive) > d2 <- as.data.frame(simulation) > > head(d1[, -c(7,8)]) posterior logMargLik logPrior postExpectedg postExpectedShrinkage R2 1 0.13166735 -33.01089 0 177.01428 0.9660069 0.8855796 2 0.11475439 -33.14837 0 172.12764 0.9650484 0.8827286 3 0.06891219 -33.65833 0 154.98428 0.9612121 0.8714957 4 0.02912484 -34.51957 0 57.01579 0.9503560 0.8923307 5 0.02894184 -34.52588 0 56.93452 0.9502866 0.8921960 6 0.02877918 -34.53151 0 56.86194 0.9502244 0.8920753 > head(d2[, -c(2, 8, 9)]) posterior logMargLik logPrior postExpectedg postExpectedShrinkage R2 1 0.13166735 -33.01089 0 177.01428 0.9660069 0.8855796 2 0.11475439 -33.14837 0 172.12764 0.9650484 0.8827286 3 0.06891219 -33.65833 0 154.98428 0.9612121 0.8714957 4 0.02912484 -34.51957 0 57.01579 0.9503560 0.8923307 5 0.02894184 -34.52588 0 56.93452 0.9502866 0.8921960 6 0.02877918 -34.53151 0 56.86194 0.9502244 0.8920753 > > shouldbeZero <- d1[, -c(7,8)] - d2[, -c(2, 8, 9)] > shouldbeZero <- max(abs(unlist(shouldbeZero))) > stopifnot(all.equal(shouldbeZero, 0)) > > > ## also test the dependent model prior > dependent <- BayesMfp (y ~ bfp (x1, max=1) + bfp(x2, max=1), + data = covariateData, + priorSpecs = + list (a = 3.5, + modelPrior="dependent"), + method = "exhaustive", + nModels = 10000) Starting with computation of every model... 0%______________________________________________________________________________________________100% --------------------------------------------------------------------------------- Actual number of possible models: 81 Number of non-identifiable models: 0 Number of saved possible models: 81 > attr(dependent, "logNormConst") [1] 8.012593 > > depSum <- as.data.frame(dependent) > depSum posterior logMargLik logPrior postExpectedg postExpectedShrinkage 1 5.399373e-01 -33.14837 -2.484907 172.127635 0.9650484 2 1.439563e-01 -34.75800 -2.197225 54.008347 0.9476502 3 8.850220e-02 -33.01089 -4.430817 177.014280 0.9660069 4 4.632037e-02 -33.65833 -4.430817 154.984283 0.9612121 5 1.403699e-02 -34.85222 -4.430817 120.293438 0.9501499 6 1.388565e-02 -34.86306 -4.430817 120.010068 0.9500336 7 1.269060e-02 -34.54759 -4.836282 56.655348 0.9500465 8 1.058551e-02 -34.72896 -4.836282 54.367358 0.9479886 9 1.050158e-02 -34.73692 -4.836282 54.268730 0.9478961 10 1.050050e-02 -34.73703 -4.836282 54.267458 0.9478949 11 1.025336e-02 -34.76084 -4.836282 53.973251 0.9476169 12 9.670482e-03 -34.81937 -4.836282 53.255884 0.9469267 13 9.484894e-03 -34.83875 -4.836282 53.020117 0.9466958 14 9.110389e-03 -34.87903 -4.836282 52.532730 0.9462123 15 7.551659e-03 -35.06668 -4.836282 50.310759 0.9438922 16 3.728895e-03 -34.51957 -6.089045 57.015785 0.9503560 17 3.705466e-03 -34.52588 -6.089045 56.934522 0.9502866 18 3.684640e-03 -34.53151 -6.089045 56.861938 0.9502244 19 3.576731e-03 -34.56124 -6.089045 56.480423 0.9498949 20 3.560730e-03 -36.22395 -4.430817 88.319723 0.9324439 21 3.379891e-03 -34.61784 -6.089045 55.759777 0.9492606 22 3.256995e-03 -34.65488 -6.089045 55.292404 0.9488406 23 3.133024e-03 -34.69369 -6.089045 54.806220 0.9483963 24 2.620685e-03 -36.12501 -4.836282 39.151656 0.9284092 25 2.370699e-03 -36.63073 -4.430817 80.196740 0.9257735 26 2.228077e-03 -35.03455 -6.089045 50.685697 0.9442976 27 2.209194e-03 -35.04306 -6.089045 50.586171 0.9441905 28 2.207283e-03 -35.04392 -6.089045 50.576059 0.9441796 29 2.148037e-03 -35.07113 -6.089045 50.259019 0.9438358 30 2.002441e-03 -35.14132 -6.089045 49.448639 0.9429375 31 1.975199e-03 -36.40778 -4.836282 36.528163 0.9234563 32 1.958937e-03 -35.16328 -6.089045 49.197238 0.9426530 33 1.843054e-03 -35.22426 -6.089045 48.504744 0.9418545 34 7.810091e-04 -36.08285 -6.089045 39.554905 0.9291147 35 7.804454e-04 -36.08358 -6.089045 39.547972 0.9291027 36 7.747661e-04 -37.34364 -4.836282 28.775501 0.9038789 37 7.695406e-04 -36.09765 -6.089045 39.413044 0.9288681 38 7.672200e-04 -36.10067 -6.089045 39.384132 0.9288176 39 7.127536e-04 -36.17430 -6.089045 38.684221 0.9275737 40 6.936301e-04 -36.20150 -6.089045 38.428164 0.9271078 41 6.390573e-04 -36.28345 -6.089045 37.664539 0.9256825 42 5.842642e-04 -36.37309 -6.089045 36.842569 0.9240853 43 5.822375e-04 -36.37656 -6.089045 36.810984 0.9240226 44 5.799165e-04 -36.38056 -6.089045 36.774704 0.9239504 45 5.748502e-04 -36.38933 -6.089045 36.695098 0.9237916 46 5.572545e-04 -36.42042 -6.089045 36.414119 0.9232256 47 5.431756e-04 -36.44601 -6.089045 36.184065 0.9227560 48 5.304523e-04 -36.46971 -6.089045 35.971957 0.9223179 49 3.897493e-04 -38.03070 -4.836282 23.889874 0.8855783 50 3.633970e-04 -38.50617 -4.430817 49.243080 0.8817838 51 2.361060e-04 -37.27916 -6.089045 29.267119 0.9054076 52 2.350428e-04 -37.28367 -6.089045 29.232517 0.9053015 53 2.337752e-04 -37.28908 -6.089045 29.191097 0.9051743 54 2.285609e-04 -37.31164 -6.089045 29.018761 0.9046413 55 2.238666e-04 -37.33239 -6.089045 28.860862 0.9041478 56 2.047384e-04 -37.42171 -6.089045 28.188219 0.9019881 57 1.893843e-04 -37.49966 -6.089045 27.610277 0.9000549 58 1.158947e-04 -37.99076 -6.089045 24.157026 0.8867523 59 1.156623e-04 -37.99277 -6.089045 24.143550 0.8866937 60 1.145849e-04 -38.00212 -6.089045 24.080800 0.8864197 61 1.137551e-04 -38.00939 -6.089045 24.032140 0.8862064 62 1.130067e-04 -38.01599 -6.089045 23.988005 0.8860123 63 1.104215e-04 -43.02957 -1.098612 0.000000 0.0000000 64 1.091266e-04 -38.05093 -6.089045 23.755309 0.8849780 65 1.090242e-04 -38.05187 -6.089045 23.749081 0.8849501 66 1.008450e-04 -39.38262 -4.836282 15.931292 0.8353770 67 3.243301e-05 -39.26426 -6.089045 16.550139 0.8407284 68 3.219984e-05 -39.27148 -6.089045 16.512016 0.8404083 69 3.192271e-05 -39.28012 -6.089045 16.466412 0.8400238 70 3.106622e-05 -39.30732 -6.089045 16.323409 0.8388066 71 2.998654e-05 -39.34269 -6.089045 16.138513 0.8372065 72 2.656522e-05 -39.46384 -6.089045 15.514571 0.8315777 73 2.475422e-05 -39.53444 -6.089045 15.157481 0.8281877 74 1.739081e-05 -43.49164 -2.484907 4.197792 0.4527453 75 2.929596e-06 -43.32680 -4.430817 4.907128 0.4802698 76 2.815324e-06 -43.36659 -4.430817 4.730201 0.4737063 77 2.727892e-06 -43.39814 -4.430817 4.592484 0.4684647 78 2.636693e-06 -43.43214 -4.430817 4.446607 0.4627791 79 2.553139e-06 -43.46434 -4.430817 4.310915 0.4573615 80 2.398547e-06 -43.52681 -4.430817 4.054568 0.4467646 81 2.368351e-06 -43.53947 -4.430817 4.003677 0.4446015 R2 x1 x2 1 0.8827286457 1 2 0.8871078483 1 1 3 0.8855796032 0.5 4 0.8714956694 0 5 0.8405967510 2 6 0.8402830274 -0.5 7 0.8917304232 0.5 1 8 0.8877578169 1 0 9 0.8875800042 1 -0.5 10 0.8875777082 1 0.5 11 0.8870439046 1 -1 12 0.8857208260 1 2 13 0.8852791905 1 -2 14 0.8843553135 1 3 15 0.8799475721 0 1 16 0.8923307406 0.5 0 17 0.8921959767 0.5 0.5 18 0.8920753199 0.5 -0.5 19 0.8914366613 0.5 -1 20 0.7951978331 -1 21 0.8902094303 0.5 2 22 0.8893985658 0.5 -2 23 0.8885422536 0.5 3 24 0.8515215849 -0.5 1 25 0.7792158329 3 26 0.8807147664 0 0 27 0.8805120742 0 0.5 28 0.8804914426 0 -0.5 29 0.8798409267 0 -1 30 0.8781455016 0 2 31 0.8427662270 2 1 32 0.8776097649 0 -2 33 0.8761093840 0 3 34 0.8527815002 -0.5 0 35 0.8527600186 -0.5 -0.5 36 0.8095636171 -1 1 37 0.8523407163 -0.5 0.5 38 0.8522505566 -0.5 -1 39 0.8500338291 -0.5 -2 40 0.8492061223 -0.5 2 41 0.8466824461 -0.5 3 42 0.8438696580 2 -0.5 43 0.8437595084 2 0 44 0.8436327937 2 -1 45 0.8433540344 2 0.5 46 0.8423621122 2 -2 47 0.8415405432 2 2 48 0.8407754285 2 3 49 0.7802830569 3 1 50 0.6855326620 -2 51 0.8120814915 -1 -0.5 52 0.8119064610 -1 -1 53 0.8116965142 -1 0 54 0.8108179137 -1 0.5 55 0.8100056502 -1 -2 56 0.8064655005 -1 2 57 0.8033161521 -1 3 58 0.7821166185 3 -1 59 0.7820248709 3 -0.5 60 0.7815966083 3 0 61 0.7812633373 3 -2 62 0.7809601732 3 0.5 63 0.0000000000 64 0.7793476545 3 2 65 0.7793041671 3 3 66 0.7064065474 -2 1 67 0.7139258301 -2 -1 68 0.7134740624 -2 -2 69 0.7129317180 -2 -0.5 70 0.7112173058 -2 0 71 0.7089692289 -2 0.5 72 0.7011097381 -2 2 73 0.6964114946 -2 3 74 0.0154525450 1 75 0.0646459314 -2 76 0.0531804586 -1 77 0.0439094354 -0.5 78 0.0337331221 0 79 0.0239151107 0.5 80 0.0043504219 2 81 0.0002953391 3 > > sum(exp(depSum$logPrior)) [1] 1 > > index <- 1L > > stopifnot(all.equal(getLogPrior(dependent[index]), + dependent[[index]]$logP)) > > proc.time() user system elapsed 1.35 0.04 1.39