A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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
0
votes
1answer
14 views

How to use inverse link functions on gamm mgcv model [closed]

I used inverse link functions, ilink <- family(gam_model)$linkinv for create time series interaction graph, and it works wonderful. I replace my model to gamm ...
1
vote
0answers
18 views

How can I measure the contribution of individual factors in the occurrence of a change point?

I have found a change point (or breakpoint) in a time series in a specific year. Using time-varying coefficient model (in mgcv package), as a special case of the generalized additive model, I found ...
0
votes
0answers
10 views

Getting the right interaction structure (continous and categorical) in GAM and intepreting p-values

I have looked long and hard to better understand implementing the right interaction structure in GAM and am aware of similar posts out there so I apologise for that, however I'm still unsure sure how ...
2
votes
0answers
25 views

Time series regression analysis with GAM in a factorial design

I have data from 16 automated sensors that measure a parameter across 4 experimental treatments with 4 replicated experimental units each: How would I go about to robustly test for significant ...
3
votes
1answer
57 views

GAM Interactions : Individual and Combined Interactions are different

I am quite new to GAM, I was trying various interactions in my GAM models, the individuals interactions and combined interactions are not coming up the same. There are three variables which define my ...
0
votes
1answer
28 views

calculating percentiles (quantiles) from GAM predictions in R

I'm working with a bird migration dataset, and exploring some different metrics to quantify changes in migration phenology (timing) over several decades. There are many different approaches to do this,...
0
votes
0answers
23 views

Representation of cubic-linear spline in mgcv::gam

I have a dataset of empirical hazard rates which I would like to model to produce a reasonable forecast of the survival rate. I'd like to use a cubic-linear spline to fit the logit-transformed hazards ...
3
votes
1answer
105 views

When and why would you not want to use a GAM?

I understand that GAMs in mgcv have the ability to reduce s(x) to a linear relationship with the response variable. If this is the case, why wouldn't you use a GAM? ...
0
votes
1answer
13 views

anova.gam, significant test and 0 deviance

I have fitted a series of GAMs of increasing complexity, and compared with anova.gam. I get a significant p value (based on Chisq test) for a pair of models, even though the difference in deviance ...
0
votes
1answer
41 views

Acceptable/reasonable deviance explained for fitted GAM?

thanks to all for any help in advance. I have built a series of nested GAMs in mgcv to explain the presence/absence of antibodies in a population of animals and used AIC to select my best fitting ...
1
vote
1answer
53 views

Interpreting a pattern in a residual plot produced by gam.check()

I'm working on creating a model that examines the effect of ocean characteristics on fishing outcomes. I have spatial data on a 0.5 degree grid and I created the following model: ...
0
votes
0answers
22 views

constrained GAM using bspline

I have presence/absence data for an animal as well as associated environmental covariates, temp, salinity, and oxygen. I'm using a GAM to find the relationship of the response over each covariate. I ...
4
votes
0answers
97 views

How does random variable nesting in GAMs work (mgcv)?

Consider me very new to the world of GAMs, I am actually using it out of necessity rather than by choice but I thought it could be a chance to learn something new anyway. Originally I had hoped to ...
0
votes
0answers
7 views

How to interprete relation in MAE with independent variable while ME is zero?

I have done a regression with mgcv based on 2 independent continious variables (x1, x2) and a dependent continious variable (y) and an interaction term. ...
1
vote
0answers
12 views

Can we get the specific formulation form of thin plate regression spline in GAM?

In mgcv package, the default smoother is thin plate regression spline. After building a GAM model, can we "write" the formula form of the thin plate regression ...
1
vote
0answers
33 views

Correct GAMM function for binary dependent variable

I am looking for help for how to implement a correct syntax for my Generalized mixed effect model. I have data for 4 independent transects set along an altitudinal gradient. I placed, at several ...
1
vote
0answers
34 views

Gam.check() and k number

