简体   繁体   中英

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). Calling the gam model should return the fit, but yet it gives error. 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'. Using gam '1.14' and not using mcgv worked. Example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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