Closed FatemahSakr closed 10 months ago
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?
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
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
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 selectedTo 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):