I have a GAMM that's multivariate. It's also a hurdle_gamma() model due to the presence of 0's throughout the dataset. I continuously get errors when attempting to run the model and I'm not sure where they are coming from.
model <- bf(mvbind(var1, var2, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15 ) ~ gear_type + s(effort, k = 55) + s(doy, bs = 'cc', k = 20) + s(landing_year, k = 22) + s(forest, k = 15) + s(herbaceous, k = 15) + s(open_water, k = 15) + s(X,Y, bs= 'ts', k = 44) + (1|boat_id) + (1|landing_mun) + (1|basin_id),
hu ~ gear_type + s(effort, k = 55) + s(doy, bs = 'cc', k = 20) + s(landing_year, k = 22) + s(forest, k = 15) + s(herbaceous, k = 15) + s(open_water, k = 15) + s(X,Y, bs= 'ts', k = 44) + (1|boat_id) + (1|landing_mun) + (1|basin_id)) + hurdle_gamma()
M1 <-
brm(formula = model,
data = completed_catch_data,
iter = 2000,
warmup = 1000,
cores = 4,
save_warmup = FALSE)
I get the following error: Compiling Stan program... Error in stanc(file = file, model_code = model_code, model_name = model_name, : parser failed badly
I've tried the recommended steps of uninstalling rstan and StanHeaders and reinstalling the github libraries for rstan and StanHeaders. I've double checked that my RTools C++ toolchain was downloaded and installed. What other explanations are there for this error?
I also looked into running the same model for just one variable to see if the error persists. Instead, the model starts to run, but then generates the error:
Chain 1: Rejecting initial value:
Chain 1: Error evaluating the log probability at the initial value.
Chain 1: Exception: Exception: gamma_lpdf: Inverse scale parameter is 0, but must be positive finite! (in 'string', line 34, column 6 to line 35, column 41) (in 'string', line 34, column 6 to line 35, column 41)
This seems to suggest that the error from my multivariate model is not due to issues with stan, since stan runs when there is only 1 variable in the model. The column 6 where the error originates corresponds to my random factor for landing_mun, which is the name of the municipality. Do these have to be integers instead of a string? There are no errors with gear_type which is also a string/factor.
An example multivariate model using brms data works without error.
fit1 <- brm(mvbind(zBase, zAge) ~ visit * count * Trt + (1|patient),
data = epilepsy, cores = 4)
Insight appreciated.
- Operating System: Windows 11
- brms Version: 2.19.0
- R version 4.3.1
- RTools43