Questions tagged [mgcv]

mgcv is a R package for mixed GAM computation vehicle with GCV/AIC/REML smoothness estimation.

Filter by
Sorted by
Tagged with
2 votes
1 answer
7 views

GAM model warning message: step failure in theta estimation

When running and gam model and this warning message pops up, what does this mean and what is advised? A simple increase in knots (even by 1) seems to remove this warning message. "Warning message:...
user avatar
1 vote
1 answer
22 views

How to extract the penalty term from the GAMM function in R and what is used to estimate the penalty terms

I'm working on some log GDP data and I am testing out a Generalized Additive Mixed Model for it with a penalized cubic regression spline. I am using the GAMM function from the mgcv package in R and I ...
user avatar
2 votes
1 answer
47 views

Estimating separate smooths for a factor with hundreds of levels using GAMs

I am fitting a smooth-factor interaction term to a longitudinal microbiome abundance data set using GAMs. ...
user avatar
2 votes
1 answer
71 views

How to obtain local time slope from GAM model

I have a model where I try to model the linear trend in my response over time The trend may vary by elevation and location As far as I understood the mgcv package ...
user avatar
  • 23
0 votes
0 answers
29 views

understand and define complex spatial GAM structure

I want to use Generalized Additive Models (mgcv) to model a continuous variable over space and time. I have say 3000 locations around the globe. Each location has an unevenly spaced time series of my ...
user avatar
  • 23
1 vote
1 answer
34 views

How to find difference in means at particular points in a by-factor GAMM?

This is a bit long but I wanted to give enough photos and code to explain what I'm doing and the issues I'm having. The main question is in the last paragraph. I'm examining differences in male and ...
user avatar
  • 25
0 votes
0 answers
30 views

How to partition effects of variables and interactions in a GAM?

When using generalized additive models, can you partition the effects of variables and interactions? Here is an example: ...
user avatar
  • 1
0 votes
1 answer
27 views

plotting single plot to figure with gratia package for model visualisation [closed]

I am using Gavin Simpson's gratia package to plot my models (GAMs) as follows: draw(mod, scales = 'free', rug = NULL) The different plots get written to a single ...
user avatar
  • 43
0 votes
0 answers
20 views

mgcv GAM models in R package caret - how to interpret output

I am attempting to evaluate two GAM models I developed in mgcv via leave-one-out cross validation in the caret package. I am a newbie to both GAMs and cross-validation. For the purposes of this ...
user avatar
  • 11
0 votes
0 answers
31 views

Binomial mgcv::GAM with different behavioral states - how to interpret results

I'm trying to understand whether I have diel patterns of behavioral states of sampled animals. Per hour, each animal is assigned one of three states based on how much time it's spending in each state: ...
user avatar
  • 211
0 votes
1 answer
41 views

GAM: cox regression doesn't fit my synthetic data

I want to understand how Cox regression work using gam and mgcv, so I want to make my own data and try to see if I can fit a ...
user avatar
1 vote
1 answer
48 views

AIC between glm and gam

What are the consequences of comparing the AIC from a logistic regression model (glm) to the AIC from a generalized additive model (gam with binomial link and REML)? Here's an example of two models, ...
user avatar
1 vote
1 answer
33 views

How to fit piecewise linear splines or natural cubic splines in mgcv

How do GAMs generate forecasts that are outside the range of the training data? I often need to use regression models for extrapolated forecasts, where the values of the predictors are outside their ...
user avatar
1 vote
1 answer
74 views

Change y-axis value in R GAM plot from smoothed to actual response variable

I know similar questions have been asked before, but I've looked through them all and I'm still confused, in part because the other examples seem to be more complicated, so thought I'd throw mine up. ...
user avatar
  • 25
0 votes
0 answers
44 views

GAMs with multiple time series predictors

I have a binomial classification (yes/no) made on about 100 words. For each word, I can compute several time series (fo, intensity, etc.). I’m finding difficult to model (using GAMs) the outcome, ...
user avatar
  • 1
0 votes
0 answers
45 views

Paths to optimal K for GAM model selection

Let's say I have 10 different model combinations to compare via AIC for one year. There are 3 years of data, roughly 200-400 observations each year. For covariates, 2-3 of 5 appear to require tweaking ...
user avatar
0 votes
1 answer
65 views

