简体   繁体   English

带有gam s()包装器的ExtractVars中的无效模型公式

[英]invalid model formula in ExtractVars with gam s() wrapper

What I am trying to do is simple. 我想做的很简单。 Trying to fit a gam model where I can decide the df of the smoomthing spline (the 's' function in the formula part). 试图拟合一个gam模型,在此我可以确定decide花键样条线的df(公式部分中的“ s”函数)。 Calling the gam model should return the fit, but yet it gives error. 调用gam模型应该返回拟合值,但是会给出错误。 What am I doing wrong here? 我在这里做错了什么?

    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)

Apparently was related to the mcgv package and to the version of 'gam'. 显然与mcgv软件包和'gam'版本有关。 Using gam '1.14' and not using mcgv worked. 使用gam'1.14'而不使用mcgv是可行的。 Example: 例:

    library(ISLR)
    attach(Wage)
    library(gam)
    fit = gam(wage ~ s(year, 4) + s(age, 5) +   education, data = Wage)
    plot(fit)
    summary(fit)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM