stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
388 stars 133 forks source link

error earlier if outcome is character #524

Closed jgabry closed 3 years ago

jgabry commented 3 years ago

fixes #341

This affects models using stan_glm.fit as well as stan_jm and stan_mvmer, which use the same internal validate_glm_outcome_support that stan_glm.fit does.

Previous error message:

f1 <- stan_lmer(formula = as.character(logBili) ~ 1 + (1 | id), 
                 data = pbcLong, 
                 chains = 1)

Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) : 
  Exception: variable does not exist; processing stage=data initialization; variable name=y; base type=vector_d  (in 'model_continuous' at line 32)

In addition: Warning message:
In FUN(X[[i]], ...) : data with name y is not numeric and not used
failed to create the sampler; sampling not done
Error in check_stanfit(stanfit) : 
  Invalid stanfit object produced please report bug
Error in dimnamesGets(x, value) : 
  invalid dimnames given for “dgCMatrix” object

New error message:

f1 <- stan_lmer(formula = as.character(logBili) ~ 1 + (1 | id), 
                 data = pbcLong, 
                 chains = 1)

Error: Outcome variable can't be type 'character'.
jgabry commented 3 years ago

Thanks!