Back transform predict.gam() from nb link log model run?

I have model with 1 covariate. I would like to run y values from gam in another model. I used nb(log=link) in gam model. Because I used nb and link log in gam, do I need to back transform to use ...
user avatar
1 vote
1 answer
38 views

Heteroscedasticity in palaeolimnology with GAMs

I'm trying to understand heteroscedasticity and the influence this may have on GAMs fitted to palaeo data (or other time series). My understanding of heteroscedasticity is as follows (please correct ...
user avatar
  • 13
0 votes
0 answers
26 views

GAM to remove image noise in time series

I got some satellite data for a region where cloud coverage may introduce some noise into my images. I have a time series of images taken at 1 month apart and my response is a variable that has a ...
user avatar
0 votes
1 answer
66 views

Doubt about my GAM formula, is it the right model to use for my data?

I measured a physiological performance of a specie (n=16) at 8 different temperatures, the same animal was used for each temperature and are identified by their "ID". I want to model the non-...
user avatar
  • 1
0 votes
1 answer
50 views

Fitting an functional autoregressive model in R with mgcv

I'm working with the 'mgcv' package in R and I just want to know if I am going about the right way of fitting a functional autoregressive (FAR) model. The FAR model is represented as $$Y=f_1(x.1)x.1+...
user avatar
0 votes
0 answers
29 views

GAM with the same variable in both fixed and random

