Contents
Can a GAM be used as a GLM?
That’s not to say that GAM’s are just a special case of GLM’s though! While there are a series of models that exactly identical and can be framed as both a GAM or as a GLM with a spline expansion of the covariates, there are some GAM models that are not available in the standard GLM framework.
Can a non linear spline be used in a GAM model?
But the splines trick is still handy. For instance, you can quickly modify an existing linear model to have a non-linear spline. Or use it in a Bayesian linear model that doesn’t have a GAM equivalent ( you can also spit out model matrices from mgcv and use them in Bayesian models if you want other types of splines).
Which is better for GLm 3 or 2 splines?
Yep, the 3 spline model has a much lower AIC despite using more model D.F., so is better. A nice feature of this cubic spline trick is that you can use it anywhere that takes a model matrix as input. So it will work with and any Bayesian GLM method you care to use.
What’s the difference between GAM and fitted for M1?
This is what fitted.gam will be doing for m1 because it represents the random effect as a spline “fixed” effect. In the case of the gamm model, fitted.gam is returning fitted values for the “fixed” effect part of the model, which would explain the difference.
When to use GLM for generalized linear models?
glm is used to fit generalized linear models, specified by giving a symbolic description of the linear predictor and a description of the error distribution.
How is the link function used in GLM?
In the linear model, the link function links the weighted sum of the features to the mean of the Gaussian distribution. Under the GLM framework, this concept generalizes to any distribution (from the exponential family) and arbitrary link functions.
Can a linear model be used with the gam function?
We could use the standard R lm function, but I’ll leave that as an exercise for comparison. We can still do straightforward linear models with the gam function, and again it is important to note that the standard linear model can be seen as a special case of a GAM. What are we getting here?