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 ...
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 ...
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 ...
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 ...
23
votes
2answers
19k views

How to include an interaction term in GAM?

The following code evaluates the similarity between two time series: ...
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 ...
9
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 <...
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 ...
4
votes
1answer
9k views

How I can interpret GAM results?

I have a question about Generalized Additive Models. What is Deviance explained, GCV score and Scale est. in GAM results? What these indicators show?
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 ...
0
votes
1answer
236 views

ANOVA table (and its interpretation) for a single GAM model

I am not really confident in interpreting the ANOVA table of a GAM model. I understand how it can be used to compare models (see for instance this question), but I am interested in interpreting it for ...
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 ...
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 ...
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 ...
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 ...
4
votes
1answer
2k views

Interpretation of bs(x) and gam Results

This is a two-part question. 1) I've read the description of the bs function in the R splines package, but I don't think I ...
3
votes
5answers
227 views

Introductory Text for GAM

I'm looking for a text to help someone who uses GLMs in practice become familiar/comfortable with GAMs. Online or physical textbook would be fine. I am approaching this as a practitioner, so I would ...
3
votes
0answers
230 views
6
votes
1answer
120 views

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

The following question builds on the discussion found on this page. Given a response variable y, a continuous explanatory variable ...
3
votes
2answers
2k views

smoothing methods for gam in mgcv package

i am currently working with gam models in the mgcv package and for me the smoothing methods are a bit confusing and i hope that you guys can help me to understand that better. So here is what i've ...
1
vote
1answer
2k views

Centering constraints in MGCV GAM

The help pages for MGCV in R states the following: Note that when using factor by variables, centering constraints are applied to the smooths, which usually means that the by variable should ...
1
vote
1answer
2k views

GAM with categorical variables - interpretation

I want to use GAM to analyze my experimental data. In my experiment, participants basically play a game for 40 experimental years. In total I have 6 different conditions and I have a between-subject ...
1
vote
0answers
86 views

Is there a reasonable way to impose a prior within a likelihood-based model?

I have been using GAM (mgcv's gam()) to perform a fairly complex and computationally intensive analysis - I have millions of observations and dozens of terms ...
1
vote
0answers
647 views

Selecting GAM with/without random effects - residual plots vs. AIC

My question is about fitting GAMs with a random effect in mgcv, using s(x, bs="re"). I understand that determining the random effects structure should occur before determining the fixed effects ...
8
votes
2answers
873 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 ...
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") ...
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
2k views

How to summarize GAM model result from multiple imputation data in R

I am very new to R and not very experienced in statistics. I have this general question regarding applying Generalized Additive Models (GAM) in multiple imputation dataset. I used R package mice for ...
5
votes
2answers
991 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 $...
4
votes
1answer
1k views

Interactions between non-linear predictors

I have data on 70,000 students, nested in 120 schools. I'm starting with fixed effects for the schools, but at some point I might start letting intercepts and slopes vary. Some key predictors (e.g....
4
votes
1answer
3k views

scatterplot smoothing in r with big dataset: different methods

I have a large dataset (>300,000 rows) with two variables. y is binary and x is continuous & numeric. I'd like to plot y and add smooth curve against x. I understand that loess(y~x) is a solution, ...
4
votes
1answer
185 views

Principled ways of constraining $E[Y]=0$ when one of your regressors $\rightarrow$ 0

Consider the following ridiculous example. There is a real, non-ridiculous research question here, I promise -- I'm just a little bit uncomfortable posting what I'm working on on the internet in ...
4
votes
1answer
4k views

Predicting with GAM, using an offset

I came in a new post because I’m quite confused with the use of an offset in gam() function (mgcv package). I’m actually working on predicting marine top predator’s distribution using aerial surveys (...
3
votes
1answer
2k views

Fitting a glm to a zero inflated positive continuous response

I'm trying to fit R glm's to data sets where the response is zero inflated positive continuous. This is an example data set ...
3
votes
1answer
916 views

Centering constraints for regression - specifically GAM

I asked the following question and (don't think) really received a thorough answer. I qualify my impression about the suitability of the answer, because perhaps I am lacking pre-requisite knowledge. ...
2
votes
1answer
216 views

How can I robustly smooth my time series data?

I have data like the following image, where the x-axis is the absolute elapsed time in hours (think calendar days; this plot goes over ~2.5 years), and the y-axis is the manually entered uptime of a ...
1
vote
1answer
147 views

Are there concerns with doing a generalized additive model with a smoothing term of multiple variables?

In R, usually one performs a generalized additive model like so: library(mgcv) x <- gam(depvar ~ s(indvar1) + s(indvar2) + parametricvar) Say I want to ...
1
vote
1answer
76 views

R: generalised additive model on proportional data

Introduction I am analysing temporal population data on the amphipod Orchestia gammarellus. At several moments each year, all animals were collected from a small spot, and several life history traits ...
5
votes
1answer
824 views

beta-regression accounting for residual spatial auto-correlation in R

I have data on the interval (0,1), that I model using beta regression with the betareg package in R. This works well. However, I ...
4
votes
2answers
952 views

Why do qq-plots appear to show normal residuals from a GAM when the underlying distribution is not normal?

Say you do this in R: g <- rgamma(5000, 4) t <- rt(5000, 5) So, now you've got data from the gamma and $t$-...
3
votes
1answer
1k views

gam smoother vs parametric term (concurvity difference)

I have a gam model that is: gam=gam(sv~s(day,bs="tp")+s(range,bs="tp")+s(time,bs="cc"),data=train.all,gamma=1.4,method="REML") the ...
2
votes
0answers
400 views

Sum to Zero Constraint GAM Factor Interaction

I was under the impression that the smooths fit with mgcv were made identifiable through a sum to zero constraint - i.e. if one was to sum the smooth over the ...
2
votes
0answers
191 views

GAM model and interactions between nonparametric terms / additive interactions and GAM?

I have a GAM model with several continuous parametric covariates, one non-parametric covariate, and two continuous parametric predictors. I am using R. The reason I am employing GAM is to be able to ...
1
vote
1answer
271 views

Strange effective degrees of freedom (smoothness) selected for smooth component in GAM model with mgcv

Consider the following very simple example: ...
0
votes
0answers
370 views

Comparing gam models using ti( )

I want to compare gam models including interaction with simpler models. For interaction models, I used gam(Y~ti(X1) + ti(X2) + ti(X1,X2)). Removing the interaction, ...