r - GAM prediction with interactions -


what routine predicting using generalized additive models including interactions r library gam?

library("gam") x <- data.frame(a=runif(100,1,10), b=runif(100,1,10)) x$y <- x$a*x$b  res <- gam(as.formula("y ~ s(a) + s(b)"), data=x[1:90,]) pred <- predict(res, x[91:100,], type="response")  res <- gam(as.formula("y ~ s(a) + s(b) + s(a,b,df=2)"), data=x[1:90,]) pred <- predict(res, x[91:100,], type="response") 

works fine initial model without interactions. latter model including interactions learned in meaningful way, trying predict results in error:

error in gam.s(data[["s(a, b, df = 2)"]], z, w, spar = b, df = 2, xeval = smooth.frame[["s(a, b, df = 2)"]]) : object 'b' not found 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -