Skip to main content

Questions tagged [mgcv]

mgcv is a R package for mixed GAM computation vehicle with GCV/AIC/REML smoothness estimation. Use this tag for any on-topic question that (a) involves mgcv either as a critical part of the question or expected answer, & (b) is not just about how to use mgcv or R.

Filter by
Sorted by
Tagged with
1 vote
1 answer
30 views

My data is clustered in space, how can I account for that in a GAMM?

I am modelling whether a bird nest is build or not based on the date it was built, the geographical coordinates where the nest was built, and using the year when the nest was built as random effect - ...
Teresa's user avatar
  • 21
1 vote
1 answer
33 views

Modelling spatial autocorrelation with GAMs

the topic of spatial autocorrelation (SA) within the context of generalized additive models has already been discussed in several posts within this forum, see e.g. Why does including latitude and ...
August Edwards's user avatar
0 votes
0 answers
16 views

Why does mgcv's bam() not work with null models (y~1) but gam() does? [closed]

I'm trying to derive the unique and shared deviance explained by each predictor in several gam models using the gam.hp package. In brief, the package's approach uses creates a matrix of all possible ...
MicroSD's user avatar
0 votes
0 answers
14 views

Effects Contrast Matrix for Interaction with Multiple Grand Means

I want to include an interaction between two factors: area and house_type, in my GAM (MGCV), I hope to make a sum-to-zero ...
statmaj's user avatar
  • 76
2 votes
2 answers
74 views

Issue fitting and plotting GAM with soap film smoother

I am having an issue fitting a gam with mgcv in R and am looking for some help. In brief, I have a dataset that contains numbers of fish from one of two groups (Hatchery or Wild) that were detected at ...
Jack B's user avatar
  • 21
1 vote
0 answers
46 views

gamm and gamm4 give very different smooth term results for mixed models with factor-smooth interaction

I am analyzing an longitudinal dataset which has two groups (patient vs controls; ordered factor) with brain volume data over time. Participants entered the study at different ages and have varied ...
adrianneurosci's user avatar
1 vote
1 answer
27 views

Asking for clarification on how to interpret the output of a Generalized Additive Model with interaction terms

I'm very noob to GAM modeling, so I needed to clarify some questions, so thank you in advance :) I want to model bacterial growth (numeric) as a function of the concentration (numeric) of two drugs (...
2au's user avatar
  • 11
1 vote
1 answer
67 views

Generalized additive model which interacts with mean of response

I am currently constructing a model to predict house prices based on the GAM framework. The model is based on fitting a data set of 222299 house sales with the following information: Response variable:...
August Edwards's user avatar
1 vote
1 answer
71 views

GAM: Smooth and factor interaction

I am currently working on a GAM. It includes a smooth-factor interaction. I am trying to decide which function is the one I need. ...
Laura's user avatar
  • 49
5 votes
1 answer
138 views

Model checking for generalized additive models

I am currently constructing a GAM model to describe house prices. The dataset is a collection of roughly 200K house sales in a particular geographic region. Based on previous suggestions in this forum,...
August Edwards's user avatar
2 votes
0 answers
103 views

dubious diagnostics in species distribution modeling with mgcv gam

I am doing some marine species distribution modeling with gams and mgcv in R. The diagnostics from gam.check(), and concurvity() seem dubious. Are there issues with the specification of the model, or ...
Thanasis's user avatar
2 votes
1 answer
39 views

How to model the interaction between two continuous variables and two factors using gams with mgcv? [closed]

