-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_parameters() and find_parameters() should indicate fixed and random effects for BayesFactor::anovaBF
#169
Comments
This errors due to library(insight)
library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey ([email protected]).
#>
#> Type BFManual() to open the manual.
#> ************
model <- anovaBF(extra ~ group + ID, data = sleep, whichRandom = "ID", progress = FALSE)
head(get_parameters(model))
#> mu group-1 group-2 ID-1 ID-2 ID-3 ID-4
#> 1 1.349286 -0.6724627 0.6724627 0.05559608 -2.1598342 -0.6760759 -1.047968
#> 2 1.692076 -0.7261666 0.7261666 0.04946193 -1.3462277 -1.2668723 -1.251121
#> 3 2.110250 -0.8819996 0.8819996 -0.12487609 -0.7093962 -1.1001693 -2.061756
#> 4 1.656555 -0.8587893 0.8587893 0.79552914 -1.1983304 -0.1355185 -1.472216
#> 5 1.895765 -0.4498286 0.4498286 0.95904814 -1.9519772 -0.9481232 -1.507108
#> 6 1.631278 -0.8018071 0.8018071 0.21136784 -1.0153058 -1.1680062 -1.009764
#> ID-5 ID-6 ID-7 ID-8 ID-9 ID-10 sig2
#> 1 -0.7875713 1.568064 1.651395 0.3938788 1.65393017 1.15372957 0.9994526
#> 2 -0.7433016 2.044083 1.709569 -0.4861043 0.92190880 0.48956802 1.3592481
#> 3 -2.1731418 1.148342 1.158459 -0.2194751 0.48845869 -0.02081864 0.9389592
#> 4 -1.4777671 1.743779 1.229966 -0.5381937 0.32094642 1.06300767 0.8146430
#> 5 -1.6224734 1.504265 2.105043 -0.8283088 -0.03518938 1.02143941 0.9147814
#> 6 -1.4372970 2.115739 3.690448 -1.1648361 -0.06883875 0.99407781 1.0693874
#> g_group g_ID
#> 1 0.5444569 0.9252051
#> 2 0.8492134 1.3423385
#> 3 6.6524189 1.0730355
#> 4 0.7506118 1.1278043
#> 5 0.8147826 2.4118328
#> 6 1.8295035 2.0901768
find_parameters(model)
#> $conditional
#> [1] "mu" "group-1" "group-2" "ID-1" "ID-2" "ID-3" "ID-4"
#> [8] "ID-5" "ID-6" "ID-7" "ID-8" "ID-9" "ID-10" "sig2"
#> [15] "g_group" "g_ID" Created on 2019-12-17 by the reprex package (v0.3.0) |
@strengejacke note that library(insight)
library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey ([email protected]).
#>
#> Type BFManual() to open the manual.
#> ************
data("puzzles")
result <- anovaBF(
RT ~ shape * color + ID,
data = puzzles,
whichRandom = "ID",
progress = FALSE
)
ttest_res <-
ttestBF(
x = sleep$extra[sleep$group == 1],
y = sleep$extra[sleep$group == 2],
paired = TRUE,
nullInterval = c(-Inf, 0)
)
posterior(result, iterations = 10)
#> Error in posterior(result, iterations = 10): Index argument required for posterior with multiple numerators.
posterior(ttest_res, iterations = 10)
#> Error in posterior(ttest_res, iterations = 10): Index argument required for posterior with multiple numerators. Created on 2019-12-17 by the reprex package (v0.3.0) Also, if you wan result@numerator$`shape + ID`@dataTypes
#> ID shape
#> "random" "fixed" (But this is a whole mess on-to itself...) |
Would be nice, and I can even use |
I think it's now mainly an insight issue, as it works with Now we have to extract information on which parameter is random, and which is fixed, and make |
model_parameters
doesn't work with BayesFactor::anovaBF
BayesFactor::anovaBF
I've been down that rabbit hole... Once you open that door... |
library(insight)
library(parameters)
#>
#> Attaching package: 'parameters'
#> The following object is masked from 'package:insight':
#>
#> format_ci
library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey ([email protected]).
#>
#> Type BFManual() to open the manual.
#> ************
model <- anovaBF(extra ~ group + ID, data = sleep, whichRandom = "ID", progress = FALSE)
head(get_parameters(model))
#> mu group-1 group-2 ID-1 ID-2 ID-3 ID-4
#> 1 1.388413 -0.9373772 0.9373772 -0.3358237 -1.249506 -0.6663588 -0.1712864
#> 2 2.092704 -1.0004152 1.0004152 -0.4030889 -0.802145 -2.0117398 -2.2269061
#> 3 1.862832 -0.8652697 0.8652697 -1.4377261 -1.754347 -1.4568715 -1.8716563
#> 4 1.784898 -0.8077692 0.8077692 -0.2117907 -2.042515 -0.6654858 -2.3811870
#> 5 2.685579 -0.7216999 0.7216999 -0.8455328 -2.992526 -1.7699278 -3.3533533
#> 6 1.304258 -0.9785429 0.9785429 0.1042850 -2.167270 -1.0909156 -0.9915559
#> ID-5 ID-6 ID-7 ID-8 ID-9 ID-10 sig2
#> 1 -0.7255611 1.8931277 1.899339 0.2131550 0.56946258 1.5719684 0.9627126
#> 2 -2.2192400 0.9967290 2.697733 -1.7158945 0.48580661 0.6370042 1.1319091
#> 3 -1.8016265 0.4559148 2.257765 -1.0178970 -0.03012636 1.3148016 0.6901860
#> 4 -1.6334668 1.6687262 2.523719 -0.6269279 0.56978852 1.4394503 0.7274266
#> 5 -2.7867715 1.8316788 2.167131 0.3504694 0.26296890 0.9842533 0.7864430
#> 6 -0.7278862 1.9251050 2.924684 -0.2444156 1.68773453 0.9569678 0.6179961
#> g_group g_ID
#> 1 0.5071210 1.526206
#> 2 5.5938528 2.530137
#> 3 1.6020113 2.011088
#> 4 0.2738577 5.318503
#> 5 0.7436001 7.866674
#> 6 1.9593037 2.744540
find_parameters(model)
#> $conditional
#> [1] "group-1" "group-2"
#>
#> $random
#> [1] "ID-1" "ID-2" "ID-3" "ID-4" "ID-5" "ID-6" "ID-7" "ID-8" "ID-9"
#> [10] "ID-10"
#>
#> $extra
#> [1] "mu" "sig2" "g_group" "g_ID"
model_parameters(model)
#> # Fixed Effects (Count Model)
#>
#> Parameter | Median | 89% CI | pd | % in ROPE | BF
#> ----------------------------------------------------------------
#> group-1 | -0.67 | [-1.06, -0.28] | 99.30% | 0% | 11.73
#> group-2 | 0.67 | [ 0.28, 1.06] | 99.30% | 0% | 11.73
#>
#> # Extra Parameters
#>
#> Parameter | Median | 89% CI | pd | % in ROPE | BF
#> --------------------------------------------------------------
#> mu | 1.55 | [0.62, 2.44] | 99.28% | 0% | 11.73
#> sig2 | 1.00 | [0.34, 1.98] | 100% | 0% | 11.73
#> g_group | 0.84 | [0.02, 5.73] | 100% | 3.17% | 11.73
#> g_ID | 2.61 | [0.16, 6.71] | 100% | 0% | 11.73
#>
#> # Random Effects (Count Model)
#>
#> Parameter | Median | 89% CI | pd | % in ROPE | BF
#> ----------------------------------------------------------------
#> ID-1 | -0.21 | [-1.58, 1.07] | 59.33% | 11.60% | 11.73
#> ID-2 | -1.54 | [-2.90, -0.21] | 96.28% | 0% | 11.73
#> ID-3 | -0.88 | [-2.25, 0.46] | 86.02% | 6.57% | 11.73
#> ID-4 | -1.68 | [-3.05, -0.30] | 97.40% | 0% | 11.73
#> ID-5 | -1.33 | [-2.65, 0.01] | 94.55% | 2.81% | 11.73
#> ID-6 | 1.87 | [ 0.39, 3.17] | 98.28% | 0% | 11.73
#> ID-7 | 2.45 | [ 0.91, 3.80] | 99.48% | 0% | 11.73
#> ID-8 | -0.29 | [-1.58, 1.03] | 64.05% | 11.06% | 11.73
#> ID-9 | 0.61 | [-0.69, 1.91] | 78.62% | 7.78% | 11.73
#> ID-10 | 0.90 | [-0.38, 2.31] | 87.02% | 5.48% | 11.73 Created on 2019-12-18 by the reprex package (v0.3.0) |
Awesome, thanks for fixing this so quickly! |
Created on 2019-12-17 by the reprex package (v0.3.0)
Traceback:
Session info
The text was updated successfully, but these errors were encountered: