Imputation during model fitting - Weibull Error

I am trying to impute missing data during model fitting similar to the vignette, but running in to a stan error when I try to use weibull()

For example, using the vignette’s data set, this runs properly:

data("nhanes", package = "mice")
bform <- bf(bmi | mi() ~ age * mi(chl), family=gaussian()) +
  bf(chl | mi() ~ age, family=gaussian()) + set_rescor(FALSE)
fit_imp2 <- brm(bform, data = nhanes)

While this does not:

bform <- bf(bmi | mi() ~ age * mi(chl), shape ~ age, family=weibull()) +
  bf(chl | mi() ~ age, family=gaussian()) + set_rescor(FALSE)
fit_imp3 <- brm(bform, data = nhanes)

Throwing this error:

SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for: 

  int / vector

Available argument signatures for operator/:

  int / int
  real / real
  vector / real
  row_vector / real
  matrix / real

No matches for: 

  int + ill-formed

Available argument signatures for operator+:

  int + int
  real + real
  vector + vector
  row_vector + row_vector
  matrix + matrix
  vector + real
  row_vector + real
  matrix + real
  real + vector
  real + row_vector
  real + matrix
  +int
  +real
  +vector
  +row_vector
  +matrix

Expression is ill formed.
 error in 'model30105dbc5997_file3010178b4e4d' at line 77, column 60
  -------------------------------------------------
    75:   for (n in 1:N_warp) {
    76:     // apply the inverse link function
    77:     mu_warp[n] = exp(mu_warp[n]) / tgamma(1 + 1 / shape_warp);
                                                                   ^
    78:   }
  -------------------------------------------------

Error in stanc(model_code = paste(program, collapse = "\n"), model_name = model_cppname,  : 
  failed to parse Stan model 'file3010178b4e4d' due to the above error.
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for: 

  int / vector

Available argument signatures for operator/:

  int / int
  real / real
  vector / real
  row_vector / real
  matrix / real

No matches for: 

  int + ill-formed

Available argument signatures for operator+:

  int + int
  real + real
  vector + vector
  row_vector + row_vector
  matrix + matrix
  vector + real
  row_vector + real
  matrix + real
  real + vector
  real + row_vector
  real + matrix
  +int
  +real
  +vector
  +row_vectorSYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for: 

  int / vector

Available argument signatures for operator/:

  int / int
  real / real
  vector / real
  row_vector / real
  matrix / real

No matches for: 

  int + ill-formed

Available argument signatures for operator+:

  int + int
  real + real
  vector + vector
  row_vector + row_vector
  matrix + matrix
  vector + real
  row_vector + real
  matrix + real
  real + vector
  real + row_vector
  real + matrix
  +int
  +real
  +vector
  +row_vector
  +matrix

Expression is ill formed.
 error in 'model3010622862fa_file30105341edc' at line 85, column 57
  -------------------------------------------------
    83:   for (n in 1:N_bmi) {
    84:     // apply the inverse link function
    85:     mu_bmi[n] = exp(mu_bmi[n]) / tgamma(1 + 1 / shape_bmi);
                                                                ^
    86:   }
  -------------------------------------------------

Error in stanc(model_code = paste(program, collapse = "\n"), model_name = model_cppname,  : 
  failed to parse Stan model 'file30105341edc' due to the above error.
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for: 

  int / vector

Available argument signatures for operator/:

  int / int
  real / real
  vector / real
  row_vector / real
  matrix / real

No matches for: 

  int + ill-formed

Available argument signatures for operator+:

  int + int
  real + real
  vector + vector
  row_vector + row_vector
  matrix + matrix
  vector + real
  row_vector + real
  matrix + real
  real + vector
  real + row_vector
  real + matrix
  +int
  +real
  +vector
  +row_vector
  +matrix

Expression is ill formed.
 error in 'model30101e25dc47_file30105341edc' at line 85, column 57
  -------------------------------------------------
    83:   for (n in 1:N_bmi) {
    84:     // apply the inverse link function
    85:     mu_bmi[n] = exp(mu_bmi[n]) / tgamma(1 + 1 / shape_bmi);
                                                                ^
    86:   }
  -------------------------------------------------

Error in stanc(model_code = paste(program, collapse = "\n"), model_name = model_cppname,  : 
  failed to parse Stan model 'file30105341edc' due to the above error.

Any help would be much appreciated. Thanks so much for your time and attention!

Brian

  • Operating System: Ubuntu
  • brms Version: 2.12.0

This looks like a bug to me. I will check it out tomorrow.

This issue should now be fixed in the github version of brms. Thanks for reporting it!

Awesome, thanks so much for the quick fix!