Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smooth_estimates() returns random smooths for levels on in the by smooth #311

Open
StefanoMezzini opened this issue Aug 26, 2024 · 1 comment

Comments

@StefanoMezzini
Copy link

Hi Gavin,

I have a dataset with control and treatment animals (C_* and T_*, respectively). Plotting the partial effect of s(doy, animal_year, by = group, bs = 'fs') returns the random smooths for all levels for both groups rather than only the levels within each group. This results in unnecessary, flat smooth estimates with the sample-level CIs. (alpha is 0.1 for all geom_ribbons.)

> unique(filter(partials, term == 's(doy,animal_year):groupControl')$animal_year)
 [1] C_100 2023 C_100 2024 C_102 2023 C_102 2024 C_106 2023 C_107 2023 C_108 2023
 [8] C_161 2023 C_161 2024 C_200 2024 T_151 2023 T_151 2024 T_152 2023 T_153 2023
[15] T_153 2024 T_155 2023 T_155 2024 T_158 2023 T_158 2024 T_159 2023 T_160 2023
[22] T_163 2023 T_163 2024 T_166 2023 T_166 2024 T_169 2023
26 Levels: C_100 2023 C_100 2024 C_102 2023 C_102 2024 C_106 2023 ... T_169 2023

image

Cheers,
Stefano

@gavinsimpson
Copy link
Owner

Thanks @StefanoMezzini; I'll take a look at what's going wrong here, most likely is the special internal method use for fs smooths isn't doing the required subsetting of the levels for the by smooth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants