openpharma / mmrm

Mixed Models for Repeated Measures (MMRM) in R.
https://openpharma.github.io/mmrm/
Other
101 stars 17 forks source link

L-BFGS-B divergence however error code is not correct #423

Closed clarkliming closed 5 months ago

clarkliming commented 5 months ago

when fitting mmrm we can run into such issue

Warning message:
In mmrm(FEV1 ~ AVISIT + us(AVISIT | USUBJID), data = fev) :
  Divergence with optimizer L-BFGS-B due to problems: L-BFGS-B needs finite values of 'fn'

and immediately

Error in UseMethod("logLik") : 
  no applicable method for 'logLik' applied to an object of class "c('mmrm_fit', 'list')"

The reason is that L-BFGS-B final status is warning instead of error.

reprex.

fev = data.table::data.table(fev_data)

fev[seq(1, 800, 4), FEV1 := 0]

mmrm(FEV1 ~ AVISIT + us(AVISIT|USUBJID), data = fev)
clarkliming commented 5 months ago

related to #311 but I wonder why for these divergent values we still want to keep them as "success"? Is there any cases that this error is reported however a result is also returned? @danielinteractive

danielinteractive commented 5 months ago

Thanks @clarkliming , maybe there was a change in the optim here, but yeah in principle this should be an error I guess. Maybe just need to adapt the filter for warnings in the helper functions?