Skip to content

varImp issue for GAMs #1407

@potoole7

Description

@potoole7

rownames(gams) <- gsub("^s\\(", "", rownames(gams))

This line won't work with different smoothers to s(), such as te, and also won't work for 2D splines, e.g. s(x1, x2).

Reprex:

library(mgcv)
library(caret)

set.seed(2) ## simulate some data... 
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gam(y~s(x0)+te(x1, x2), data = dat)
varImp(b)
# Error in if (any(extras)) { : missing value where TRUE/FALSE needed

c <- gam(y~s(x0)+s(x1, x2), data = dat)
varImp(c)
# Error in if (any(extras)) { : missing value where TRUE/FALSE needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions