When you add a variable you use +
not cbind.
vgam
parses the formula using terms.formula
to look for specials = 's'
, i.e. terms that are wrapped in s
signifying a spline.
Therefore
vgt2 = vgam(y~s(x, df=2)+s(z, df=2), data=df,family=gaussianff, trace=TRUE)
will give you what you want (and this has a lower deviance than vgt1
).
When you fit
vgt2 = vgam(y~cbind(s(x, df=2),s(z, df=2)), data=df,family=gaussianff, trace=TRUE)
terms.formula
doesn't find any specials
that start with s
, as cbind
is the function that identifies the term in the formula. Therefore
gam(y~cbind(s(x, df=2),s(z, df=2)), data=df,family=gaussianff, trace=TRUE)
is the equivalent of
gam(y~cbind(x,y), data=df,family=gaussianff, trace=TRUE)
which in term is the equivalent of
vgam(y~x+z, data=df,family=gaussianff, trace=TRUE)
i.e. no spline terms are fitted.