44 votes
Accepted

Adaptive GAM smooths in mgcv

Most of the extra smooths in the mgcv toolbox are really there for specialist applications — you can largely ignore them for general GAMs, especially univariate smooths (you don't need a random ...
Gavin Simpson's user avatar
41 votes
Accepted

Can degrees of freedom be a non-integer number?

Degrees of freedom are non-integer in a number of contexts. Indeed in a few circumstances you can establish that the degrees of freedom to fit the data for some particular models must be between some ...
Glen_b's user avatar
  • 278k
34 votes
Accepted

When to use a GAM vs GLM

The main difference imho is that while "classical" forms of linear, or generalized linear, models assume a fixed linear or some other parametric form of the relationship between the dependent variable ...
matteo's user avatar
  • 3,163
33 votes

How I can interpret GAM results?

The deviance explained is a bit like $R^2$ for models where sums of squares doesn't make much sense as a measure of discrepancy between the observations and the fitted values. In generalised models ...
Gavin Simpson's user avatar
29 votes
Accepted

Summary of a GAM fit

The way the output of this approach to fitting GAMs is structured is to group the linear parts of the smoothers in with the other parametric terms. Notice Private ...
Gavin Simpson's user avatar
28 votes
Accepted

Generalized Additive Model Python Libraries

I've written a Python implementation of GAMs using penalized B-splines. check it out here: https://github.com/dswah/pyGAM I've included lots of link functions, distributions and features.
dswah's user avatar
  • 441
26 votes

When to use a GAM vs GLM

I'd emphasize that GAMs are much more flexible than GLMs, and hence need more care in their use. With greater power comes greater responsibility. You mention their use in ecology, which I have also ...
Wayne's user avatar
  • 20.8k
24 votes
Accepted

ANOVA to compare models

The output from anova() is a series of likelihood ratio tests. The lines in the output are: The first line in the output corresponds to the simplest model with ...
Gavin Simpson's user avatar
23 votes

Selecting knots for a GAM

Where is the idea coming from that GCV will automatically choose the number of knots? The number of knots (i.e., the basis dimension) is fixed and cannot be changed during model fit. What the GCV ...
nukimov's user avatar
  • 652
21 votes

Generalized additive models -- who does research on them besides Simon Wood?

There are many researchers on GAMs: it's just that basically the same model (GLM with linear predictor given by sum of smooth functions) is given lots of different names. You'll find models that you ...
Simon Wood's user avatar
21 votes
Accepted

R/mgcv: Why do te() and ti() tensor products produce different surfaces?

These are superficially the same model but in practice when fitting there are some subtle differences. One important difference is that the model with ti() terms is ...
Gavin Simpson's user avatar
21 votes

Smoothing methods for gam in mgcv package?

mgcv uses a thin plate spline basis as the default basis for it's smooth terms. To be honest it likely makes little difference in many applications which of these you choose, though in some situations ...
Gavin Simpson's user avatar
20 votes
Accepted

Model selection for GAM in R

If you want to select from among a group of covariates, then a principled way of doing this is to put some additional shrinkage on each of the smoothers in the model so that they can be penalised out ...
Gavin Simpson's user avatar
19 votes
Accepted

GAM vs LOESS vs splines

What matters the most is the number of effective degrees of freedom that you give to each approach. For nonparametric smoothers such as loess this is controlled by the bandwidth whereas for ...
Frank Harrell's user avatar
19 votes
Accepted

Can I use bootstrapping to estimate the uncertainty in a maximum value of a GAM?

An alternative approach that can be used for GAMs fitted using Simon Wood's mgcv software for R is to do posterior inference from the fitted GAM for the feature of interest. Essentially, this involves ...
Gavin Simpson's user avatar
19 votes
Accepted

Generalized additive models (GAMs), interactions, and covariates

Q1 What's the difference between models 3 and 4? Model 3 is a purely additive model $$y = \alpha + f_1(x) + f_2(w) + \varepsilon$$ so we have a constant $\alpha$ plus the smooth effect of $x$ plus ...
Gavin Simpson's user avatar
18 votes
Accepted

Analysed non-linear data with GAM regression, but reviewer has suggested fitting exponential or logarithmic curves instead. Which to use?

In addition to Demetri's answer (+1): The use of GAM is well-established in the field of Ecology so I would add certain books/influential articles. Show you are not reinventing the wheel rather that ...
usεr11852's user avatar
  • 42.6k
17 votes
Accepted

Two methods of adding random effects to a GAM give very different results. Why is this and which one should be used?

I suspect the difference is in terms of what fitted values you are getting. If you look at what I would call the model fit, the coefficient estimates, variance terms, the models are identical. Compare ...
Gavin Simpson's user avatar
16 votes
Accepted

Calculating total estimated degrees of freedom for a GAM

The correct terminology for the degrees of freedom that you need to compute is model degrees of freedom. You could also compute residual degrees of freedom. The model degrees of freedom are indeed ...
Isabella Ghement's user avatar
16 votes
Accepted

Different ways of modelling interactions between continuous and categorical predictors in GAM

gam1 and gam2 are fine; they are different models, although they are trying to do the same thing, which is model group-specific ...
Gavin Simpson's user avatar
16 votes

When should I balance my data for GLM/GAM?

I would strongly suggest to avoid rebalancing your data at first instance. Especially when using a GLM/GAM to describe the tendencies of the sample at hand it makes little sense to try to up- or down-...
usεr11852's user avatar
  • 42.6k
16 votes

When should I balance my data for GLM/GAM?

+1 to usεr11852's answer. Don't worry about "unbalanced" data, as long as you use appropriate models. Are unbalanced datasets problematic, and (how) does oversampling (purport to) help? GLM/...
Stephan Kolassa's user avatar
15 votes
Accepted

Model construction: How to build a meaningful gam model? (generalized additive model)

The reason for the first error is that bio.percent_b500 doesn't have k - 1 unique values. If you set ...
Gavin Simpson's user avatar
15 votes
Accepted

Inference in Time Series: Prophet vs. ARIMA

ARIMA and similar models assume some sort of causal relationship between past values and past errors and future values of the time series: $$Y_{t+h}=f(Y_{t},Y_{t-1},Y_{t-2},....,\epsilon_{t},\epsilon_{...
Skander H.'s user avatar
  • 11.6k
15 votes
Accepted

How to obtain the model coefficients of GAM in R?

The model you fitted with {mgcv} is $$ y_i = \alpha + f(x_i) + \varepsilon_i $$ not $$ y_i = \alpha + \beta \cdot f(x_i) + \varepsilon_i $$ So that makes me a little unsure as to what $\beta$ you want....
Gavin Simpson's user avatar
13 votes

How to choose the type of GAM-parameters

I'm assuming this is better explained in the 2nd edition of Simon's book (which should be out in a couple of days) as he and his students only worked out some of the theory for this years after Simon ...
Gavin Simpson's user avatar
13 votes
Accepted

Correcting for multiple pairwise comparisons with GAM objects {mgcv} in R

The glht() function for generalized linear hypotheses from the multcomp package can be used to carry out various kinds of ...
Achim Zeileis's user avatar
13 votes
Accepted

Smooth bivariate interaction decomposition in GAM models

Q1 There are a couple of key practical situations where the decomposed model using separate marginal smooths plus a special tensor-product interaction, or ti(), ...
Gavin Simpson's user avatar
13 votes

Analysed non-linear data with GAM regression, but reviewer has suggested fitting exponential or logarithmic curves instead. Which to use?

That GAMs are somehow “statistical overkill” and simpler functions are “more generalizable” is a contentious claims. A priori, if you had no idea about the functional relationship between your inputs ...
Demetri Pananos's user avatar
12 votes
Accepted

Assessing variable importance in generalized additive models (GAM)

Variable importance doesn't have a universally agreed-upon definition, but usually it means something like how much variance is explained by a predictor in your model. What you're describing isn't ...
Paul's user avatar
  • 10.8k

Only top scored, non community-wiki answers of a minimum length are eligible