Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [gam]

Generalized additive model (GAM) is a generalized linear model (GLM) in which the response variable depends on unknown smooth functions of some predictor variables.

53
votes
4answers
14k views

Why does including latitude and longitude in a GAM account for spatial autocorrelation?

I have produced generalized additive models for deforestation. To account for spatial-autocorrelation, I have included latitude and longitude as a smoothed, interaction term (i.e. s(x,y)). I've based ...
28
votes
1answer
5k views

Can degrees of freedom be a non-integer number?

When I use GAM, it gives me residual DF is $26.6$ (last line in the code). What does that mean? Going beyond GAM example, In general, can the number of degrees of freedom be a non-integer number? <...
23
votes
2answers
19k views

How to include an interaction term in GAM?

The following code evaluates the similarity between two time series: ...
18
votes
2answers
995 views

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

I use GAMs more and more. When I go to provide references for their various components (smoothing parameter selection, various spline bases, p-values of smooth terms), they are all from one ...
13
votes
1answer
4k views

GAM vs LOESS vs splines

Context: I want to draw a line in a scatterplot that doesn't appear parametric, therefore I am using geom_smooth() in ggplot in <...
12
votes
3answers
12k views

Confidence interval for GAM model

Reading mgcv::gam's help page: confidence/credible intervals are readily available for any quantity predicted using a fitted model However I can't figure a ...
11
votes
3answers
2k views

When to use a GAM vs GLM

