Contents
- 1 How to choose the right number of knots for a GAM?
- 2 Is the unknot a knot in knot theory?
- 3 How are mathematical knots different from regular knots?
- 4 Can you see the difference in the locations of knots?
- 5 Where can I find GAM methods in R?
- 6 Why do I want to use Gam for my model?
- 7 How to choose the number of knots in mgcv?
How to choose the right number of knots for a GAM?
When selecting an appropriate number of knots for a GAM one might want to take into account the number of data and increments on the x-axis. What if we have 100 increments on the x-axis with 1000 data points at each increment.
Is the unknot a knot in knot theory?
Well, a loop like the one at the left is considered a knot in mathematical knot theory (it is a simple closed curve in 3-dimensional space). In fact this knot has a special name: the unknot. The unknot can be drawn with no crossings, and is also called a trivial knot.
What is a knot in three dimensional space?
A knot, mathematically speaking, is a closed curve sitting in three dimensional space that does not intersect itself. Intuitively if we were to take a piece of string, cord, or the like, tie a knot in it and then glue the loose ends together, we would have a knot.
How are mathematical knots different from regular knots?
Tie a knot in it. Now, glue or tape the ends together. You have created a mathematical knot. The last step, joining the ends of the rope, is what differentiates mathematical knots from regular knots. The kinds of knots mathematicians work with are always formed on a closed loop (no loose ends).
Can you see the difference in the locations of knots?
You can see the difference in knots placement. You can also provide your customized knots locations via the knots argument of gam () (yes, knots are not fed to s (), but to gam () ). For example, you can do evenly spaced knots for cr: However, there is usually no need to set knots yourself.
How to plot a smooth line using GAM?
When using gam () in mgcv, turn GCV on by setting k to equal -1. To plot your smooth line you will have to extract the model fit. This should do the trick: You can also adjust k manually, and see what number of k brings you closest to the k value set automatically by GCV.
Where can I find GAM methods in R?
GAM methods are implemented in R in the awesome package mgcv by Simon Wood ( link to mgcv ). For visualizations packages ggplot2, grid and animation will be used. One useful function from package car will be used too. Let’s scan all of the needed packages.
Why do I want to use Gam for my model?
As mentioned in the intro, there are at least three good reasons why you want to use GAM: interpretability, flexibility/automation, and regularization. Hence, when your model contains nonlinear effects, GAM provides a regularized and interpretable solution – while other methods generally lack at least one of these three features.
Do you need to choose knot locations for thin plate splines?
You don’t need to choose knot locations with the thin plate splines (there is a knot at each unique data value, and then a low-rank version of the full basis expansion with k basis functions is found) and for most of the less exotic bases, knot placement typically makes little to no difference on the fitted model.
How to choose the number of knots in mgcv?
This post (link below) alludes to setting the basis dimension to -1 (k = -1) as automatically choosing the number of knots via Generalized Cross Validation (GCV) in R’s mgcv package: except that k is NOT the number of knots. I’ve only come across this specific instance of setting k = -1.