Relative Content

Tag Archive for gam

Finding x at maximum/peak of a Generalised Additive Model (GAM) of y~x

I am attempting to model species’ responses to an environmental gradient to characterise their niche in terms of this gradient. I will be using a data on presence/absence of species in grids along this gradient, and a GAM so that I can have flexible shapes and incorporate a number of covariates.

gam modeling: error in variable specification

I have created this regression model that works well :
Model1 = bam(depend ~ s(indep, by = gender.x,bs = “tp”) + s(Age, by = gender.x, bs = “tp”)+ ti(Age, indep, by=gender.x ) + gender.x + s(Subject, bs = “re”) + s(Age, Subject, bs = “re”)+ s(ImagingCentreCity, bs = “re”), data = M2_SRS_Project, method = “fREML”, family = “gaussian”)
but when introducing the variable ‘timepoints’ :
model2 = bam(depend ~ s(Age, bs=”tp”) + s(indep, bs=”tp”) + s(Age, indep, bs=”tp”, by=gender.x) + gender.x + timepoints + s(Subject, bs=”re”)