730 questions
-3
votes
0
answers
41
views
SCAM model summary NA R
I am using the scam library in R to fit an SCAM model to my data.
If my model contains depth, then I get NA in salinity.
If my model does not contain depth, then I get an estimation for salinity.
Why ...
Advice
0
votes
2
replies
51
views
Detect non-linear regression patterns in multiple univariate analyses
I have a dataset with around 10,000 continuous variables (gene abundances) in 200 samples, and also some parameters of these samples (e.g., pH). I am trying to see if there are any genes whose ...
0
votes
0
answers
31
views
GAM OAuth 2.0 + Keycloak
I have successfully implemented OAuth 2.0 authentication between GAM and Keycloak. Login works perfectly.
What already works:
✅ Full OAuth 2.0 authentication
✅ Login and redirection working
✅ User ...
0
votes
0
answers
34
views
Having trouble using multiple imputation for covariates in generalized additive model using mice package
I am attempting to figure out how to perform multiple imputation using the mice package when I am fitting a generalized additive model. I have a fully observed continuous response variable with 4 ...
2
votes
1
answer
69
views
Y-axis of mgcv::gam cox.ph model: rate or ratio?
I am plotting a nonlinear generalized additive model (gam) using R's mgcv package:
library(mgcv)
V <- rep(1, nrow(dt)
fit <- gam(cbind(V, group_number) ~ s(time_elapsed, exposure_group, bs='fs'...
1
vote
1
answer
56
views
Error running GAM with soap smoother - data outside soap boundary
I am running a gam model with a soap smoother
mod_aut_X10 <- bam(occurrenceStatus ~
s(x, y, bs = "so", xt = list(bnd = shap_bnd_ls, nmax = 1000)) +
s(...
2
votes
1
answer
137
views
How to correctly specify lower and upper bounds in mgcv mono.con function
In the documentation for mgcv::pcls(), an example of constructing a monotonically increasing gam model is provided with the following code:
set.seed(1234) # added for reproducibility in this post only
...
1
vote
1
answer
82
views
Variogram per group
I'm using a variogram to try and detect un-accounted for temporal auto-correlation in my model, but it shows the same pattern for all group levels (fSite). I allowed each fSite to have it's own trend, ...
1
vote
1
answer
101
views
Problem running classification Gam models with Additive Function
I am having problem running a classification (binary outcome) gam model using the additive package in combination with tidymodels. I have tried to follow the creator of additive's GetStarted.Rmd ...
0
votes
0
answers
89
views
Verbose output for GAM Gaussian family via mgcv
I'm building a GAM via mgcv, which takes days to build. Is there any way to know how much of the model has been built just to get an indication of what is left?
Can I print all details during the run ...
0
votes
1
answer
146
views
How to exclude random effects (smooths) when visualizing GAMMs with the vis.gam function of the mgcv package?
As far as I know, mgscv's vis.gam does not feature an argument like exclude = c("s(id)", ...) to exclude a random effect s(id, bs = "re") of a GAMM from the prediction. Is there ...
1
vote
1
answer
65
views
How to add density plots for x and z axes in a tensor smooth plot?
I created this plot using tensor smooths..
I would like to add a visualization of the data density along the x-axis and z-axis. Ideally, this could be done with either:
A rug plot on the respective ...
1
vote
0
answers
57
views
Pause and resume GAM processing in R with multithreading using foreach
I have quite complicated additive models (GAMs) to be processed in R. Since it already takes several days (not finished yet) for even one model, and I would like to process some 100s, I would like to ...
0
votes
0
answers
56
views
Normality Issue with `gam.check()` after adding Random Effect
I am trying to run a GAM that includes 8 input variables (see code below). I first ran the model without accounting for any random effect and the gam.check() appeared to be a good fit. After I add the ...
0
votes
1
answer
66
views
Extremly high deviance explained but no significant predictors in mgcv()
I have a small (n=28) dataset of three seabird occurrence count data and have run a hurdel GAM model (using mgcv::gam()) with first using a binary model with presence/absecene, and then a negative ...
1
vote
2
answers
118
views
Changing the title and labels of the plot provided by draw in the gratia package
I would like to change the title of the plot and the labels on the x and y axes without modifying the variable names in the dataframe.
I am using the gratia package.
library(patchwork)
library(gratia) ...
0
votes
1
answer
123
views
geom_smooth() producing a linear fit
I'm using R to model the tone contour (pitch) of words in a language and I have two main questions. Note that I am new to R and don't have a data science background, so any help is really appreciated.
...
1
vote
1
answer
73
views
Very odd plots from posterior simulation of factor by GAM model
I am running the model below (modGI_test):
modGI_test <- gam(Met1 ~ Antibiotics + s(Timepoint, k=7) +
s(Timepoint, by=Antibiotics, k=7, m=1) +
s(Timepoint, ID_new,...
0
votes
1
answer
58
views
Using map() with GAM model
I have a code that works if I am using LM but not if I am using a GAM. I guess the that for whatever reason LM looks inside object for the variable and GAM just looks at the names of the object but I ...
1
vote
1
answer
196
views
GAM model with multidimensional categorical response variable (with mgcv) [closed]
I try to fit a GAM model with a multidimensional categorical response variable combining three binomial dimensions (e.g., A-B by a-b by α-β) lacking certain combinations and depending on a smooth of ...
0
votes
0
answers
37
views
The overly large size of the dataset makes the GAMM curves sharp/angular?
I am currently building several similar GAMM models on numerous datasets with the same structure but varying sizes, with the smaller datasets containing about 15k rows and the largest around 400k. I’...
0
votes
1
answer
221
views
gam fails with the error - "inner loop 3; can't correct step size"
I am using the mgcv package to train a gam model (family = betar(), method = 'REML' using 10 threads). I use the tp basis.
I split my dataset in multiple train-test splits - my main interest is ...
2
votes
0
answers
54
views
How to pass an explicit weights vector to a gam function in R
I'm working with the gam function from the mgcv package in R, and I have a custom function that uses a weights vector to fit the model. My issue is that when I pass a weights vector to the function as ...
1
vote
0
answers
125
views
Warning message: In bgam.fit(G, mf, chunk.size, gp, scale, gamma, method = method, : algorithm did not converge
I am fitting this model:
m <- bam(f,
data = d,
family = binomial(link = 'logit'),
select = TRUE,
method = 'REML')
where f is y ~ s(t) + s(x1) + s(x2) + s(x3) + ...
1
vote
1
answer
43
views
GAM predictors structure: matrix vs long data.frame format
I am fitting a typical GAM with lagged structure. The gam has the general form:
g1<-gam(y~te(e, l), data=df)
Specifically:
#exposure
e <- matrix(rnorm(2500, mean = 100, sd = 25), ncol=50)
#lag
...
2
votes
1
answer
206
views
How to add a monotonic constraint in a GAM model
I use the mgcv package on R, and I have a model like this :
gamm_model <- gam(Y ~ s(X, bs = "ps") + B + C + s(D, bs = 're') + s(E, bs = 're'), data = df)
summary(gamm_model)
I would ...
3
votes
1
answer
161
views
How to use terra::predict for raster output to predict GAM temperature model with seasonal variation
I am trying to model temperature across seasons using (package mgcv) GAMs. I am interested in using terra::predict() to plot the predicted temperatures as a raster.
Ideally, the output would be 4 ...
2
votes
1
answer
75
views
Generate predictions for GAM (mgcv) using penalised cubic spline forced through a certain point
I am using MGCV to generate predictions for a GAM using a cubic spline forced through a certain point. I have generated the gam exactly as outlined in this post: https://stat.ethz.ch/pipermail/r-help/...
2
votes
1
answer
86
views
Exporting summary.betareg and summary.gam from list to csv
I have two types of models (GAM and beta regression) that I am running for my data and I am using a lapply function to iterate over multiple variables. I am encountering an error when trying to export ...
0
votes
1
answer
387
views
Prediction values don't match fitted function from GAM model
I have a presence/absence data for a species occurrence and I did a binomial GAM using sea surface temperature (sst) as a predictor variable.
My df object is a data.frame with the presence/absence ...
1
vote
1
answer
77
views
predict.gam behaviour gives error in R4 but works in R3. full reprex included
In R version 3.6.3, my predict.gam function gives a result. When I use R 4.x, I get errors for some types of predict, but not others.
My goal is to be able to use this code in R4.
library(gam)
gm1 <...
0
votes
0
answers
121
views
Missing category in reference level in multinomial GAM with mgcv in R
Consider the multinomial GAM with mgcv in R
library(mgcv)
multinom = gam(list(sound ~ word + s(long, lat),
~ word + s(long, lat),
~ word + s(long, ...
0
votes
0
answers
100
views
gam function output (mgcv package)
How can I improve my bam model if 3/4 gam.check plots show poor diagnosis, except for the histogram of residuals (which shows a normal distribution).
My response variable is soundscape saturation (...
0
votes
1
answer
402
views
Step failure (and iteration limit) in multinomial GAM with mgcv in R
I have a data set with 40 sites (long, lat) by 2 ages by 2 genders by 6 words and 6 dependent sound categories (coded 0 to 5) as simulated here:
sound <- sample(0:5, size=960, replace=T)
...
1
vote
0
answers
64
views
mgcv predict.gam in R version 4 gives error, in R version 3, no error
In R version 3.6.3, my predict.gam function gives a result. When I use R 4.x, I get errors for some types of predict, but not others:
library(gam)
library(dplyr)
gm1 <- predCol ~ s(VCF_nontree) + ...
1
vote
1
answer
192
views
How to Plot Difference Smooth with confidence Intervals using gamm4 in R
I am currently working on fitting splines with gamm4 and I have hierarchical data. In my dataset, Trial_no is nested within VP, and SoundType (levels: STA and DEV) is a level-1 predictor. My model ...
1
vote
1
answer
145
views
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 ...
1
vote
1
answer
205
views
Plotting a QQplot from a logistic GAM fitted with mgcv and using weights
Here is a little script describing my problem.
I am fitting a logistic model in R using the mgcv package.
The dataset represent the occurrence of an event under certain conditions.
For this model, I ...
1
vote
2
answers
236
views
Using both foreach and bam from the mgcv package
I have several large GAM models to fit (lots of data, various distributions for residuals and random effect smooths). Currently, I use foreach with a cluster of processors based on the parallel ...
0
votes
0
answers
183
views
How to visualize GAM fit with a multiple imputed dataset?
I’m working with a dataset that has missing values, and I am using multiple imputation with the mice package in R. I then fit a Generalized Additive Model (GAM) using the mgcv package on the imputed ...
1
vote
1
answer
76
views
Cannot force legend to bottom in gratia::compare_smooths
I am using the wonderful gratia package to visualize multiple gam models from the mgcv package using the compare_smooths function. While I am able to create the gams properly and draw them, I cannot ...
2
votes
1
answer
303
views
How do I plot GAM model with log transformed response
I created a GAM model using mgcv. My response variable is log transformed. I would like to plot this model using gratia. However, I want to make sure the y-axis is exponentiated after I plot it using ...
1
vote
1
answer
152
views
Extract the effective degrees of freedom (EDF) from a Generalized Additive Model (GAM) applied to an imputed dataset
How do you extract the pooled estimated degrees of freedom (edf) from a pooled generalized additive model ?
library(mice) # For multiple imputation
library(mgcv) # For GAM models
library(broom) # ...
0
votes
2
answers
247
views
Create a logit GAM species prediction raster using Terra [closed]
I am trying to predict the occurrence of a species (presence/absence) using a GAM in R. I have fit the GAM, but I get an error when I try to make the prediction to spatial data with terra::predict(). ...
0
votes
1
answer
26
views
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....
0
votes
1
answer
644
views
Mixed GAM with zero-inflated poisson distribution in r [closed]
I'm encountering an issue fitting a model with zero-inflated data. You can view the distribution of the response variable here:
The random effect is linked with the variable "site".
The ...
1
vote
1
answer
201
views
Plotting geom_smooth with log10 transformation
This is my first post so I am sorry if I did something wrong (hope not!).
I am struggling with aesthetics of my GAM plots, tried different options, searched for solutions but did not succeeded.
I am ...
0
votes
0
answers
74
views
mgcv::gam mimicry of default geom_smooth gam when n is small
Am performing mgcv::gam over each unique XY pairing (2 in this instance) and both of these pairings have just 11 obs. Ideally, the prediction of A=0 should be somewhere between B = 2,000 and 1,000. ...
1
vote
1
answer
102
views
How to correct error in gamm for modGI hierarchical model (and thus how to visualise and correct for autocorrelation more than AR1 in time series)?
I have blood biochemistry markers measured in 28 subjects, where samples were collected every month.
I can run a simple modG with gamm and get the acf and pacf plots.
modG <- gamm(Met1 ~ s(...
1
vote
1
answer
7k
views
"Error in Ops.data.frame(guide_loc, panel_loc) : ‘==’ only defined for equally-sized data frames" when using draw() from gratia to draw GAM in r
I am trying to draw GAMs in R using the below code. This code always used to work, and I could draw the partial effect of my smoothed term, but randomly it no longer works, consistently triggering ...