I was wondering how I could model the effect of two continuous variables X1 and X2 and two factors F1 and F2 and their interaction on a outcome Y using gams. What I primarily want to know is (in ...
Boussens-Dumon Grégoire's user avatar
2 votes
1 answer
27 views

Incorporating site-level random-effects and 2-dimensional spline of coordinates in a GAM in R

When building a Generalized Additive Model model using gam() from the mgcv package in R, one ...
geoscience123's user avatar
2 votes
1 answer
41 views

How to address multicollinearity when adding random effects in gam model and include random slopes?

I'm working with a generalized additive model (GAM) using the mgcv package in R. My dataset includes measurements collected over several years at different sites. I ...
maycca's user avatar
  • 325
6 votes
1 answer
112 views

Valid confidence intervals in GAM’s using shrinkage estimation

In this blog article: https://www.fharrell.com/post/improve-research/ it states: “The frequentist paradigm does not provide confidence intervals or p-values when parameters are penalized”. I was ...
user167591's user avatar
1 vote
1 answer
37 views

How can I do GAM piecewise in R? [closed]

I have some data $(x_i,y_i)_{i=1}^N$ which looks like a sigmoid curve in the xy-plane. Kind of like this: I think my data is homoscedastic normal distributed. My data has much larger variance than ...
Mikke Mus's user avatar
  • 113
1 vote
0 answers
32 views

Rel. contribution of each term to deviance explained (in GAM)

I have seen this and similar questions all over the place, but no really satisfying answers: How can we quantify the contribution that each term in a GAM (using mgcv package) adds to the total ...
user_20201213's user avatar
1 vote
1 answer
32 views

Interpreting GAM intercept (mccv's bam() function in R)

I am very new to GAMs (and, frankly, regression models in general), and I am struggling to understand the model summary I get when using the bam() function from the mgcv package in R, more ...
aevilok's user avatar
  • 11
2 votes
1 answer
43 views

Random effects in GAMs with mgcv vs random effects in LMMs with lme4

This blog post considers an example where GAMs from the mgcv package are used to model random effects: ...
Syd Amerikaner's user avatar
0 votes
0 answers
23 views

R/mgcv: GAM where some dependent variables are function of each other

I am trying to create a model using mgcv of an explanatory variable based on multiple other variables that are cross-correlated, and have high concurvity. Essentially, I want to explain a gas flux ...
user412561's user avatar
0 votes
0 answers
13 views

Set a monotonically increasing or decreasing relationship with GAM for binomial data

I am working with observation data and climate variables. I expect that the relationship should be linear or non-linear with a single direction of influence. Instead the output from ...
user3386170's user avatar
0 votes
0 answers
40 views

Is it possible to use gratia::difference_smooths() to compare only certain smooths (not all) in a modGI GAM?

The model I am using is the following : ...
Adam9's user avatar
  • 33
0 votes
0 answers
22 views

Combing multiplicative and additive effects in GAMs or GLMs

I am currently modelling a data set of house sales prices, P, as a function of various characteristics such as location, house size etc. etc. The list of explanatory variables can be divided into two ...
August Edwards's user avatar
2 votes
2 answers
58 views

Which way to correct for autocorrelation in GAM in timeseries (corARMA/corAR1/corCAR1)?

I was wondering if there are any noteworthy differences in how to correct for $\text{AR}=1$ in a GAM, where time is continuous considering the three different methods here (the data has been collected ...
aim6789's user avatar
  • 77
0 votes
0 answers
39 views

Modelling spatiotemporal data with GAMs (part II)

this post is a continuation of my previous question about modelling spatiotemporal data with GAMS: Modelling spatiotemporal data with GAMs In short, I am currently modelling a data set of house prices,...
August Edwards's user avatar
3 votes
3 answers
89 views

Interpreting Poisson GAM for epidemiological model

I'm working on a project where I investigate the relationship between PM2.5 (a form of pollution) and ischemic stroke hospitalization (i.e. number of hospitalizations total, collected per day). My ...
user1141170's user avatar
0 votes
0 answers
56 views

Handling missing values in GAMs

I am currently fitting a GAM-model, which assumes that the price of a house P can be modelled as a sum of smooth effects from different distances $d_{1}, d_{2}, ...$, e.g. distance to coast, lake, ...
August Edwards's user avatar
4 votes
1 answer
57 views

Removing high influence points in GAM fits

I am currently building a GAM model to describe house prices. The dataset is a collection of roughly 200K house sale prices $\{P_{i}\}$ together with a vector of house characteristics $\{\textbf{x}_{i}...
August Edwards's user avatar
4 votes
1 answer
93 views

Simulating from fitted t-distribution mgcv

My question is related to the following post: Extracting the degrees of freedom of t distribution of a GAM I have a dataset of y-values that I am fitting using the gam-function in mgcv. The ...
August Edwards's user avatar
8 votes
2 answers
802 views

Interpretation of effect of factor-by-smooths in GAM

Given the following data and model, we'd like to assess if treatment affects the effect of conc on ...
user409498's user avatar
1 vote
1 answer
52 views

How does the predict() function used with GAMs work with generating values from original data? [closed]

Hi I'm wondering if I may gain some insight on how the predict() and predict.gam() function work. Below I have my GAM model and the name of my original dataframe I am using. ...
w3l10w's user avatar
  • 21
0 votes
1 answer
37 views

Performance of GAM with asymptotic regression curves

Our research group studies edge effects of disturbances on adjacent relatively undisturbed ecosystems. We evaluate metrics such as light levels that may be higher at forest edges relative to the ...
user3386170's user avatar
2 votes
0 answers
28 views

In the mgcv ::bam function in R, how can I constrain a two dimensional smooth to be monotonically increasing in both dimensions for large data?

I have a large dataset (1.3M rows) where I want to ensure that both Age and Duration increase monotonically for each by factor level (Male, Female). Here is the setup of the model: ...
Colin's user avatar
  • 41
1 vote
1 answer
93 views

Violation of assumptions in Generalized additive models (GAMs)

I wanted to forecast Dengue count for the given weather data covariates: MeanT Mean temperature MeanRH Mean relative humidity MeanSM Mean soil moisture MeanVP Mean vapor pressure MeanWS Mean ...
Quantam's user avatar
  • 23
3 votes
1 answer
42 views

What method should be used to compare fit of different GAMs?

I am building GAMs of the following form (using R's mgcv notation) and would like to compare the fit between each model. ...
geoscience123's user avatar
1 vote
1 answer
63 views

Would someone be able to give me a basic understanding of s(x1), s(x2), s(x3), etc. terms work in R Generalized Additive Models (GAM)?

Hi there would someone be able to explain to me how the s(x1) terms work in the GAMS? For instance in the equation: ...
w3l10w's user avatar
  • 21
0 votes
0 answers
38 views

Is reversing the z-axis label in GAMs interaction plot statistically appropriate?

I have plotted a 3D perspective plot for generalized additive models. However, the z-axis label Growers (proportion) read from top to bottom. I have been asked to ...
Ahsk's user avatar
  • 425
4 votes
1 answer
255 views

Modelling spatiotemporal data with GAMs

I am currently modelling a data set of house prices, where some of the important covariates are the house coordinates (x,y) and the date of the house sale, t. In doing so, two questions have popped up:...
August Edwards's user avatar
0 votes
0 answers
129 views

How to deal with Heteroskedasticity in a GAM model

I am running a set of GAMs (Generalized Additive Models) to model a smoothed effect. I have verified all the other necessary checks of my GAMs for the basis functions, etc. However, I find persistent ...
flâneur's user avatar
2 votes
1 answer
197 views

Three-way interaction of two categorical factors and a continuous factor with random error in GAM

I am modeling a three-way interaction with a random error in GAM using mgcv package. The data is from a plant growth experiment with 2 categorical predictors f1 (mois; moisture = 3 levels) and f2 (...
Radim Sarlej's user avatar
1 vote
1 answer
39 views

Optimizing relative errors with GAMs

I am currently building a model GAM model to describe house prices. The dataset is a collection of roughly 200K house sales prices $\{p_{i}\}$ in a particular geographic region along with a range of ...
August Edwards's user avatar
2 votes
2 answers
275 views

How to constrain a GAM to non-negative values

I am using mgcv to run GAMs with elevation as the only predictor and concentration as the response. Naturally, the response cannot be negative (i.e., concentrations ...
JKO's user avatar
  • 785
1 vote
1 answer
53 views

mgcv GAM identifiability constraints

When fitting GAMs in mgcv package in R using smooth function, an identifiability constraint is typically imposed, such that smooth function should sum to zero (thus, addition of the main effect is ...
NeuroPanda's user avatar
1 vote
0 answers
84 views

GAM-modelling: Accounting for spatial autocorrelation in large datasets

Let me start by saying that I am rather new to GAMs and using the mgcv package, so let me know if this question has already been addressed thoroughly in this forum. I am aware that there already exist ...
August Edwards's user avatar
5 votes
1 answer
116 views

Order of derivative for MGCV splines and low EDF

I'm following up on the informative discussion here concerning choice of m (order of derivative) for MGCV splines. Using the default options in MGCV (thin plate spline, REML for optimization, k=10, ...
dean's user avatar
  • 455
3 votes
1 answer
127 views

Implications of keeping a "low" basis dimension in GAMM

Some of the smooths in my generalized additive mixed model (GAMM) indicate in mgcv::k.check(m) they want to be more wiggly, but I don't think I have enough data to ...
Nate's user avatar
  • 1,641
1 vote
0 answers
53 views

Distributional choices for sparse 0,1 data

I am using GAMs to model the relationship between a binary response variable (0 or 1) and several continuous fixed and random explanatory variables. It seems that a binomial distribution is the ...
Andrew 's user avatar
0 votes
0 answers
43 views

GAMM: Removing an interaction changes variance confidence interval of other terms

I'm learning how to interpret the output of the gratia::variance_comp function. I noticed that removing an interaction changed the confidence intervals of a ...
Nate's user avatar
  • 1,641
0 votes
0 answers
30 views

How do I appropriately code a gamm() model with an inverse.gaussian family and autocorrelation structure?

I am incredibly new to generalized additive modeling, so I apologize in advance for any and all naiveté. But I believe GAMMs are the appropriate methodology for my data. I am working with fish ...
babygammer's user avatar
5 votes
2 answers
366 views

GAM plot in R for "by = factor" [closed]

I have a dataset of dolphin encounters (count data) which are segregated by "type" of detection of an event (acoustic, visual, mix). I ran a GAMM to test the effect of environmental ...
Isha B's user avatar
  • 163

1
2 3 4 5
12