Hello I have a question regarding gam.check() I understand that small p-values in the output of gam.check() indicate that residuals are not randomly distributed. This often means there are not enough ...
1
vote
0answers
56 views

Negative binomial random effects models (glmmTMB/gamm/gamm4)

Can anyone help please. Am I missing something fundamental here? I would like to test for a Cave and a Category effect in the same model, and I'd like to know if I've specified the random effects ...
2
votes
0answers
62 views

GAM model: Group-specific smoothers with different wiggliness of two random and nested factors [closed]

I aim to model the specific seasonal population fluctuations of several species. In particular, I have the abundance of individual along several years of 20 populations belonging to 5 species, and I ...
3
votes
1answer
359 views

visreg visualization of mgcv results (GAM)

I fitted a GAM with random effects using mgcv, and I've noticed that the visualization of the smooths using visreg does not appear to match the output of mgcv's plots: ...
0
votes
1answer
52 views

How to fit a zero-inflated quasi-poisson distribution to a continuous variable using GAM [closed]

I am trying to fit a GAM to a continuous variable which is zero-inflated. However, since my variable is continuous, I am not able to use ziP() for a zero-inflated quasi-Poisson. Is there someway to ...
0
votes
0answers
18 views

Modeling variable recensus/exposure count data using gam, quasipoisson with cloglog link

I am modeling tree recruitment in a forest. Foresters visit a forest monitoring plot twice. Recruitment is defined as the number of trees above a certain size threshold that are in the second census, ...
3
votes
1answer
145 views

GAM factor smooth interaction--include main effect smooth?

I am working with a dataset it which I am interested in modeling an age*sex interaction in the GAMM framework. From examples I have seen and documentation I have read, this is typically accomplished ...
1
vote
0answers
2k views

Should I be concerned about the warning message in model.matrix.default() - non-list contrasts argument ignored?

I am running a GAMM (mgcv package) with percentage/proportion as the dependent variable and a mixture of categorical and continuous variables, after running most of my models, this is the warning ...
0
votes
1answer
41 views

Why do my splines become not more flexible after altering the parameters in R mgcv?

I have done a logistic regression with two independent variables (x1 and x2) and a dependent binary variable (y). The AUC (roc curve) is 0.7915. After making a heatmap, I noticed the logistic ...
1
vote
1answer
39 views

Need to center continuous variables in GAMs?