I have a dataset collected over multiple years, with many samples collected per year. The samples are assumed be random within year (collected over a short period of time, over a large area, in a ...
user avatar
1 vote
1 answer
136 views

Is my GAM modeling longitudinal change appropriately?

My data includes the following: Y which is a physiological measure Age continuous Gender ...
user avatar
1 vote
1 answer
34 views

view default chosen k in mgcv's gam()

If using the default k in a smooth, e.g. gam(y ~ s(age), data=dat, family=binomial) how can I see which ...
user avatar
  • 11
0 votes
2 answers
51 views

generalized additive model with proportion independent variable

I'm using GAM to model a potentially non-linear relationship between two variables (with some controls variables included) in mgcv. My main independent variable is a proportion (without 0's or 1's) ...
user avatar
  • 3
2 votes
1 answer
102 views

What to do when GAMM is linear?

I have the following gamm4 output: This is longitudinal data modeled as: ...
user avatar
3 votes
1 answer
141 views

How to interpret non-signicant intercept but significant smooth terms with GAM in R?

I have the following gam model: ...
user avatar
1 vote
0 answers
37 views

Negative R2 from GAMM, but not with GLMM

I'm running a GAM using the bam function from the mgcv package and I've noticed something a bit peculiar. In my model I have a single smoothed adaptive spline on the explanatory variable 'ri' (...
user avatar
0 votes
1 answer
145 views

GAM in R; an intercept term

I am dealing with GAM models. I don't understand the intercept term there. Consider the following simple model. ...
user avatar
0 votes
0 answers
31 views

Interpreting data from a GAM that has data on log scale

I have a data set where I'm comparing territory sizes of animals of different age classes and populations. I use a GAM to fit a model as it seems to work very well when I fit the duration the animal ...
user avatar
  • 53
0 votes
0 answers
166 views

plot.gam partial effects plot: is there another function to plot more than one variable?

The package description of plot.gam describes under Warning: "The function can not deal with smooths of more than 2 variables!" My gam model has a base model that includes habitat variables, ...
user avatar
0 votes
1 answer
75 views

GAM partial effect line does not overlap raw data?

I am using a GAM to model the relationship between a response (mean_NN_dist) and a predictor (spRichness), while incorporating ...
user avatar
  • 103
1 vote
0 answers
64 views

Using a spatial tensor spline in a nnet:multinom multinomial fit in R

I know that in library(mgcv) one can use spatial tensor spline smooths in gam fits with a cyclical spline basis for longitude as ...
user avatar
0 votes
2 answers
54 views

can daily count data use GAM ordered categorical family, proportional-odds model?

The observed response variable Y takes on one of K(=21) ordered categories. Here is a summary of my response data (count data: the number of hospital admission in each day), y has observations across ...
user avatar
  • 37
2 votes
1 answer
38 views

MGCV summary function extremely slow

I am fitting a gam using the MGCV package in R using the bam function: ...
user avatar
1 vote
2 answers
117 views

Residuals of GAM models not improving with poisson or ziplss, but better with negative binomial (help with high values)

I am running GAM models on species counts with lots of zeros and high values or high counts. Residuals under poisson family have a s-like curve on qq line with models not predicting lower and higher ...
user avatar
2 votes
1 answer
77 views

What is the structure of a GAM fit with `mgcv::bam()` with the `rho` parameter set?

If I fit the model mgcv::bam(y~s(x), rho=0.8), where y and x are ordered by time, my understanding is that the model can be described in math notation as: $ y_t = \...
user avatar
1 vote
0 answers
62 views

Is model averaging possible/appropriate with a GAM?

I'm new here - apologies if there are any problems. I have two GAMs that I've fit (using mgcv::gam()), and the two models are comparable in AICc values. With GLMs, ...
user avatar
  • 11
0 votes
0 answers
66 views

Interpret GAM summary output for factor levels vs plotDiff plots

I have the following gam model that is testing to see if there is a significant effect of vessel referred to as CruiseID on the number of animals caught (Numberpertow). CruiseID is categorical with 3 ...
user avatar
  • 208
1 vote
0 answers
26 views

Prediction of intercept random effect in mgcv with a t2 smooth specification of a continuous predictor

I'm fitting gam models in mgcv with a "cr" spline applied to continuous regressor + an intercept random effect by group. When the "cr" spline is ...
user avatar
1 vote
1 answer
36 views

Additive Mixed Models: residual check for count response variable

Hi, The response variable is the count of daily number of physician visits of one specific disease.(y usually has the value for example of 4,5,6,10...,26). A standardized residual plot is produced ...
user avatar
  • 37
1 vote
1 answer
321 views

y-axis values in plot(gam)

I have used mgcv to fit a simple gam with a negative binomial distribution. My model looks at how animal abundance changes with distance to a feature, and looks like this: ...
user avatar
1 vote
0 answers
79 views

Concurvity with spatial random effect in GAM

I have a gam model where I am trying to describe animal mass as a function of distance from a feature. A simplified version of this model is ...
user avatar
0 votes
1 answer
44 views

Difference between sigma and cov-matrix in multivariate normal GAM

I'm confused about the difference between sigma and the cov-matrix when one fits a multivariate normal gam. More precise, I used for example mvn(d=2) when fitting a ...
user avatar
  • 25
0 votes
3 answers
97 views

gamlss plot check

I used the gamlss to fit the model. Bottom right panel: Normal QQPlot of the quantile residuals. The plots suggest a slight left skewness of the quantile residuals. My questions is should this be ...
user avatar
  • 37
0 votes
0 answers
104 views

Not all conditional distribution are normal - how to analyze

I tested the response of a weed's biomass (dry weight- DW) to a herbicide sprayed at three different phenological stages (4-6, 6-8 and 8-10 true leaves). The ...
user avatar
0 votes
0 answers
40 views

Residuals Checking QQ plot

There are some plots for residuals checking. I am wondering about the QQ plot, since it shows there are some nonnormality in one side of the tail. Based on this, is there hints showing that in which ...
user avatar
  • 37
2 votes
1 answer
102 views

Is the modeling strategy of GAM in MGCV equivalent to ridge regression when there are no smoothing terms?

According to GAM, it utilizes a penalized likelihood, which is maximized by penalized iteratively re-weighted least squares (P-IRLS), to obtain parameter estimations. The likelihood is defined as: ...
user avatar
0 votes
1 answer
88 views

by group random effect GAM

I am currently learning how to use GAMs and try to model a species response (resp) to different environmental parameters (x1, x2, x3) that were sampled at different locations (random effect). My ...
user avatar
1 vote
1 answer
86 views

Estimating a conditional logistic model with hierarchical splines in mgcv leads leads to error "indefinite penalized likelihood in gam.fit5"

One can estimate a conditional logistic model in the R package mgcv by using the cox.ph family, which I have done successfully. I also estimated a logistic ...
user avatar

1
2 3 4 5
8