I realize this may be a potentially broad question, but I was wondering whether there are generalizable assumptions that indicate the use of a GAM (Generalized additive model) over a GLM (Generalized ...
11
votes
1answer
2k views

Summary of a GAM fit

If we fit a GAM like: ...
11
votes
0answers
318 views

Penalized spline confidence intervals based on cluster-sandwich VCV

This is my first post here, but I've benefited a lot from this forum's results popping up in google search results. I've been teaching myself semi-parametric regression using penalized splines. ...
10
votes
1answer
5k views

Predicting with random effects in mgcv gam

I am interested in modeling total fish catch using gam in mgcv to model simple random effects for individual vessels (that make repeated trips over time in the fishery). I have 98 subjects, so I ...
10
votes
1answer
6k views

Generalized Additive Model Python Libraries

I know that R has gam and mgcv libraries for generalized additive models. But I am having difficulty finding their counterparts in the Python ecosystem (statsmodels only has prototype in the sandbox)....
10
votes
1answer
2k views

Generalized additive models (GAMs), interactions, and covariates

I've been exploring a number of tools for forecasting, and have found Generalized Additive Models (GAMs) to have the most potential for this purpose. GAMs are great! They allow for complex models to ...
10
votes
1answer
1k views

Variance inflation factor for generalized additive models

In the usual VIF calculation for a linear regression, each independent/explanatory variable $X_j$ is treated as the dependent variable in an ordinary least squares regression. i.e. $$ X_j = \beta_0 + ...
10
votes
1answer
564 views

Is the observed allele frequency significantly less than the predicted?

Question: How can I construct a test to determine if the observed "mountain"-allele frequency (Fig 1) is significantly lower in the central to southern mountains than predicted (Fig 2) by the ...
9
votes
3answers
669 views

Spline df selection in a general additive Poisson model problem

I've been fitting some time series data using a Poisson general additive model using SAS's PROC GAM. Generally speaking, I've been having it's built-in generalized ...
9
votes
2answers
5k views

Help me fit this non-linear multiple regression that has defied all previous efforts

EDIT: Since making this post, I have followed up with an additional post here. Summary of the text below: I am working on a model and have tried linear regression, Box Cox transformations and GAM but ...
9
votes
1answer
9k views

Interpretation of gam model results

I am fitting some generalized additive models using the mgcv package in R, and I am wanting to test between two models; whether I can remove a term or not. I am, ...
9
votes
2answers
6k views

GAM cross-validation to test prediction error

My questions deals with GAMs in the mgcv R package. Due to a small sample size I want to determine the prediction error using leave-one-out cross-validation. Is this reasonable? Is there a package or ...
8
votes
1answer
2k views

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

The mgcv package for R has two functions for fitting tensor product interactions: te() and <...
8
votes
2answers
872 views

GAMM with zero-inflated data

Is it possible to fit a GAMM(Generalized Additive Mixed Model) for zero-inflated data in R? If not, is it possible to fit a GAM(Generalized Additive Model) for zero-inflated data with a negative ...
8
votes
1answer
4k views

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

I have seen there are various questions concerning the interpretation and construction of gams, which seems to illustrate the difficulty for non-statisticians to deal with those. Unfortunately, from ...
8
votes
1answer
195 views

Causal identification and penalized splines

I just got a rejection from an economics journal. Among the reasons cited for rejection were: the benefits of using the semi-parametric method are not clearly brought out compared to alternative ...
8
votes
1answer
945 views

Modeling a spline over time — design matrix and survey of approaches

A response variable y is a nonlinear function of a number of predictor variables X (in my real data the response is binomially distributed, but here I'm using a normally-distributed value for ...
7
votes
1answer
9k views

Selecting 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 ...
7
votes
2answers
6k views

ANOVA to compare models

I'm looking at this site for a workshop on GAM in R: http://qcbs.ca/wiki/r_workshop8 In the end of the section 2. Multiple smooth terms they show an example, where ...
7
votes
2answers
1k views

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

I have data from an experiment where I look at the development of algal biomass as a function of the concentration of a nutrient. The relationship between biomass (the response variable) and the ...
7
votes
1answer
3k views

How to choose the type of GAM-parameters

I have started to work with GAM in R and I’ve acquired Simon Wood’s excellent book on the topic ("Generalized Additive Models An Introduction with R"). Based on one of his examples, I am looking at ...
7
votes
1answer
145 views

Does taking the logs of the dependent and/or independent variable affect the model errors and thus the validity of inference?

I often see people (statisticians and practitioners) transforming variables without a second thought. I've always been scared of transformations, because I worry they could modify the error ...
7
votes
2answers
1k views

GAM model summary: What is meant by “significance of smooth terms”?

I have dataset for which I am constructing a GAM model, with a number of factors predicting the dependent variable. When I take a summary of the model, I get a chart that indicates the "significance ...
7
votes
0answers
897 views

Generalised additive model: What is ref.df in R's output?

Hi I am struggling to understand Ref.df in the output screen in R: ...
6
votes
1answer
6k views

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

A particular section of the mgcv documentation gives multiple methods of incorporating random effects into a generalized additive model. Two methods are 1) to add a smooth term in the class labels ...
6
votes
1answer
207 views

Are GAM models linear in the parameters?

Consider a GAM model, expressed in mgcv just to fix ideas: my_model <- gam(y ~ ti(x1)+ti(x2) + ti(x1, x2), method= "REML") ...
6
votes
1answer
1k views

QR factorization and linear regression

I have been reading "Generalized Additive Models an Introduction with R" by Simon Wood and have come across a section I'm having trouble with. On page 13 it is stated that the model or design matrix ...
6
votes
3answers
229 views

Clarification on how to perform nested cross-validation

I'm currently trying to get lifetables for our population based on death and population counts. My first idea was to follow this paper methodology but after some discussions we are planning to use ...
6
votes
1answer
592 views

Are both of these generalized additive models?

I've been reading about generalised additive models. I've been using this data (which is a reformatted version of data from Hastie's website), and running my code in R. This data essentially consists ...
6
votes
1answer
224 views

Are GAMMs/GLM the best choice for calculating number of germs on hands?

We would like your opinion on whether GAMMs are a good option and how best to go about implementing for the following: During a period of patient care, a nurse will accrue $Y$ colonies of bacteria on ...
6
votes
0answers
102 views

When using GAMs, how much concurvity is too much?

Is there a rule of thumb for excessive concurvity? For example, I've heard that a VIF of $>10$ suggests that multicollinearity may be a problem (e.g., in this CV answer), but I cannot find a ...
6
votes
0answers
250 views

Mixed models formulation (GAMM, GLS, nlme): from R to mathematical notation

I have just finalised the analysis of a dataset fitting Generalised additive mixed models (GAMMs) with mgcv package in R v3.3.0. But I am having trouble in writing my models into their correct ...
6
votes
0answers
201 views

When to choose GAM over LOESS? [duplicate]

I am smoothing the relationship between a binary variable y and a continuous variable x. For this I've looked into both GAM and ...
6
votes
0answers
2k views

Interpreting and reporting gamm4 result

I am new to gam, and most of my knowledge comes from this document http://www3.nd.edu/~mclark19/learn/GAMS.pdf. Now I am using generalized addictive model with random effects to model some data, where ...
6
votes
1answer
7k views

Non-linear modelling with several variables including a categorical variable [duplicate]

I am trying to model some data regarding a predator prey interaction experiment (n=26). Predation rate is my response variable and I have 4 explanatory variables: predator density (1,2,3,4 5), ...
5
votes
3answers
2k views

Are LOESS and GAM with one covariate the same?

I am learning about Generalized Additive Models (GAMS) and have found in multiple locations a claim that a GAM with one independent variable is identical to a bivariate LOESS regression. Is this ...
5
votes
2answers
2k views

Predicting mean smooth in GAM with smooth-by-random-factor interaction

I have a binomial GAM with a smooth-by-random-factor interaction. From this I am able to predict and visualize the smooth term for any level of my random effects: ...
5
votes
1answer
3k views

Why does this logistic GAM fit so poorly?

I am trying to create a logistic regression model with mgcv::gam with what I think is a simple decision boundary, but the model I build performs very poorly. A local regression model built using ...
5
votes
1answer
5k views

Using a gamm4 model to predict estimates in new data

I have been experimenting with gamm4 to derive GAMMs of some repeated measures data. The models looks very nice and seem to give more flexibility than my LMMs. Ultimately I want to compare models ...
5
votes
2answers
987 views

Multiple polynomial regression versus GAM

How does using GAM differ from using multiple polynomial regression? They seem to produce the same result. Below I run a polynomial regression using lm() with $...
5
votes
1answer
7k views

GAM versus GLM: same fit, different significance of predictors

When performing GAM and GLM fits to the same data set, I get an almost identical fit in terms of fitting metrics. However, the variables that are identified as significant differ between the two ...
5
votes
1answer
1k views

Build a covariance matrix for GAM

I am using a GAM in R to compare time series data from 3 countries. The data sets are of hourly measurements for one year. The main aim here is to show when at which time of the day and day of the ...
5
votes
1answer
1k views

Assessing variable importance in generalized additive models (GAM)

In a linear model, it's easy to assess the importance of each explanatory variable. If the assumptions of the model are met, given two explanatory variables $x_1$ and $x_2$, both with a regression ...
5
votes
3answers
336 views

Which method is correct? (generalized additive model, mgcv)

If possible could you please let me know if I am on the right track? I don't know anyone who works with GAMs who I can ask and I would be so appreciative of any help I receive. I use mgcv in R. My ...