This is just a quick question, but I remember reading somewhere that continuous variables used in splines for generalized additive models ought to be centered (especially for GAMs rather than just as ...
2
votes
1answer
31 views

what are the intercepts in mgcv's ordered-factor difference smooths?

I aim to plot the gam() model fit back on the original data. My impression was that gam() has special treatment for ordered ...
2
votes
1answer
39 views

significance of difference smooths

I am working to understand what is represented by the standard errors and confidence intervals of smooths of ordered factors. In this toy example, I wish to determine (1) the overall form of the trend ...
1
vote
0answers
26 views

concurvity in presence of random smooths [closed]

I am trying to fit a GAMM containing per subject random smooths using the bam function in mgcv as follows: ...
0
votes
0answers
102 views

zero inflated presence absence binomial GAM in R

I am fitting a binomial GAM using mgcv in R. My data is presence (1)/ absence(0) of dolphin acoustic detections in 10 minute time windows over ~1 year period. However, I have only ~750 presences to ~...
1
vote
1answer
69 views

Using GAM outside statistical modelling software (in-datatabase, outside R)

Question to advanced users, math pros/programists. Can you help me understand this explanation how to use GAM outside R? As I understand very vaguely, a matrix of parameters is being exported and ...
0
votes
0answers
110 views

Application of GAM on large dataset

I was suggested that my questions were too broad. As I commented below, I have nearly a million data points and perhaps a hundred variables. This may be a very basic modeling question: I am curious to ...
0
votes
0answers
26 views

How does one interpret r-sq (adj) versus deviance explained in GAMM creation?

I am running some models for my master's dissertation using backwards stepwise regression of GAMMs. I have six total models. I have a base model with several significant variables; the r-sq (adj) = -0....
1
vote
1answer
362 views

Model selection for GAM in R

Apologies in advance I new to this forum and to GAM models. I am trying to model complex ecological data. I have programmed a lot of GAM models using the mgcv ...
2
votes
3answers
931 views

Problems interpreting GAM output

I have been advised to run General Additive Models to be able to describe trends in my data, my data being animal harvest numbers by year. I have done so, but have a problem with interpreting the ...
4
votes
1answer
349 views

Thin Plate Regression Splines mgcv?

I am struggling on the understanding of thin plate regression splines. I already found a very helpful answer here in cross-validated: smoothing methods for gam in mgcv package but I still have some ...
8
votes
2answers
692 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
1answer
121 views

My data has overdispersion but the Hurdle model estimated theta is 0. What am I doing wrong?

I am confused by the dispersion parameter from my model. My data fails the overdispersion test. It's mean is 28.7, the variance is 18655.27. N=2916 of which 32% are zeros. How can theta equal 0 in ...
0
votes
0answers
53 views

Practically speaking, what do the three concurvity measures provided by the package mgcv mean?

I am using the R package mgcv to examine the association between asthma visits to the ER and air pollution. Most of my terms are parametric, with the exception of time, which is a smooth cubic ...
3
votes
0answers
54 views

How can I incorporate a known measurement error per group into a GAM?

I am trying to investigate surface changes using a time series of 3D point clouds. Due to data volume, I am segmenting the point cloud in small (eg. 50cmx50cm) areas and for each compute a generalized ...
2
votes
1answer
258 views

Random effects in GAM

I'm modelling some biological function, outcome, in patients over 8 hours. Over time, I measure two additional covariates x and ...
1
vote
0answers
31 views

How to measure the amount of confounding in tensor interaction in GAMs?

I am interested in fitting an additive model with tensor interaction terms. This construction is described in Wood (2006) and used in the mgcv ...
0
votes
0answers
75 views

Step failure in theta estimation using bam() in mgcv

I am using ?bam in mgcv 1.8-24, and when I'm using the negative binomial family I sometimes get a warning that says: ...
0
votes
1answer
99 views

mgcv::gam(). ANOVA decomposition of a factor-by-variable interaction

Suppose: y is a continuous response variable. z is a factor variable, and x is a continuous variable. For example, ...
1
vote
1answer
230 views

Confidence Interval for non-smooth term in gam (mgcv)

I fitted a gam model in mgcv package and now want to get the confidence intervals for the non-smooth term. ...
2
votes
0answers
64 views

confidence intervals of function of predictions

I would like to know how to get confidence intervals of function of predictions of a gam (via R package mgcv) model. In detail, I got $h\left( y_i \right) = E\left(y_i\right)$ and $std\left(y_i\right)$...
1
vote
0answers
60 views

bam() error: “reparameterization unstable for margin: not done”

In running a large GAM model of the form mgcv::bam(y ~ te(x, y, k = 100, bs = 'ts'), family = binomial, discrete = TRUE) I get this warning <...
2
votes
1answer
359 views

Difference between s() and ti() terms in mgcv package when applied to one variable

I am using the mgcv package in R to fit logistic GAMs to survey data. In one of my models I use an interaction between two covariates. I am currently trying to fit ...
1
vote
0answers
43 views

gam/gamm when response variable is complex

I would like to fit a generalized additive mixed model using mgcv or gamm4, but have a response variable consisting of complex numbers where y=a+1i*b. Is this possible, and if so are there any special ...
2
votes
1answer
52 views

How to make a random draw from a mgcv GAM model

Hi there statistical wizards! I have a (maybe) minor problem, where I would like to use the predicted fit (fit) and standard error (...