Code Monkey home page Code Monkey logo

Comments (9)

mattansb avatar mattansb commented on July 17, 2024

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.

strengejacke avatar strengejacke commented on July 17, 2024

Yeah, nothing of the error indicates that it could be an issue with the hdi() function.

from bayestestr.

strengejacke avatar strengejacke commented on July 17, 2024

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.

poldrack avatar poldrack commented on July 17, 2024

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.

mattansb avatar mattansb commented on July 17, 2024

@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.

poldrack avatar poldrack commented on July 17, 2024

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.

strengejacke avatar strengejacke commented on July 17, 2024

Thank you for checking this more closely! I agree, it seems that nothing needs to be done from our side.

from bayestestr.

poldrack avatar poldrack commented on July 17, 2024

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.

DominiqueMakowski avatar DominiqueMakowski commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.