I have run into some difficulty using tab_model and plot_model with rstan models. Both functions throw a transform error and a warning about not being able to access model information.
I have not been able to find a worked example, but it does seem rstan models are supported according to this post.
Perhaps I need to modify the syntax of how I'm calling the strengejacke functions on rstan fits?
A reprex:
# List of needed packages
Pkgs <- c("rstan", "strengejacke")
# Load packages
lapply(Pkgs, require, c = T)
fit <- stan(
model_code = "// 8 Schools Example (r)Stan Model
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
vector[J] eta;
}
transformed parameters {
vector[J] theta;
theta = mu + tau * eta;
}
model {
target += normal_lpdf(eta | 0, 1);
target += normal_lpdf(y | theta, sigma);
}
",
data = list(
J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18)
),
chains = 1,
warmup = 500,
iter = 1000,
cores = 1,
refresh = 0
)
Error calling tab_model
tab_model(fit)
Error in if (fam.info$is_linear) transform <- NULL else transform <- "exp" :
argument is of length zero
In addition: Warning message:
Could not access model information.
Error calling plot_model
plot_model(fit)
Error in if (fam.info$is_linear) transform <- NULL else transform <- "exp" :
argument is of length zero
In addition: Warning message:
Could not access model information.
Sorry, that post was probably a bit imprecise. Actually, you can use models from packages like brms or rstanarm, which rely on rstan. Stan models fitted from package rstan won't work.
I have run into some difficulty using
tab_model
andplot_model
withrstan
models. Both functions throw a transform error and a warning about not being able to access model information.I have not been able to find a worked example, but it does seem
rstan
models are supported according to this post.Perhaps I need to modify the syntax of how I'm calling the strengejacke functions on
rstan
fits?A reprex:
Error calling
tab_model
Error calling
plot_model