我想做的很简单。尝试拟合gam模型,我可以决定smoomthing样条的df(公式部分中的' s'函数)。调用gam模型应返回拟合,但它会给出错误。我在这里做错了什么?
library(mgcv)
library(gam)
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gam(y~s(x0,df = 5)+s(x1)+s(x2)+s(x3),data=dat)
答案 0 :(得分:0)
显然与mcgv包和'gam'版本有关。使用gam'1.14'并且不使用mcgv工作。例如:
library(ISLR)
attach(Wage)
library(gam)
fit = gam(wage ~ s(year, 4) + s(age, 5) + education, data = Wage)
plot(fit)
summary(fit)