Questions tagged [mgcv]

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

mgcv is a package for the R project for statistical computing. "mgcv" stands for mixed GAM computation vehicle. Additional information can be found in the following webpages:

365 questions
20
votes
2 answers

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 researcher -- Simon Wood, at the University of Bath, in…
18
votes
2 answers

How to tune smoothing in mgcv GAM model

I am trying to figure out how to control the smoothing parameters in an mgcv:gam model. I have a binomial variable I am trying to model as primarily a function of x and y coordinates on a fixed grid, plus some other variables with more minor…
colonel triq
  • 181
  • 1
  • 1
  • 3
15
votes
1 answer

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 be specified very succinctly. However, that same…
jdobres
  • 338
  • 2
  • 10
15
votes
1 answer

Adaptive GAM smooths in mgcv

Simon Wood's book on GAMs and his associated R package mgcv are both highly detailed and informative when it comes to GAM theory and model-fitting to real and simulated data. For 1D smooths, there is really not much to worry about, save for…
compbiostats
  • 1,017
  • 9
  • 18
14
votes
1 answer

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 ti(). I understand the basic division of labour between the two (fitting a non-linear interaction vs. decomposing this interaction into main effects and an…
jvh_ch
  • 313
  • 2
  • 9
13
votes
1 answer

How to choose the type of GAM-parameters

I have started to work with GAM in R and I’ve acquired Simon Wood’s excellent book on the topic ("Generalized Additive Models An Introduction with R"). Based on one of his examples, I am looking at the…
12
votes
4 answers

How to obtain the values used in plot.gam in mgcv?

I would like to find out the values (x, y) used in plotting plot(b, seWithMean=TRUE) in mgcv package. Does anyone know how I can extract or compute these values? Here is an example: library(mgcv) set.seed(0) dat <- gamSim(1, n=400, dist="normal",…
user2264
12
votes
2 answers

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 x and a factor fac, it is possible to define a General Additive Model (GAM) with an interaction between x and fac…
Marco Plebani
  • 779
  • 4
  • 17
12
votes
1 answer

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 thought I would use gam instead of gamm to model the…
11
votes
1 answer

How to Interpret GAM P-Values?

My name is Hugh, and I'm a PhD student using generalised additive models to do some exploratory analysis. I'm not sure how to interpret the p-values that come from the MGCV package and wanted to check my understanding (I'm using version 1.7-29, and…
user45178
  • 161
  • 1
  • 5
11
votes
2 answers

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 they use anova to compare three different models to determine the best fit model. The…
BillyJean
  • 447
  • 1
  • 4
  • 12
11
votes
0 answers

Negative deviance explained by GAM with betareg in R

I am fitting the following model in "mgcv" package in R using option family=betar to predict a percentage cover response variable (cyano %): g6 = gam(cyano/100 ~ s(SEGLOWFLOW) + s(SEGJANAIRT) + s(LOCHAB) + s(LOCSED) +…
jatalah
  • 443
  • 1
  • 3
  • 8
11
votes
1 answer

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 using bs="re" in gam; 2) Use the function gamm,…
linksys
  • 283
  • 1
  • 2
  • 7
10
votes
2 answers

GAM cross-validation to test prediction error

My questions deals with GAMs in the mgcv R package. Due to a small sample size I want to determine the prediction error using leave-one-out cross-validation. Is this reasonable? Is there a package or code how I can do this? The errorest() function…
Peter
  • 223
  • 1
  • 2
  • 4
9
votes
1 answer

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 package but am struggling to select a model and struggling to evaluate which models are…
1
2 3
24 25