1
$\begingroup$

Hi there would someone be able to explain to me how the s(x1) terms work in the GAMS?

For instance in the equation:

gam(response ~ s(x1) + s(x2) + s(x3))

Would each smoother variable be “accounting for the influence on each other and on the response” after than gam was ran? In other words, would the graph produced between the response variable and x1 also account for the influence of x2 and x3 on the response? If not, if there a way to account for this interaction?

In addition to this, I'm wondering if this was a built model for one dataset could it be used on a different dataset to predict and generate values for the response variable of interest if I had data for x1, x2, and x3?

I'm admittedly a beginner to GAMs in R so I'm having a hard time even knowing that vocab to find out how to understand this problem. I really appreciate any advice or insight anyone has.

$\endgroup$
1
  • 2
    $\begingroup$ These are very basic questions which are answered by basic documentation and tutorials. GAM stands for "generalized additive model", note the "additive" part. That means your example doesn't model interactions. However, mgcv provides interaction smoothers, see help("te"). Study help("predict.gam") to learn how to predict from the model with new data. $\endgroup$
    – Roland
    Commented Feb 28 at 7:06

1 Answer 1

1
$\begingroup$

I provided the following answer to exactly the same questions sent to me directly by email. I hadn't noticed that this had been asked on [so] or here before replying privately.

GAMs work just like other regression models, they just don't enforce a particular parametric relationship between covariates and the response.

The model

gam(y ~ s(x1) + s(x2) + s(x3)

estimates smooth effects of x1 conditional upon the smooth effects of the two other covariates, and vice versa. But then you mention "interaction" so I wonder if you mean is the effect of x1 allowed to vary with either one or both of the other covariates' effects? If so, no; this model is an additive model.

If you want the equivalent of an interaction but for smooths, you would need to fit

gam(y ~ te(x1, x2, x3))

but you'd need a lot of data to estimate a 3D smooth like this because of the curse of dimensionality.

You can use GAM for prediction; mgcv has a predict() method where you can supply new values of the covariates. Just be careful not to predict outside the observed range of your covariates unless you know what you are doing and what the implications are.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.