6 votes

Calculation of degrees of freedom for B-splines

Cubic splines are not just many third-degree polynomials with knots marking the transitions between one polynomial and another, they are constrained third-degree polynomials with knots marking the ...
jbowman's user avatar
  • 38.7k
6 votes
Accepted

Basis dimension (k) too low for the smooth term in a GAMM

It's not a huge problem in your case. The best I can find on it is p.330-331 of this guide by Simon Wood. Because the edf is way below the basis dimension I don't ...
Blundering Ecologist's user avatar
5 votes
Accepted

GAMM with Zero-Inflated Negative Binomial - Looking for a package in R

This model is possible with the brms R package which is an interface to R: A slight modification of one of the examples from https://cran.r-project.org/web/packages/brms/vignettes/brms_distreg.html ...
Gavin Simpson's user avatar
4 votes
Accepted

GAM with many binary factors

You're assuming that the audience here knows quite a lot about your particular subject area and specific task. I'm also going to assume your pseudocode was just a thinko as it is ...
Gavin Simpson's user avatar
4 votes
Accepted

How to interpret non-signicant intercept but significant smooth terms with GAM in R?

The intercept in a model like this is the mean of $\mathbf{Y}$ in the Male group. I doubt the test therefore is of anything of interest ($H_0: \hat{\mu}_{\text{male}...
Gavin Simpson's user avatar
3 votes

Obtaining, and manipulating, the prediction equation from a gamm model with smooth terms

Given fit <- gamm(Y ~ s(X) + s(Z)) and assuming Y is where you want to predict... ...
Gavin Simpson's user avatar
3 votes
Accepted

AIC comparison of GAMM and LMM: Is it valid?

You have to be very careful with off-the-shelf AIC calculations for mixed models and for GAMs. For the latter, you want the AIC to account for having done smoothness parameter selection for example. ...
Gavin Simpson's user avatar
3 votes

Using gamm4 on zero-inflated count data with Tweedie or zero-inflated Poisson distributions

You can't use these extended families outside of gam() or bam() from the mgcv package. With gamm4 you're stuck with the families ...
Gavin Simpson's user avatar
3 votes
Accepted

Is my GAM modeling longitudinal change appropriately?

The first model fails because you ask for too many coefficients; you ask for Subject specific intercepts twice (!) and try to fit 9 basis functions per ...
Gavin Simpson's user avatar
2 votes

Is GAM appropriate for these data

It's hard to see nonlinear relationships in your scatterplots by eye unless you superimpose a loess fit - that would be easy to do in R via the geom_smooth() function of the ggplot2 package. (If ...
Isabella Ghement's user avatar
2 votes
Accepted

What to do when GAMM is linear?

I wouldn't use AIC for {gamm4} models - or rather I'd want to check very closely that an AIC that was corrected for the extra uncertainty due to smoothness selection was implemented for ...
Gavin Simpson's user avatar
2 votes
Accepted

Unable to extract AR(p) values from the GAMM function in mgcv

Try coef(GAM_sim2$lme$modelStruct$corStruct, unconstrained = FALSE). I found this by looking through the {nlme} functions ...
Alex J's user avatar
  • 2,206
2 votes
Accepted

Interpretation help of summary from basic GAM models with random smooths

In my opinion you are correct to be cautious about simply using $p$-values to guide interpretation. {mgcv} has amazing functionality and the significance tests are ...
Nicholas Clark's user avatar
2 votes

Nonparametric version of lme- gamm function in R

I think there is some confusion on the terms and the programming elements, so let me explain a bit what each is: A linear mixed model (LMM) is a linear regression technique that incorporates random ...
Shawn Hemelstrand's user avatar
1 vote

High autocorrelation in GAMM

Does this itsadug-based approach using bam substantially reduce the autocorrelation? ...
denis's user avatar
  • 185
1 vote

use GAMM models for full circular wind direction data

If the effect of the cyclical component on the response can possibly change smoothly over time, an alternative is to use a smooth modulation model (like the one proposed by Eilers et al. (2008) and ...
Gi_F.'s user avatar
  • 1,171
1 vote

use GAMM models for full circular wind direction data

There is nothing per se wrong or flawed about representing wind direction, a circular variable, via a cyclic cubic regression spline. That this approach is not as common (or used at all) in your field ...
Gavin Simpson's user avatar
1 vote

Specifying random effects using GAMM4

Even though these are essentially the same model, you're seeing different behaviour because of how these models are actually fitted. In fit1, the ...
Gavin Simpson's user avatar
1 vote
Accepted

INTERPRETATION OF GRAPHIC RESULTS OF GAM IN R

Q0 If you look closely at the plot for the s(Year) term, you'll see it doesn't actually include 0 everywhere, e.g. the local peak around ~2000. You likely want <...
Gavin Simpson's user avatar
1 vote

How to interpret the plotted difference of in-factor smooths

The first plot showing the two smooths also includes the model constant term (the intercept), whereas the second plot is showing the difference between the two smooths themselves, excluding the ...
Gavin Simpson's user avatar
1 vote

Irregular time series with multiple sampling sites

I would suggest a different strategy, fitting this as a GAM via gam(), and using a count distribution as the real response variable is an integer count. The ...
Gavin Simpson's user avatar
1 vote
Accepted

Does family 'ocat' work with gamm4 in R?

No, ocat doesn't work with gamm4(). From ?family.mgcv As well as the standard families ...
Gavin Simpson's user avatar
1 vote

Getting better p-values for a gam model with multiple explanatory terms using bootstrapping

Although Wood 2006 said that p-values shouldn't be trusted, Wood 2013 said that they should be fine. See help("summary.gam") for the references and ...
rep_ho's user avatar
  • 7,619
1 vote

GAMM with fragmented spatial data - presence/absence response

You could add s(Year) + s(Year, by = area, m = 1) which will generate a common trend (s(Year)) and ...
Gavin Simpson's user avatar
1 vote

R^2 for mixed effect models (both generalized linear and additive)

You might be interested in checking-out performance's r2() family of functions, that works with mixed models. For gamm4, support should be implemented soon (see ...
Dominique Makowski's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible