Open DominiqueMakowski opened 2 years ago
Can't we use both? We must keep in mind that it still works with rstanarm
I don't know these models well enough to be confident, but I notice that the 3 rstantools
calls all use the same arguments. So perhaps we could use checks such as:
if (inherits(x, "brmsfit") && (utils::packageVersion("brms") >= "2.16.1")) {
args_list[["nsamples"]] <- iterations
} else {
args_list[["ndraws"]] <- iterations
}
Then we call each function with do.call
@DominiqueMakowski where do you get this warning?
library(insight)
library(rstanarm)
library(brms)
m1 <- stan_glm(mpg ~ wt, data = mtcars, iter = 500, chains = 2)
m2 <- brm(mpg ~ wt, data = mtcars, chains = 2, iter = 500)
get_predicted(m1)
#> Predicted values:
#>
#> [1] 23.263619 21.910620 24.855382 20.106621 18.912799 18.806681 18.223035
#> [8] 20.239268 20.451503 18.912799 18.912799 15.570096 17.374094 17.108800
#> [15] 9.309160 8.385937 8.805101 25.492087 28.596026 27.428733 24.086030
#> [22] 18.488329 18.939328 16.790448 16.763918 26.898145 25.810440 29.137225
#> [29] 20.345386 22.467737 18.223035 22.414678
#>
#> NOTE: Confidence intervals, if available, are stored as attributes and can be accessed using `as.data.frame()` on this output.
get_predicted(m2)
#> Predicted values:
#>
#> [1] 23.277567 21.910119 24.886328 20.086856 18.880285 18.773035 18.183155
#> [8] 20.220920 20.435421 18.880285 18.880285 15.501886 17.325149 17.057022
#> [15] 9.174091 8.241010 8.664650 25.529833 28.666917 27.487159 24.108760
#> [22] 18.451282 18.907098 16.735270 16.708457 26.950905 25.851585 29.213896
#> [29] 20.328171 22.473186 18.183155 22.419560
#>
#> NOTE: Confidence intervals, if available, are stored as attributes and can be accessed using `as.data.frame()` on this output.
get_predicted(m1, predict = "link")
#> Predicted values:
#>
#> [1] 23.263619 21.910620 24.855382 20.106621 18.912799 18.806681 18.223035
#> [8] 20.239268 20.451503 18.912799 18.912799 15.570096 17.374094 17.108800
#> [15] 9.309160 8.385937 8.805101 25.492087 28.596026 27.428733 24.086030
#> [22] 18.488329 18.939328 16.790448 16.763918 26.898145 25.810440 29.137225
#> [29] 20.345386 22.467737 18.223035 22.414678
#>
#> NOTE: Confidence intervals, if available, are stored as attributes and can be accessed using `as.data.frame()` on this output.
get_predicted(m2, predict = "link")
#> Predicted values:
#>
#> [1] 23.277567 21.910119 24.886328 20.086856 18.880285 18.773035 18.183155
#> [8] 20.220920 20.435421 18.880285 18.880285 15.501886 17.325149 17.057022
#> [15] 9.174091 8.241010 8.664650 25.529833 28.666917 27.487159 24.108760
#> [22] 18.451282 18.907098 16.735270 16.708457 26.950905 25.851585 29.213896
#> [29] 20.328171 22.473186 18.183155 22.419560
#>
#> NOTE: Confidence intervals, if available, are stored as attributes and can be accessed using `as.data.frame()` on this output.
packageVersion("brms")
#> [1] '2.16.1'
Created on 2021-10-14 by the reprex package (v2.0.1)
Oops I had incomplete info, it apparently happens with modelbased::get_predicted()
😬 , moving the issue
https://github.com/easystats/insight/blob/dca9e72ef426584073ee866e5c487d0115b12a78/R/get_predicted.R#L735
brms says:
Argument 'nsamples' is deprecated. Please use argument 'ndraws' instead.
We should probably update, but how to best make it so that we maintain compatibility with old versions?
tagging also @vincentarelbundock