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.

615 questions
Filter by
Sorted by
Tagged with
16 views

GAM MGCV: Difference in fitting and summary

Hello I am trying to adjust a GAM in R.I am trying to see the relationship that can exist through time in 57 river stations that are divided into Impacted and not previously Impacted. There are ...
11 views

How to chek if time spent in subsequent state has an influence of time spent in a present state?

As in the title of topic I'd like to check this assumption. I have already read the topic: How to test if "previous state" has influence on "subsequent state" in R but it regards ...
26 views

mgcv: p-spline basis does not have local support

My understanding is that one of the attractive properties of the B-spline basis is that the individual basis functions have local support, i.e. it will be >0 on the interval between $d+2$ adjacent ...
14 views

How can I do a pairwise comparison on a model without any interactions?

I am testing a continuous y variable against 2 factors in a GAM. It's similar to what I've shown in the dummy code with the iris data set below. I want to do a posthoc comparison to see if the species ...
29 views

Can I say that my model is acceptable?

I am performing a multiple regression with GAM.I found the significant predictors using the stepAIC function and now I am performing a model checking with mod.check(). This is what a get: ...
7 views

How to create contrast matrix model manually from GAM output

I have run a general additive mixed model and would now like to see if the levels of the two factor variables are statistically different from one another. An example of my data and code for this ...
18 views

Poisson Regression with GAM but with multiplicative lambda

Consider the following model $$a_i \sim \text{Poisson}(\, m(x_{1,i},x_{2,i}) \, b_i \,)$$ I'd like to predict $m$ as a function of predictor variables $x_1, x_2$. You can think of $a$ as the "...
29 views

How does mgcv deal with sum-to-zero constraints for intrinsic Gaussian Markov Random fields?

