data <- read.csv("cen_data.csv", header = T)
priors_IG = c(
set_prior('normal(1.08, .008)',class="Intercept"),
set_prior('normal(.04, .006)',coef = "weightLow"),
set_prior('normal(.009, .009)',coef="std_speed"),
set_prior('normal(.003, .008)',coef="std_ratio"),
set_prior('normal(-0.001, .006)',coef="weightLow:std_speed"),
set_prior('normal(-0.014, .006)',coef="weightLow:std_ratio"),
set_prior('normal(-0.012, .007)',coef="std_speed:std_ratio"),
set_prior('normal(.0148, .005)',coef="weightLow:std_speed:std_ratio")
)
# fit model using Gamma
fit_brm_GM <- brm(effect ~ weight * std_speed * std_ratio + (1|subject),
data = data, family = Gamma, prior = priors_IG,
sample_prior = TRUE, thin = 5, iter = 2e3,
save_all_pars = TRUE, init_r = 2,
control = list(adapt_delta = .99, max_treedepth = 15))
# SAMPLING FOR MODEL '2447381a3f586e34cddd5f72cad7c9be' NOW (CHAIN 1).
# Chain 1: Rejecting initial value:
# Chain 1: Error evaluating the log probability at the initial value.
# Chain 1: Exception: gamma_lpdf: Inverse scale parameter[7] is -5.89104,
# but must be > 0! (in 'model5a750f1e21c_2447381a3f586e34cddd5f72cad7c9be' at line 57)
# fit model using inverse gaussian
fit_brm_IG <- brm(effect ~ weight * std_speed * std_ratio + (1|subject),
data = data, family = inverse.gaussian, init_r = 6,
prior = priors_IG, sample_prior = TRUE, thin = 5, iter = 2000,
save_all_pars = TRUE)
#SAMPLING FOR MODEL 'daacb255a9526e3cd27ac4cbb42d5b79' NOW (CHAIN 1).
#Chain 1: Rejecting initial value:
# Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#Chain 1: Stan can't start sampling from this initial value.
# refit the model according to the suggestion
fit_brm_IG2 <- brm(effect ~ weight * std_speed * std_ratio + (1|subject),
data = data, family = inverse.gaussian(link = "identity"), init_r = 6,
prior = priors_IG, sample_prior = TRUE, thin = 5, iter = 2000,
save_all_pars = TRUE, control = list(adapt_delta = .99, max_treedepth = 27))
summary(fit_brm_IG2)
# Warning message:
# The model has not converged (some Rhats are > 1.1). Do not analyse the results!
# We recommend running more iterations and/or setting stronger priors.
I have question when using the package brms. The distribution of our data doesn’t seem to be normal from the result of Shapiro test. So instead, we did other analysis and found out the data could be Gamma or inverse gaussian. However, when we fitted these two models, we always got the same error message:
SAMPLING FOR MODEL ‘8c9b4de377ac0bac1ad8558834116464’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
After that, we modified the parameter according to the hints, and refitted the model. In this case, we did get the result, but the model doesn’t converge.
So is there any answer to these phenomenon?