[英]Error in gam function of smoothing spline regression
I'm trying to run a smoothing spline regression using gam for y as a function of a and b, variables in the dataset. 我正在尝试使用gam for y作为数据集中变量a和b的函数运行平滑样条回归。 But when I run the following code, I get the following error.
但是,当我运行以下代码时,出现以下错误。
> autogam_axb <- gam(data$y~s(data$a,data$b))
Error in eval(expr, envir, enclos) : object 'a' not found
Any idea what I am doing wrong? 知道我在做什么错吗?
You need to separate the model specification from the locations of the data. 您需要将模型规范与数据位置分开。 The former is specified via the formula, whilst the
data
argument is used to tell gam
about the latter: 前者通过公式指定,而
data
参数用于告知gam
后者:
autogam_axb <- gam(y ~ s(a, b), data = data)
This serves two purposes: 这有两个目的:
data$
, which makes it easier to see what it being fitted, and data$
弄乱,这使得查看模型的适应性变得更加容易,并且
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.