mgcv states that splines are constrained to sum to zero over the observations. This is to make the model identifiable. Intrinsic Gaussian Markov Random Fields (...
14 views

Is there a way to statistically compare the trend lines of nominal data using GAMs?

I was just wondering if anyone knows of a way to compare whether there is a significant increase or decrease in a fitted GAM model between factors. I currently have nominal data that is separated over ...
18 views

What should do when a smooth effect looks linear In a GAM?

Recall the example in Wood, 2017 (Page.344), where a logistic GAM is fitted to a data set with some covariates all as smooth terms and then the estimated effects are plotted. Here is the effect of ...
24 views

How to use a GAM to predict the probability in binomial data as a function of predictors

I'd like to predict the probability of success as an unknown function of predictor variables. For example, consider the following fake data ...
15 views

How choose formula in the Generalized Additive Model using Thin Plate Splines?

I am using mgcv to train GAM. For example, suppose we have a Dataset with 3 Features: x, y and z. When should I use a Thin Plate Spline for each variable? When should I use a Thin Plate Spline with ...
12 views

Compare goodness of fit for GAMs and (multiple) ordinary least squares

I'd be super grateful for any help. I have a dataset with a continuous response variable and various predictors. I want to fit two models. A "simple" linear multiple least squares regression....
37 views

Drawing smooths from different mgcv::gam models on unified scale in one plot - is it meaningful?

I want to draw the s(x1) smooths from the following models in a single plot, but I'm not sure whether plotting these smooths on the same scale is visually ...
27 views

How get correct prediction in Generalized Additive Model?

I am using the mgcv package in R. I trained a GAM, for a binary classification task, so I used binomial as a family. But when I run the predict method on the Test Set, I don't get 0 or 1 output, but ...
89 views

Model building in generalized additive mixed models (GAMMs)

I am currently try to set up a GAMM model that is based on data that my team and I have gathered. The data contains self-reported performance of 30 startups during 12 weeks (weekly measures) of the ...
74 views

GAMs: specifying knots positions for thin-plate regression splines

PROBLEM STATEMENT I have many replicates of the same dataset. I want to fit the same GAM to each replicate, and then average the model coefficients and covariance matrices (Vp) from all GAMs. The best ...
15 views

The disaggregation of between-person and within-person effects in nonlinear generalized additive mixed models (GAMMs)

As per Curran and Bauer (2011), one should disaggregate the between-person and within-person effects when conducting longitudinal multilevel models. One approach mentioned for time-varying covariates (...
43 views

Nonlinear multilevel modeling with GAM(M)s: Which model to choose?

I am attempting to understand the difference between three approaches for a GAM. My dataset (of which a subsample is included below) is longitudinal and hence is nested within-persons. I am predicting ...
85 views

Interpretability of tensor product interactions in space

Spatial data (x, y) is most often accompanied by spatial autocorrelation or locally different interactions between x & y. When I want to fit a parameter across space with generalized additive ...
15 views

How choose smoothing function for Generative Additive Models? (GAMs)

I would like to know which strategies are used in practice to choose the correct smoothing function for each features in the GAMs, both for classification and regression tasks. I thought of plotting ...
36 views

Fit a GAMM with two fixed factors and their combination

I would like to explore the effects of local climate zones (lczs), planting conditions (pcs) and their combination on leaf water ...
8 views

How to generate binary data that is additive through levels of a factor?

Suppose we define $Y\in \mathbb{R}$ as a function of some random variable $Z$ so that $$Y(Z)=\alpha Z + \beta X$$ for $Z\sim Bern(p)$ and $X \sim N(0,1)$. Then  Y(1) \sim N\left(\alpha, \beta^2\...
23 views

Autocorrelative parameter in GAM in R

I'm looking at a dataset of the number of users who used a specific software over a period of a year. I also have a binary predictor in the model. There is substantial autocorrelation in the data, and ...
22 views

32 views

In mgcv::gam(), what is the difference between s(x, by=cat) and s(x, cat, bs='fs')?

In this comment about smooth-factor interactions, Gavin Simpson wrote: s(x1, by = cat) doesn't create a "fs" class smooth I understand that ...
31 views

Non-independence of data points a problem when only doing model comparison?

I have a dataset that behaves sort of like time series data. It's 150 measurements in ~15000 individuals, with each measurement either a 0 or a 1 (failure or success). In addition, for each individual,...
21 views

Prediction basis for ti() smooths in mgcv

How are the sum to zero constraints absorbed in a bivariate decomposition smooth, ti()? And more importantly, how can we recover the parameters in the original basis to make predictions with new data (...
9 views

How to remove residual patterns from GAM?

My data is modelling the proportion of 'foraging' clicks vs overall clicks in a 30 minute interval using GAMs. I have multiple explanatory variables and factors. I have tried including all my ...
17 views

How to find out about weird patterns in gam.check of a bam

I run a bam with timeseries data and a response variable defined as cbind(positive, negative), family = quasibinomial (because of overdispersion), a number of interactions, and some random effects. ...
25 views

Interpreting significance of difference between two GAM smoothed series?

My question is about statistical interpretation of a two-level categorical fixed effect in a GAM model regarding the difference between two groups. Altough I found information about the construction ...
32 views

Is it possible to test for strongest predictor, if all variables are identical within a random effect grouping?

I'm trying to understand the regression analysis done in a published study. They use GAM models to predict plant growth, and to test for the most important predictors. They have measured growth of ...
21 views

How are the smoothers fitted in case of Logistic GAMS? For Gaussian response variable, many smoothers are defined such as splines and local regression etc. But how are they used in case of Logistic ...
50 views

Options for running GAMs with excessive zeros

I am analyzing count data that has 75% zeros, and I want to determine how catch of my species of interest has changed over time. Since I am looking at a 30 year time series I am using a smoother for ...
52 views

Credible Interval for smoothed random effect in a GAM

I followed the instructions here to create credible intervals for the smoothed terms, but these include random effects: How I've specified my model: ...
16 views

Write out Mixed GAM model mathematically

How do I write out the following mixed Generalised Additive model? ...
52 views

Gaussian process smoothers (bs = “gp”) in GAMs

In his inspiring overview of generalized additive modeling, Noam Ross makes a passing mention of gaussian process smooths (bs = "gp" in mgcv syntax), noting that they are especially well-...
28 views

Modeling binomial outcomes with repeated measures

I'm looking at patterns of a particular injury within individuals and how they vary by age and sex. For each of 1365 individuals I have four locations each of which may be positive for this injury. ...
16 views

How to perform time series prediction for small time series in rstudio using gam model?

I have a dataset which contains year(4 years - 2016, 2017, 2018, 2019), yield, ndvi, ndre,... savi indices, latitude and longitude of a field area of 8 hectacre. I have to predict the yield potential ...
49 views

Save computation time with mgcv?

Suppose we have a generalized additive model that is formulated as gam(y~s(x,bs='tp',k=10),...) I need to repeat the computation many times (e.g., 1000) for the ...
43 views

What does low rank smoother mean?

I read a paper on thin plate splines that stated several advantages. Thin plate splines: Do not rely on āknotsā as many other spline methods do Are of isotropic character (i.e. unaffected by the ...
52 views

Predicting with time as covariate

I have an indicator (intervention coverage in %) where data stop in 2015 and I would like to extrapolate/project data till 2018. I have used the following code that basically predicts data using glm ...
77 views

Split regression line into three groups and compare the slopes

Suppose I have a (linear) relationship between X and Y that might look like in my poor drawing below (simplified), i.e. I see that the slope of my Y~X regression differs depending on the value/range ...
23 views

Outlier in random effect - GAM

Is there any advice on how to deal with outliers in a generalized additive model? I have been following the book "Generalized Additive Models : An Introduction with R, Second Edition" by ...
29 views

Interrupted time series using GLMM / GAMM: which time variables should be smoothed?

I have conducted a controlled interrupted time series analysis within a GLMM framework. I have run the analysis in both the control and treatment groups separately to quantify the basic effects: ...
47 views

visreg visualization of GAM results (mgcv package)

How do I plot the generalised additive model using visreg? I have tried with the following code but it does not work and I am unsure how to specify it correctly. I have looked at visreg visualization ...
72 views

Random effects in Generalised Additive Model - mgcv package

I am confused about how random effects work in a Generalised Additive Model, specifically in mgcv. I want to specify a factor as a random effect. (Specifically, a ...
7 views

GAM deviance explained and COV

I feel I am misunderstanding something basic ...I ran GAM models for multiple datasets. Data attributes are the same and the GAM models are the same. Just values are different. I also calculated COV (...
49 views

Interpreting GAM plots: gam.check()

I am new to building GAMs, and would appreciate any help interpeting the graphs produced by gam.check I have written a gam model to predict probability of "success" in growing a species of ...