Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
0answers
18 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
30 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
23 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
0answers
69 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 ...
0
votes
0answers
19 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 ...
1
vote
1answer
18 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 (...
0
votes
0answers
34 views

Correct way to account for repeated measures and spatial autocorrelation in GAMM (R)

I am using the gamm function in the mgcv package in R to specify a model that predicts abundance with respect to elevation and year based on repeated measures from several sites. My overarching ...
0
votes
0answers
15 views

Dealing with complete separation in Generalized Additive Models

Related to "How to deal with perfect separation in logistic regression?": I am modelling survival using a binomial mixed model (gamm from ...
1
vote
1answer
52 views

Why doesn't penalized cubic regression reduce the number of knots in a GAM?

As far as I understand, cubic regression penalization prevents overfitting by reducing the number of knots by penalizing wiggliness. The supplied parameter k serves ...
0
votes
0answers
26 views

Circular smooths within a GAM-GEE framework

I have a predictor variable which I fit in a GAM as a circular smooth term: ...
3
votes
1answer
43 views

Why p-values are not significant even though AIC values improved a lot in model selection using GAM mix modelling and beta regression

Dear StatExchange community, I am studying disease progression in plant leaves and I am trying to estimate differences between a wild-type and a mutant plant. To achieve this I am using the ...
0
votes
0answers
39 views

How to calculate pooled deviance explained from gam model fitted with multiple imputation data set?

I fitted gam model using mgcv package with multiple imputation data set. I need to calculate the combined overall deviance explained. Is the approach used in combining r-square from multiple ...
1
vote
1answer
44 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
20 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
54 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
30 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
201 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
73 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
42 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
54 views

Non-normal random effects in a logistic GAM

I have estimated the following GAM using the mgcv package: ...
1
vote
1answer
128 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
17 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 ...
2
votes
1answer
46 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
121 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
288 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
73 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
98 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
148 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
335 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 ...
5
votes
3answers
282 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
34 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
116 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
57 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
121 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
179 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
2k 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
63 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
193 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
180 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
27 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
0answers
181 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
267 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
57 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
44 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
497 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
63 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
217 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
219 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
134 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: <...