Questions tagged [mgcv]

mgcv (Mixed GAM Computation Vehicle) is a CRAN package for the R language, it contains routines for GAMs and other generalized ridge regression with multiple smoothing parameter selection by GCV, REML or UBRE/AIC. Also GAMMs.

mgcv (Mixed GAM Computation Vehicle) is an package for analysing s and other generalized ridge models with multiple parameter selection by GCV, REML or UBRE/AIC. Also GAMMs.

Repositories

Books

Other resources

Related tags

461 questions
6
votes
1 answer

Extract estimates of GAM

I am fairly new to R and presently reading a book “Generalized Additive Models”, an Introduction with R by Wood (2006) and going through some of the exercises, particularly the part on air pollution and death which is my area of interest. Using the…
Meso
  • 1,375
  • 5
  • 17
  • 36
5
votes
1 answer

Running random error model with mgcv gam takes too much memory

I am working on a model that includes several REs and a spline for one of the variables, so I am trying to use gam(). However, I reach memory exhaust limit error (even when I run it on a cluster with 128GB). This happens even when I run the simplest…
mpnyka
  • 51
  • 1
5
votes
0 answers

Concurvity in parametric terms in GAM in R with mgcv

I have a GAM model (below) where SST_mean and NAO are numerical values, and cycle and region are categorical factors. I checked for concurvity using the concurvity function in mgcv. m2 <- gam(Strandings ~ s(SST_mean) + s(NAO, bs="re") + Cycle +…
mikejwilliamson
  • 405
  • 1
  • 7
  • 17
5
votes
0 answers

mgcv: Specifying factor-smoother interactions for "global" grouped smooths

I've found the Hierarchical GAM pre-print (and GH repo) of Pedersen et al. extremely helpful in modeling inter-group variability in functional responses, but I've hit a stumbling block. I have some time series data (counts over time) with the…
adamdsmith
  • 920
  • 1
  • 9
  • 15
5
votes
0 answers

Why does the fitting time of a gam increases with the number of threads used?

Common sense indicates that any computation should be faster the more cores or threads we use. If the scaling is bad, the computation time will not improve with increasing number of threads. Thus, how come increasing threads considerably reduces the…
nukimov
  • 216
  • 1
  • 7
5
votes
1 answer

GAM with "gp" smoother: predict at new locations

I am using the following geoadditive model library(gamair) library(mgcv) data(mack) mack$log.net.area <- log(mack$net.area) gm2 <- gam(egg.count ~ s(lon,lat,bs="gp",k=100,m=c(2,10,1)) + s(I(b.depth^.5)) + …
user3036416
  • 1,205
  • 2
  • 15
  • 28
5
votes
2 answers

Why does using "mgcv::s" in "gam(y ~ mgcv::s...)" result in an error?

I wanted to be clear and use the :: notation in the lines for fitting an mgcv::gam. I stumbled over one thing when using the notation within the model call for mgcv::s. The code with a reproducible example / error is shown below. The reason is…
Manuel Bickel
  • 2,156
  • 2
  • 11
  • 22
5
votes
0 answers

Is it possible to specify lower bound in response variable during smooth with gam?

I am trying to fit a smoothed surface of z against x and y using formula z ~ s(x, y) with gam function in mgcv package. My goal is to predict response z based on new values of x and y. In my real situation, z should be a positive number negative z…
mt1022
  • 16,834
  • 5
  • 48
  • 71
5
votes
1 answer

Prevent plot.gam from producing a figure

Say, I have a GAM that looks like this: # Load library library(mgcv) # Load data data(mtcars) # Model for mpg mpg.gam <- gam(mpg ~ s(hp) + s(wt), data = mtcars) Now, I'd like to plot the GAM using ggplot2. So, I use plot.gam to produce all the…
Dan
  • 11,370
  • 4
  • 43
  • 68
5
votes
1 answer

mgcv: how to specify interaction between smooth and factor?

In R, I would like to fit a gam model with categorical variables. I thought I could do it like with (cat is the categorical variable). lm(data = df, formula = y ~ x1*cat + x2 + x3); But I can't do things like : gam(data = df, formula = y ~…
Courvoisier
  • 904
  • 12
  • 26
5
votes
1 answer

weights option in GAM

My dataset has many redundant observations (but each observation should be counted). So I consider using 'weights' option in GAM because it significantly reduces computation time. gam function (in mgcv package) explains that they are 'equivalent'…
user67275
  • 1
  • 9
  • 38
  • 64
5
votes
2 answers

R plot.gam Error "Error in 1:object$nsdf : argument of length 0"

I am trying to plot a gam object in R, which I made with the gam package. I receive the same error reported in Error in 1:object$nsdf : argument of length 0 when using plot.gam. However, the solution found there, updating to the latest versions (I…
BazookaDave
  • 1,192
  • 9
  • 16
5
votes
2 answers

Variable Selection with mgcv

Is there a way of automating variable selection of a GAM in R, similar to step? I've read the documentation of step.gam and selection.gam, but I've yet to see a answer with code that works. Additionally, I've tried method= "REML" and select =…
IJH
  • 167
  • 1
  • 11
5
votes
2 answers

R: GAM with fit on subset of data

I fit a Generalized Additive Model using gam from the mgcv package. I have a data table containing my dependent variable Y, an independent variable X, other independent variables Oth and a two-level factor Fac. I would like to fit the following…
yannick
  • 397
  • 3
  • 19
5
votes
2 answers

Are there known compatibility issues with R package mgcv? Are there general rules for compatibility?

I use R version 2.15.1 (2012-06-22) and mgcv version 1.7-22 I load the following set of packages in R: library(sqldf) library(timeDate) library(forecast) library(xts) library(tseries) library(MASS) library(mgcv) It happens that I can not run a…
Richi W
  • 3,534
  • 4
  • 20
  • 39
1 2
3
30 31