Open fanne-stat opened 4 years ago
Sorry one line missing in the minimal example:
g_data <- mhglm_sim(n = 30, m_per_level = c(10, 5, 2), sd_intercept = c(1, 1, 1),
sd_slope = c(1, 1, 1), family = "gaussian", seed = 12345)
formula1 <- as.formula("y ~ 1 + x + (1 + x | g1/g2/g3)")
test_mhglm <- function(data){
formula1 <- as.formula("y ~ 1 + x + (1 + x | g1/g2/g3)")
mhglm_ml(formula = formula1, data = data)
}
test_mhglm(data = g_data)
I found there might be a bug in the function
mhglm_ml
: when the formula is defined in a function environment, theeval(mf$formula)
part will fail.A minimal example:
Here is the error:
I think this has to be related to the default setting
parent.frame()
in theeval
function.