我一直关注R的'many models' chapter数据科学。我已经能够适应我的模型并将它们存储为一个列表列中的列表。这非常棒,使存储更简单。问题似乎是处理每个模型条目有点笨拙,因为我有这种格式。例如:
model_table %>%
dplyr::filter(! unlist(map(model_fit, is.null))) %>%
dplyr::mutate("GAIC" = unlist(purrr::map(model_fit, gamlss::GAIC)),
"BIC" = unlist(purrr::map(model_fit, BIC)),
"AIC" = unlist(purrr::map(model_fit, AIC)),
"deviance" = unlist(purrr::map(model_fit, deviance)),
"df.residual" = unlist(purrr::map(model_fit, df.residual)),
"log. Likelihood" = unlist(purrr::map(model_fit, logLik)),
"converged" = unlist(purrr::map(model_fit, function(x) x$converged))) %>%
dplyr::ungroup() %>%
dplyr::mutate("dBIC" = round(BIC - min(BIC), 2),
"dAIC" = round(AIC - min(AIC), 2)) %>%
dplyr::arrange(dBIC)
我反复使用函数unlist(purrr::map(..., ...))
,这让我觉得我没有正确地做到这一点。
这样做有更标准或更明智的方法吗?