The predict.spm function can be used to score new observations. It’s also worth noting that we can effectively control the degree of smoothing that we want for the nonparametric part by using the spar= parameter, or alternatively by specifying the degrees of freedom using the df= parameter, as shown in the following example:
fit <- spm(data_sim$y ~ data_sim$x1 + f(data_sim$x2,spar=20))
summary(fit)
plot(fit)
fit <- spm(data_sim$y ~ data_sim$x1 + f(data_sim$x2,df=6))
summary(fit)
plot(fit)