Skip to content
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

error using describe_posterior #617

Closed
FatemahSakr opened this issue Jul 28, 2023 · 3 comments
Closed

error using describe_posterior #617

FatemahSakr opened this issue Jul 28, 2023 · 3 comments
Labels
Won't fix 🚫 This will not be worked on

Comments

@FatemahSakr
Copy link

Describe the bug
I have updated my macOS to Monterey (12.6.7) then my R, Rstudio (now version 4.2.2).
I tried to run my script using stan_glm and describe posterior, the models run fine however describe_posteribe through this error:
Error in [.data.frame(model_data, , rn, drop = FALSE) :
undefined columns selected

To Reproduce

m <- stan_glm(scale(X[,14]) ~ age_sampl_mn_frac + genotype ,
data = X,
seed =111, chains = 4, cores= cpu.cores,
iter= 10000,adapt_delta = 0.95,
diagnostic_file = file.path(tempdir(), "df1.csv"))

xx <- describe_posterior(m, centrality = "median", dispersion = TRUE,
ci= my.prob, ci_method= "HDI",
test = c( "p_direction", "bayesfactor"))

Specifiations (please complete the following information):

  • Package Version [ 0.13.1.2]
@strengejacke
Copy link
Member

This could still be a bug from #618. There are also some tests failing, seems like not all remaining bugs have been fixed yet. @mattansb @DominiqueMakowski any idea?

@mattansb
Copy link
Member

mattansb commented Sep 8, 2023

This is is due to the DV being a non-proper column name X[,14].

library(rstanarm)
library(bayestestR)

m1 <- stan_glm(scale(mtcars[, 9]) ~ hp,
               data = mtcars, 
               cores = 4, refresh = 0)

m2 <- stan_glm(scale(am) ~ hp,
               data = mtcars, 
               cores = 4, refresh = 0)

describe_posterior(m1, test = c("p_direction", "bayesfactor"))
#> Error in `[.data.frame`(model_data, , rn, drop = FALSE) : 
#>   undefined columns selected


describe_posterior(m2, test = c("p_direction", "bayesfactor"))
#> Warning message:
#> Bayes factors might not be precise.
#>   For precise Bayes factors, sampling at least 40,000 posterior samples is recommended.
#> Summary of Posterior Distribution 
#> 
#> Parameter   |    Median |        95% CI |     pd |    BF |  Rhat |     ESS
#> --------------------------------------------------------------------------
#> (Intercept) |      0.52 | [-0.31, 1.37] | 89.20% | 0.177 | 1.000 | 3165.00
#> hp          | -3.51e-03 | [-0.01, 0.00] | 90.90% | 0.179 | 1.000 | 3638.00

@strengejacke
Copy link
Member

Here's the source of the error:

library(insight)
m1 <- lm(scale(mtcars[, 9]) ~ hp,
               data = mtcars)
insight::find_response(m1)
#> [1] "mtcars"
insight::get_response(m1)
#> Error in `[.data.frame`(model_data, , rn, drop = FALSE): undefined columns selected

Created on 2023-09-30 with reprex v2.0.2

@strengejacke strengejacke added the Won't fix 🚫 This will not be worked on label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't fix 🚫 This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants