R语言 predict() 函数中 'type' 参数错误:解决方法
在 R 语言中使用 predict() 函数时,您可能会遇到以下错误:
'Error in match.arg(type) : \n 'arg' should be one of “lp”, “fitted”, “fitted.ind”, “mean”, “x”, “data.frame”, “terms”, “cterms”, “ccterms”, “adjto”, “adjto.data.frame”, “model.frame”'
这个错误可能是由于您提供的 'type' 参数值不正确而导致的。请确保提供的 'type' 参数值是 'lp', 'fitted', 'fitted.ind', 'mean', 'x', 'data.frame', 'terms', 'cterms', 'ccterms', 'adjto', 'adjto.data.frame', 'model.frame' 中的一个。
您可以尝试使用以下代码进行预测:
test_prob <- predict(f1, newdata = test, type = 'response', na.action = na.pass)
在这个代码中,我们添加了一个额外的参数 'na.action = na.pass',以确保在遇到缺失值时不会出现任何错误。
原文地址: https://www.cveoy.top/t/topic/ool9 著作权归作者所有。请勿转载和采集!