Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
949 views

x2 will represent factors "a" and "b" for this simplified example, and f3 is the random effect. (I don't know if the compound symmetry correlation is part of my problem). gamm(...
Molly Smith Metok's user avatar
0 votes
0 answers
250 views

I'm using the mgcv package to create GAMs in R. Right now I am attempting to model the interaction between my numerical variable Depth and various categorical variables. I have converted all of the ...
Zesra's user avatar
  • 1
0 votes
0 answers
593 views

My code when running the generalized additive model with the betar family is as follow. libary(mgcv) b1 <- gam(ssim_exp ~ s(stage, k = 4, fx = TRUE, by = comparison_type) + comparison_type, data = ...
nerd's user avatar
  • 493
0 votes
1 answer
251 views

I have estimated a GAM model (using the mgcv package) with an intercept and two smoothed terms such as: y = intercept + b1*s(x1) + b2*s(x2) But when I predict y on new dataset of a single row with ...
Telis's user avatar
  • 362
-1 votes
2 answers
1k views

I want to achieve a GAM plot that looks like this Image from https://stats.stackexchange.com/questions/179947/statistical-differences-between-two-hourly-patterns/446048#446048 How can I accomplish ...
nerd's user avatar
  • 493
0 votes
0 answers
161 views

I have height data (numeric height data in cm; Height) of plants measured over time (numeric data expressed in days of the year; Doy). These data is grouped per genotype (factor data; Genotype) and ...
Bertold Mariën's user avatar
0 votes
1 answer
225 views

I fitted the model using the following code mod1 <- gam(severity ~ s(mean_rh, k = 8) + s(mean_temp, k = 10) + s(mean_ws, k =7) + s(avg_daily_rain, k = 7), family = betar(), data = dat_seasonal) ...
Ahsk's user avatar
  • 333
3 votes
2 answers
442 views

I'm trying to compare the climate response in the last 60 years of two subgroups of a plant (factor variable subgroups with 2 levels). The response of the two subgroups which both grew on the same ...
user avatar
1 vote
0 answers
174 views

In R I'm running a mgcv::gam() function with 12000 observations and using 130 parameters (mostly factors and 3 splines. I get the following error message: Error in magic(G$y, G$X, msp, G$S, G$off, L = ...
Hal's user avatar
  • 105
1 vote
1 answer
472 views

I am fitting the below GAM in mgcv m3.2 <- bam(pt10 ~ s(year, by = org.type) + s(year, by = region) + s(org.name, bs = 're') + s(org.name, year, bs = ...
Pat Taggart's user avatar
0 votes
1 answer
415 views

I am building a GAM with a data set which distribution resembles poisson-distributed data. However, my data is continuous, i.e., it contains information on tree volumes in cubic meters. So, when doing ...
eve1234's user avatar
  • 21
0 votes
1 answer
262 views

I have a large dataset (~100k observations) of presence/absence data that I am trying to fit a Hierarchical GAM with individual effects that have a Shared penalty (e.g. 'S' in Pedersen et al. 2019). ...
aczich's user avatar
  • 190
0 votes
0 answers
76 views

I am trying to run different gam models using the mgcv package to predict animal behaviour based on time of day and latitude. My data frame has a 0/1 column that states whether an animal was detected ...
Camila Hurtado's user avatar
2 votes
1 answer
281 views

I'd' like to model the 25th, 50th and 75th quantile regression curves (q25, q50, q75) for 241 values of probability ('prob') depending on x0. For that purpose, I used the qgamV package as follows. ...
denis's user avatar
  • 962
1 vote
1 answer
294 views

I am trying to understand the relationship between NDVI and elevation using a GAM {mgcv}. ndvi=c(0.37284458, 0.36299109, 0.34534124, 0.35626486, 0.33304086, 0.34456021, 0.34147954, 0.37136942, 0....
vermicellion's user avatar
0 votes
0 answers
88 views

I have many hierarchical GAMs fitted with the brm() function of the brms package. Some of my GAMs have a 'I type' structure : y ~ 1 + s(year, by = site, bs = "tp", m = 2) + s(level, bs = &...
Julien Beaulieu's user avatar
0 votes
0 answers
161 views

I am using gam method with both spline and tensor interaction functions(s and ti) inside the train function (for test and train). I know for spline functions in gam we can use method = "gam" ...
Natalia's user avatar
  • 67
2 votes
1 answer
634 views

I have a question about using interaction term in mgcv package with 2 linear predictor. I wrote the code to fit interaction between x1 and x2, mgcv::gam(y ~ x1 + x2 + ti(x1, x2, k = 3), method = "...
Jerison K's user avatar
0 votes
0 answers
221 views

I have built a model with a spherical smooth term containing separate smooths for each level of a factor (formulated as s(lat,lon, bs = "sos", by = factor)) using gam() in the mgcv package ...
Arjan Engelen's user avatar
2 votes
1 answer
602 views

This question is a follow-up to this post: Using gratia::draw() in R to display partial effect plots within an HGAM that are not relative to the global smooth I have a dataset that looks like this: df ...
David Smith's user avatar
0 votes
1 answer
370 views

Hello my dataset looks like this: structure(list(pa = structure(c(2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L), .Label = c("0", "1"), class = "factor"), ...
Mauri21's user avatar
  • 11
1 vote
1 answer
725 views

I have a simple GAM, with one smooth. When I run summary() or anova.gam() on the model, it gives me an F test for the significance of the smooth. However, it is unclear what dfs are being used to ...
andrew m's user avatar
0 votes
0 answers
91 views

Do you know if it is possible to fit a parameter of a random effect using gamm from the mgcv package? For example a Normal distribution N(0, c) and fix c to a certain value instead of being estimated? ...
Bayesianboy's user avatar
2 votes
1 answer
2k views

I am building a model using the mgcv package in r. The data has serial measures (data collected during scans 15 minutes apart in time, but discontinuously, e.g. there might be 5 consecutive scans on ...
CKon's user avatar
  • 23
1 vote
1 answer
80 views

Data Here is the dput of my data: heart <- structure(list(died = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,...
Shawn Hemelstrand's user avatar
1 vote
0 answers
261 views

I tried to follow the example 7.2.6-Prediction with predict.gam from Generalized Additive model : An introduction with R. However, when I ran predict(m2)[1:5] It always gave the following error: Error ...
doraemon's user avatar
  • 853
1 vote
1 answer
562 views

I am applying a GAM model to my data: cell abundance over time. The model works just fine (although I am aware of a pattern in my resiudals, but this is a different issue not relevant here). It just ...
Reesa's user avatar
  • 13
0 votes
0 answers
293 views

I'm trying to model an estimation of the price elasticity of demand for each customer using GAM model, a model like this: \ln D = \ln P + \ln P \cdot \sum_{i=1}^{20} f(X_i) PED = \frac{\partial \ln D ...
Hitalo Pinheiro's user avatar
1 vote
1 answer
144 views

I am trying to get my fitted values from a gam with a few of the features on the GitHub version of gratia and am having trouble using the data_slice() function with a model that has an offset. I am ...
David Smith's user avatar
2 votes
0 answers
148 views

tl/dr: I have a GAM of several predictor variables and smooth functions. I need to constrain one of these smooth functions such that the response of this function is between 0 and 1. I have a GAM in ...
Canadian_Marine's user avatar
2 votes
0 answers
2k views

I'm attempting to report the model summary from mgcv::gam() using the modelsummary package. The flextable package provides a summary that is consistent with the summary output in R and what is often ...
mpschramm's user avatar
  • 550
1 vote
1 answer
897 views

I have a data set that looks like this: df <- data.frame( Lake = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, ...
David Smith's user avatar
3 votes
2 answers
1k views

I would like to make a contour plot with ggplot2 by using gam results. Below is a detailed explanation of what I want: #packages library(mgcv) library(ggplot2) library(tidyr) #prepare data df <- ...
imtaiky's user avatar
  • 333
0 votes
2 answers
151 views

Firstly, I am very new to R, very basic statistical knowledge and have thus been winging it when it comes to my analysis. This means googling the coding I need for the results, and due to how small ...
Barbara Perez de Araújo's user avatar
3 votes
1 answer
648 views

What is the difference between adding a by= parameter to a smooth and adding a random effect smooth? I've tried both, and get different results. E.g.: library(mgcv) set.seed(26) gam.df <- tibble(y=...
Adam_G's user avatar
  • 7,979
0 votes
1 answer
236 views

I have often used indicator functions in my linear regression modelling to allow for the estimation of a coefficient only when a secondary covariate is TRUE. This is always in cases where it does not ...
HammerKop's user avatar
1 vote
0 answers
125 views

I have created a GAM using the mgcv package with the gamma family. I then plot it with tidymv so that I use ggplot2. However, it plots the transformed values for the scale. How do I plot it in the ...
ABW's user avatar
  • 11
2 votes
2 answers
1k views

I am making a perspective plot of my generalised additive model (GAM) named a1b, using vis.gam(), which in turn makes use of the persp function in R. Code is as follows: library(mgcv) vis.gam(x = a1b, ...
Jade's user avatar
  • 163
2 votes
1 answer
718 views

I am using mgcv to fit GAMs with random effects, e.g.: gam_fit <- gam(y ~ s(age) + s(region, bs='re'), data = my_data, method = 'REML') See Gavin Simpson's ...
Shira's user avatar
  • 129
2 votes
1 answer
1k views

I'm trying to fit a smooth spline to what looks like data with two peaks. First, I fit a smooth spline to my data to identify the potential position of the knots. library(npreg) library(splines) ...
user avatar
2 votes
1 answer
452 views

I'm having trouble solving an error I am getting when running bam() from mgcv. I note that a similar error was reported here 14 months ago and there seemed to be no agreed on solution - with the ...
Pat Taggart's user avatar
1 vote
0 answers
608 views

I am trying to predict the output of two GAMs using the package mgcv and the predict() function and for some reason one output has the smooth prediction I am looking for and the other does not. My ...
David Smith's user avatar
1 vote
1 answer
173 views

I'm interested in estimating a shared, global trend over time for counts monitored at several different sites using generalized additive models (gams). I've read this great introduction to ...
user13317's user avatar
  • 507
4 votes
0 answers
676 views

I am trying to make a model comparison (say, for hypothesis testing) of two GAMs (mgcv package), where both models include random effects smooth term (s(bs="re")), and the second model ...
Kamil Bartoń's user avatar
1 vote
0 answers
524 views

I have a generalised additive model calculated using the bam function from the mgcv package. I have two random effects in the model and 5 fixed effects, one of which is smoothed. The R2 are quite high ...
mikejwilliamson's user avatar
0 votes
1 answer
185 views

I use the code below to apply smooth parameter to interaction term only. mgcv::gam(Y ~ s(X1, k=3, sp=-1) + s(X2, k=4, sp=-1) + ti(X1, X2, k=4, sp=c(1,1)) + X3, method = "...
Jerison K's user avatar
3 votes
1 answer
3k views

I am new to fitting gamm models and ran into two problems with my analysis. I ran the same model using the gam and the bam function of the package mgcv. The models give me different estimates, and I ...
Luca's user avatar
  • 63
2 votes
1 answer
1k views

I have made a GAM model using "mgcv" package with the family = inverse.guassian(link = identity) and I am really happy with the fit. After plotting the smooth terms using gratia:draw(GAM, ...
ASHooper93's user avatar
1 vote
1 answer
177 views

In the mgcv package, s() term has a bs option with "tp" as a default value. As I understand, "tp" is a optimal smoother for any dimension or rank, so it is used for default. But in ...
Jerison K's user avatar
2 votes
1 answer
345 views

I have a data set that looks like this: structure(list(count = c(85970L, 57321L, 46409L, 30436L, 47316L, 2037L, 82188L, 127510L, 97109L, 15328L, 37766L, 74320L, 197130L, 73258L, 27795L, 52434L, ...
David Smith's user avatar

1 2
3
4 5
11