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
4
votes
2 answers

How do you plot smooth components of different GAMs in same panel?

I have two GAMs which have the same predictor variables but different independent variables. I would like to combine the two GAMs to a set of plots where the smooth component (partial residuals) of each predictor variable are in the same panel…
tolonen
  • 67
  • 6
4
votes
1 answer

Finding maximum on a 3D gam-smoothed surface

Given the following example: library(mgcv) set.seed(2) dat <- gamSim(2, n = 1000, dist = "normal", scale = 1) m <- gam(y ~ s(x, z, k = 40), data = dat$data, method = "REML") fit <- predict(m) vis.gam(m, se=T, type="response") Is there any way to…
Kenny Chen
  • 43
  • 4
4
votes
1 answer

mgcv GAM with betar

Does anyone know how to obtain the fitted phi parameter from the model output (mgcv GAM with a beta distribution)? Referring to the betar gam example provided: library(mgcv) ## Simulate some beta data... set.seed(3);n<-400 dat <- gamSim(1,n=n) mu <-…
lmyt
  • 71
  • 2
4
votes
1 answer

How to change the y-axis for a multivariate GAM model from smoothed to actual values?

I am using multivariate GAM models to learn more about fog trends in multiple regions. Fog is determined by visibility going below a certain threshold (< 400 meters). Our GAM model is used to determine the response of visibility to a range of…
Q.James
  • 41
  • 2
4
votes
1 answer

mgcv: How to use 'exclude' argument in predict.gam?

I have a model structured as follows, and I would like to extract the predicted values while ignoring the random effect. As specified in ?predict.gam and here, I am using the exclude argument, but I am getting an error. Where is my mistake? dt <-…
mluerig
  • 638
  • 10
  • 25
4
votes
1 answer

mgcv_1.8-24: "fREML" or "REML" method of bam() gives wrong explained deviance

Fitting the same model with bam using methods "fREML" and "REML" gave me close results, but the deviance explained is rather different as returned by summary.gam. With "fREML" the quantity is ~3.5% (not good) while with "REML" it is ~50% (not that…
Arnaud
  • 377
  • 1
  • 2
  • 11
4
votes
1 answer

"not resolved from current namespace" error, when calling C routines from R

I am recently doing some computational testing with mgcv GAM. Some original functions are modified, and some are added. In order not to break compatibility, for every function I want to modify, I create a new version with a .zheyuan surfix in…
Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
4
votes
3 answers

R Recover original data.frame from model.frame

In R, you can fit GAM models from the mgcv package using a formula which contains transformations such as log or sqrt and by default the model.frame is returned (only the variables specified in the formula with transformations applied). Is there any…
Steven M. Mortimer
  • 1,618
  • 14
  • 36
4
votes
1 answer

GAM R variance explained by variable

My current problem is to calculate the variance explained by the different variables of a general additive model (GAM) with R. I followed the explanation given by Wood here : https://stat.ethz.ch/pipermail/r-help/2007-October/142743.html But I would…
4
votes
0 answers

Random effects modeling using mgcv and using lmer. Basically identical fits but VERY different likelihoods and DF. Which to use for testing?

I am aware that there is a duality between random effects and smooth curve estimation. At this link, Simon Wood describes how to specify random effects using mgcv. Of particular note is the following passage: For example if g is a factor then…
4
votes
1 answer

How can I fit all variables using splines with gam in R without typing each one?

Lets say I have a data set with y and x1, x2, xp variables. I want to fit all of my predictors with splines. For example : gam_object = gam(y ~ s(x1) + s(x2) + s(xp), data) How can I do this without typing every single variable? If I would like to…
Jixxi
  • 111
  • 1
  • 11
4
votes
2 answers

How to get confidence interval for smooth.spline?

I have used smooth.spline to estimate a cubic spline for my data. But when I calculate the 90% point-wise confidence interval using equation, the results seems to be a little bit off. Can someone please tell me if I did it wrongly? I am just…
Yu Deng
  • 1,051
  • 4
  • 18
  • 35
4
votes
0 answers

extract automatically generated knots mgcv package r

Is there any way of identifying the number and position of the knots when using gam in the mgcv package in r? So I have something like this: fit.add <- gam( rep.pos ~ 0 + factor(AY) + s(dur), family=quasipoisson(link='log') ,…
4
votes
1 answer

Changing the Y axis of default plot.gam graphs

I have run a GAM in R using the mgcv package with the following form: shark.gamFINAL <- gam(ln.raw.CPUE...0.1 ~ Year + Month + s(Mean.Temp, bs = "cr") + s(Mean.Chl.a, bs = "cr") + s(Mean.Front.density,…
user2236109
  • 41
  • 1
  • 3
3
votes
2 answers

Removing the penalty on the quadratic term in a penalized cubic spline in MGCV?

I'd like to fit a penalized cubic spline with the R package mgcv in which I don't apply any penalty to the intercept, linear, AND quadratic terms in the model. The penalty should only apply to the cubic and other terms in the spline basis. I'd like…