R caret.train in method=“gam"中的错误 [英] Error in R caret.train in method="gam"

查看:32
本文介绍了R caret.train in method=“gam"中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试使用 gam 作为 caret.train 函数中的方法时,都会出错.

I am having an error whenever I try to use gam as a method in caret.train function.

fit<- train(P~log(DR)+log(L2M)+s(TSM)+s(TH)+s(II),data=training,method="gam")错误:$ 运算符对原子向量无效

这是警告之一:

In eval(expr, envir, enclos) :
model fit failed for Resample16: select=FALSE, method=GCV.Cp

为什么会这样?当我只使用 gam 时,一切都很好,这只发生在 caret 包中.

Why is this happening? When I just use gam everything is fine, this only happens with caret package.

dput(head(training)) 输出:

structure(list(TT = c(1.810376, 0.089206, 0.623906, 0.676775, 
0.206524, 1.014849), P = c(682L, 674L, 681L, 679L, 655L, 682L
), II = c(846000000L, 4790000L, 38600000L, 40600000L, 1379632L, 
7526080L), WSM = c(5272L, 144L, 576L, 576L, 2336L, 18696L), TSM = c(168704L, 
4608L, 18432L, 18432L, 74752L, 598272L), L2M = c(1.49e+09, 12600000, 
85700000, 1.24e+08, 4214560, 33560200), DR = c(2.52e+09, 18400000, 
1.3e+08, 1.8e+08, 5559030, 44681000), DW = c(11600000L, 5440000L, 
39600000L, 46400000L, 4920550L, 36812430L), TH = c(32.032843125, 
0.1880727305, 0.2003506939, 0.1983195715, 0.558498625, 0.495952125
)), .Names = c("TT", "P", "II", "WSM", "TSM", "L2M", "DR", "DW", 
"TH"), row.names = c(3L, 5L, 7L, 8L, 9L, 10L), class = "data.frame")

推荐答案

据我所知,caret 使用新的 mgcv 包用于 gam函数;我附上了gam"的旧实现 - gam 库.当我分离 gam 库并且只使用 mgcv.gam 时,这个问题就解决了.

As far as I understand, caret uses the new mgcv package for gam functions; I had attached the older implementation of "gam" - the gam library. When I detached the gam library and only used mgcv.gam, this issue was resolved.

这篇关于R caret.train in method=“gam"中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