Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mgcv]

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

1
vote
1answer
18 views

Random effect in GAM - what are the smooth functions used?

In the GAM package in R created by Simon Wood there is a selection of the smooth function basis. I sort of understand the options such as bs='tp', bs='cr', etc. But bs='re' seems odd... that does ...
1
vote
0answers
16 views

mgcv factor smooth interaction plot [closed]

I am using mgcv with factor smooths to compare smooths of 5 Type factors. Example code is m <- gamm(Y ~ s(X,Type, bs="fs"),random=list(UnID=~1) I plot the results using plot(m) but how do I link ...
2
votes
1answer
36 views

Modeling academic seasonality with hierarchical GAMs

I am trying to model the seasonality of daily pageviews to calculus-related Wikipedia articles using a hierarchical GAM, assuming that there is a shared 'academic calendar' seasonality and that each ...
1
vote
1answer
26 views

predict.bam() produces different results when data is subset

Apologies in advance since I cannot provide a reproducible example due to the immense size of my model. I'll do my best to describe my situation fully, hopefully this will be sufficient. My model ...
0
votes
1answer
67 views

Time series analysis via generalized additive models: model assumptions and stationarity

I have settled on building a generalized additive mixed model using mgcv::gamm, on data and for purposes I have described in more detail here. In a nutshell, I want ...
2
votes
1answer
64 views

Explaining tourist numbers over time to historic sites, based on a set of predictors

I've been struggling for some time trying to figure out the most appropriate way to analyse some data. My task is to (hopefully) explain what may be driving the flow of visitors/tourists to two ...
2
votes
0answers
31 views

Concurvity in additive modelling. Parametric term?

I am modelling a outcome in gam were two variables (x1 and x2) are continuous and the other four are factors. I have a suspicion that x1 and x2 might be collinear so I want to check that. As I ...
3
votes
1answer
46 views

Non-normal random effects in a logistic GAM

I have estimated the following GAM using the mgcv package: ...
0
votes
0answers
45 views

How do I adress non-normal residuals in gam/gamm

I am trying to fit a GAM where the outcome (y) depends on 2 continuous variables (v1 and v2) and 4 categorical variables (v3-v6). $$M1 <- \mathrm{gam} (y \sim s(v1) + s(v2) + v3 + v4+ v5+ v6)$$ ...
1
vote
1answer
74 views

Correcting for multiple pairwise comparisons with GAM objects {mgcv} in R

My question concerns pairwise comparisons of factor levels in a gam object. I have a dataframe, df, containing reaction time data (in ms) to stimuli varying in ...
1
vote
0answers
14 views

Difference between tensor product and main effects plus interaction in mgcv [duplicate]

I was under the impression that using te and adding the main effects with s plus the interaction with ...
0
votes
0answers
20 views

Is it possible to control the degrees of freedom for the internal smooth on a soap-film?

I am using the mgcv package in R to fit a gam to spatial measurements of density. My aim is to use this gam primarily for spatial interpolation and smoothing, but ...
0
votes
0answers
29 views

GAM and Mgcv package problem in R (about LOESS)

I have question about gam package in R. I am trying to use LOESS function in gam::gam package, however, the package doesn't seem to offer much applications such as gam.check or concurvity from mgcv::...
2
votes
1answer
37 views

Inconsistent mgcv gam.check results

I'm not sure if this question is appropriate for cross validated, but I'm not sure where else to post it. I've built a simple model using the mgcv package. <...
1
vote
1answer
64 views

Interpretation of Tensor product splines with multiple terms and their standard errors?

I am trying to understand the tensor product splines such as ...
1
vote
1answer
182 views

Extracting significance of gam smoothing terms

I have a time course data to which I'd like to fit a gam and have easy interpretability, and by that I mean obtaining coefficient...
1
vote
1answer
49 views

How does Markov random field (bs=mrf) in mgvc gam handle repeated measures on the spatial units?

I am attempting a spatio-temporal model in mgcv gam. I am using a factor smooth to define each of 27 areal units in a shapefile ("id") as subjects (essentially) which have undergone 23 repeated ...
2
votes
1answer
77 views

Determining significant changes in slope in a nested GAM

I have annual measurements from 2 sites and want to plot where significant changes in slope occur in each site (in a nested design). I can achieve this using non-nested data based on Gavin Simpson's ...
0
votes
0answers
107 views

dependence structure in GAM partial residual plot {mgcv}

I am modeling daily mortality (dependent variable) against lag 1-day mean temperature (independent variable) with GAM, using the {mgcv} package in R. While looking through my data I noticed some of ...
0
votes
1answer
202 views

Choosing k in mgcv's gam()

This post (link below) alludes to setting the basis dimension to -1 (k = -1) as automatically choosing the number of knots via Generalized Cross Validation (GCV) in R's mgcv package: Selecting knots ...
4
votes
3answers
190 views

Which method is correct? (generalized additive model, mgcv)

If possible could you please let me know if I am on the right track? I don't know anyone who works with GAMs who I can ask and I would be so appreciative of any help I receive. I use mgcv in R. My ...
0
votes
1answer
32 views

Including streaks/runs in (generalized) linear mixed model context

The data and model used so far: I have longitudinal count data on 16 pens (8 with treatment A, 8 with treatment B). Each pen houses the same number of animals, and the pens may be considered as ...
0
votes
1answer
78 views

Visualizing the smooth terms in a logistic regression (GAM model)

We have a a logistic regression model (i.e. family=binomial) estimated with gam of the mgcv ...
2
votes
1answer
52 views

Generalized Additive Model for timely trends of topics generated via Latent Dirichlet Allocation?

I am conducting a topic modeling study via Latent Dirichlet Allocation (LDA) on scientifc abstracts over a range of about 20 years (in R). One of the outputs of LDA is a document-topic-distribution ...
2
votes
1answer
85 views

GAM: Plotting gam models of different treatments?

I want to figure out the best way to plot gams, but I am getting confused about the best way to do this for my data. Please note that I am not a statistician, so 'stats/coding for dummies' answers are ...
2
votes
0answers
131 views

GAM - Smooth comparison with factor variables

I try to compare the splines for my 6 categories. To this end, first I tried the ordered factor approach and posted the result here. This comparison is not sufficient for me since I would like to have ...
1
vote
1answer
935 views

GAM with categorical variables - interpretation

I want to use GAM to analyze my experimental data. In my experiment, participants basically play a game for 40 experimental years. In total I have 6 different conditions and I have a between-subject ...
1
vote
1answer
50 views

Does family 'ocat' work with gamm4 in R? [closed]

I am trying to fit a GAMM to ordered categorical data using gamm4 in R. In the help file for gamm4, it says the argument 'family'...
1
vote
2answers
152 views

Is it possible to fit interaction terms manually in GAM model

I wonder if it's possible to manually fit interaction terms for non-linear predictors in GAM model. Something generically equivalent to R mgcv package : ...
1
vote
1answer
139 views

GAM negative deviance explained for Poisson model fitted with REML

I am fitting time series of neuron spike data with a Poisson GAM. I am fitting it with the following call: ...
1
vote
1answer
25 views

Estimating Range Parameter ($\rho$) for GAMs in 'mgcv' R Package

A while back, I asked a question regarding the fitting of Gaussian Process (GP) smooths within a GAM framework that garnered some interest: Gaussian Process smooths in mgcv: choosing between ...
0
votes
1answer
33 views

MGCV: Signal Regression with 2-D Predictors

Does anyone have any insights on how to perform signal regression when the smooth predictor has more than one dimension? The single dimension setting, ...
2
votes
1answer
133 views

Model Comparison of GAMs using gamm4

I am using a GAM from package gamm4 in R to fit a varying coefficient model for longitudinal data. I have data consisting of ...
3
votes
2answers
219 views

In R package mgcv, is it valid to have a random effect smooth on two continuous variables?

In my model, I have two variables, distance and time, that influence the performance of different subjects (success or failure). The relationship between distance and time is nonlinear, not separable ...
0
votes
0answers
50 views

mgcv optimization: why optimize **log** smooth parameter?

In mgcv package, when optimizing smoothing parameters (in the outer iteration), one take the partial derivative of objective function with respect to $\rho = log(\lambda)$. My question is why not take ...
0
votes
0answers
37 views

Posterior Simulation of Maximum of a GAM

In carrying out posterior simulation according to this post: Can I use bootstrapping to estimate the uncertainty in a maximum value of a GAM?. I simulated 1000 observations from a multivariate ...
0
votes
1answer
343 views

How to extract confidence interval from mgcv GAM model? [closed]

I have a basic GAM model setup, with one predictor: fit <- gam(response ~ s(predictor, k=12), data = data, ) I noticed I can easily pull out the fitted values ...
0
votes
0answers
50 views

concurvity with random effects and by = factor terms in mgcv

I was validating some GAMs today, checking for concurvity with concurvity(model, full = TRUE). Results come up and everything in the model was basically 1 or close to. After overcoming my initial ...
2
votes
1answer
136 views

Are mvrnorm() in MASS R package and rmvn() in mgcv R package equivalent?

I am carrying out posterior simulation with GAMs/SCAMs and was wondering if/how the rmvn() function differs in any way from the ...
1
vote
1answer
179 views

GAM selection when both smooth and parametric terms are present

I'm fitting GAMs to avian survey data and have a mix of smooth (thin plate regression splines) and parametric terms in my models. I know about the integrated term selection available in mgcv via ...
0
votes
1answer
113 views

Dispersion value with glmmTMB versus mgcv::gam()

Assume we parametrize the variance in a negative binomial regression model as: variance = mu(1+mu/theta). Fitting the model with glmmTMB, I check theta from: <...
5
votes
0answers
223 views

Predictive modeling using GAM (mgcv)

I have seven years of continuous insect population data, along with temperature and humidity parameters. I’d like to use this data to predict future populations in a given year using a generalized ...
1
vote
1answer
158 views

Is there a way to plot the tuning parameter selection in mgcv?

Take a simple analysis using generalized additive models in mgcv: ...
1
vote
0answers
81 views

R.sq in gam model (mgcv)

first question here. I'm constructing GAMs for multispecies avian survey data, and running into some odd results in the calculation of R.sq in the summary() command. For one of my species, when i use ...
0
votes
0answers
43 views

Estimating variable importance in GAMMs

I am using the mgcv package in R to model the ratio of damaged culture hectares by wild boar in each french department according to some environmental covariates. I ...
2
votes
1answer
257 views

Specifying generalized additive models in R (using the mgcv package)

I'm currently trying to figure out how to specify a generalized additive model in four different ways in order to investigate how my outcome variable changes surrounding different events. So what I ...
2
votes
0answers
198 views

Prediction Confidence Intervals when fitting a GAM model using gam package

Is there any way to get a prediction confidence interval from a model fit with gam package? Working with mgcv is not an option for me as it doesn't provide as good fit as gam does on my data. The ...
0
votes
0answers
213 views

mgcv: is bam() more appropriate than gam() for simulated data generated via iteration?

I have devised an iterative method of curve-fitting and am looking to compare generated estimates from my method to GAMs (as well as SCAMs) via the mgcv R package. Since my data were generated via ...
0
votes
0answers
346 views

Modeling autocorrelation in Generalized Additive Models (GAM) with re-splines

Related to previous post for speeding up GAMM. After fitting a GAM with mgcv, the autocorrelation (acf) and partial-autocorrelation (pacf) of the residuals reveal very clear AR8 behaviors (pacf sharp ...
2
votes
0answers
50 views

Non-constant overdispersion (overdispersion parameter depending on covariate) in negative binomial regression

In a negative binomial regression (daily number of cases of a disease over time), after controlling for several factors and experimenting with several functional forms, my results still don't look ...