I have a GAM model built as:
res11 <- gam( BD ~ s(DEPTH_M, interaction(LC_L1_factor, TEXT_FAO), bs = "fs") + s(SOURCE, bs="re"), data = df_filtered, family = tw(link = "log"), method = "REML" ) When trying to compare the check significant differences between smooth functions with depth for each LC_L1 x TEXT_FAO combination using emmeans:
depth_seq <- seq(0, max(df_filtered$DEPTH_M), length.out = 400) expand_args <- list( DEPTH_M = depth_seq, LC_L1_factor = levels(df_filtered$LC_L1_factor) ) expand_args[[texture_col]] <- levels(df_filtered[[texture_col]]) newdata <- do.call(expand.grid, expand_args) newdata$SOURCE <- df_filtered$SOURCE[1] newdata_filtered <- newdata %>% left_join(max_depths, by = c("LC_L1_factor", texture_col)) %>% filter(DEPTH_M <= max_depth + 1) %>% select(-max_depth) em <- emmeans(model, ~ DEPTH_M | interaction(LC_L1_factor, TEXT_FAO), data = newdata_filtered) I got the following error:
Error in `[.data.frame`(tbl, , vars, drop = FALSE) : undefined columns selected Does the error come from the way I'm calling emmeans? Is emmeans compatible with this type of interaction in a GAM model, specifically when using bs = "fs" for factor-smooth interactions? And if not, is there an alternative approach to test for significant differences between smooth functions along the depth gradient? Thanks for your help