Comments (9)
That error seems weird - I cannot find any simliar call in any easystats package.
I also am unable to reproduce the example locally:
library(dplyr)
library(brms)
library(bayestestR)
df = data.frame(x = rnorm(1000), x2 = rnorm(1000)) %>%
mutate(y = rnorm(1000) + x + x2 * .1)
model = brm(y ~ x + x2, data=df)
bayestestR::hdi(model)
#> Highest Density Interval
#>
#> Parameter | 95% HDI
#> ---------------------------
#> (Intercept) | [-0.04, 0.09]
#> x | [ 0.92, 1.05]
#> x2 | [ 0.07, 0.19]
from bayestestr.
Yeah, nothing of the error indicates that it could be an issue with the hdi()
function.
from bayestestr.
Can you provide a reproducible example from your machine? (like, copy the code to clipboard and run reprex::reprex()
)
For me, it works fine:
library(brms)
library(bayestestR)
d <- data.frame(x = rnorm(1000), x2 = rnorm(1000))
d$y <- rnorm(1000) + d$x + d$x2 * 0.1
model = brm(y ~ x + x2, data = d)
bayestestR::hdi(model)
#> Highest Density Interval
#>
#> Parameter | 95% HDI
#> ---------------------------
#> (Intercept) | [-0.06, 0.06]
#> x | [ 0.99, 1.12]
#> x2 | [ 0.02, 0.15]
Created on 2023-12-19 with reprex v2.0.2
from bayestestr.
It appears that it is some kind of weird interaction with Jupyter. The code from @strengejacke example runs perfectly well in an R console or using Rscript but the same code gives the aforementoined error when run on the same machine within a Jupyter notebook cell or an R console window within Jupyter. I'll try to do some deeper comparisons to see if I can identify the source of the issue but interested in any thoughts.
from bayestestr.
@poldrack can you try running the following, just to try and locate the error:
library(brms)
d <- data.frame(x = rnorm(1000), x2 = rnorm(1000))
d$y <- rnorm(1000) + d$x + d$x2 * 0.1
H1 <- bayestestR::hdi(d)
print(H1)
model = brm(y ~ x + x2, data = d)
H2 <- bayestestR::hdi(model)
print(H2)
from bayestestr.
thanks, that code ran just fine, and helped isolate the problem: the error only occurs when bayestestR:hdi() is run within Jupyter without assigning the output to variable. Seems like this is a Jupyter problem rather than a problem with this function so I am fine closing this unless @strengejacke thinks there is something to be done here. thanks again for all your help!
from bayestestr.
Thank you for checking this more closely! I agree, it seems that nothing needs to be done from our side.
from bayestestr.
for the record I should note that my previous diagnosis was not exactly right: it turns out that it has to do with trying to print the outputs from Jupyter without surrounding the in an explicit print()
statement. Thus, print(bayestestR::hdi(model))
works just fine as well.
from bayestestr.
without surrounding the in an explicit print() statement. Thus, print(bayestestR::hdi(model)) works just fine as well
Hi Russ, this is quite weird indeed. It seems like there could be a clash of methods where jupyter doesn't call bayestestR's print method automatically but something else, maybe some wrapper over print() to nicely output stuff but which unfortunately clashes (for some non-obvious reasons given the error trace)
from bayestestr.
Related Issues (20)
- Missing images in BF Vignette HOT 1
- Formatting probability of direction objects fails HOT 7
- Add support for data frames with an `rvar` column HOT 4
- Be consistent with return values across functions
- P-Direction in zero-inflated models HOT 10
- error using describe_posterior HOT 3
- bayestestR broken after revising `pd()`. HOT 13
- Iris data example for Bayes Factor: with or without random effect? HOT 3
- "LogBF = Inf" problem HOT 5
- Issues with blavaan HOT 2
- Workflow badges not updating? HOT 9
- Infinite probability? HOT 2
- mediation with censored data using brm and bayestestR
- Is a directional p_rope possible? HOT 1
- CRAN submission HOT 11
- Flexible ROPE values for describe_posterior HOT 1
- Question on contr.equalprior function
- `bayesian_as_frequentist()` fails for brms `0 + Intercept` formula HOT 4
- Avoid resampling priors for `brmsfit` objects that contain prior samples HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bayestestr.