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

Issue with rbms::flight_curve() #21

Closed
SarahVray opened this issue Sep 27, 2023 · 4 comments
Closed

Issue with rbms::flight_curve() #21

SarahVray opened this issue Sep 27, 2023 · 4 comments

Comments

@SarahVray
Copy link

SarahVray commented Sep 27, 2023

Hi @RetoSchmucki,
For some species the fitted counts computed by the function rbms::flight_curve() are not at all in line with the "real" counts.
With the code:

species.names <- unique(LUBMS_count[order(SPECIES), SPECIES])
for(i in 1:length(species.names)){ 
ts_season_count <- rbms::ts_monit_count_site(ts_season_visit, LUBMS_count, sp = species.names[i])
ts_flight_curve <- rbms::flight_curve(ts_season_count,
                                      NbrSample = 500,  
                                      MinVisit = 3,    
                                      MinOccur = 2,   
                                      MinNbrSite = 5,  
                                      MaxTrial = 4,    
                                      GamFamily = "nb", 
                                      SpeedGam = FALSE, 
                                      CompltSeason = TRUE, 
                                      SelectYear = NULL,   
                                      TimeUnit = "w",     
                                      MultiVisit = 'mean', 
                                      weekday = 3,        
                                      KeepModel = TRUE)}

Here is what I get for P. c-album:
Polygonia c album_ts_season_count.csv
As you can see, count = NA in week 16 for 2017.
Polygonia c album_pheno.csv
Here in the fitted counts, I have a sum of 6814 counts in week 16 for 2017.
And it gives me this curve:
Polygonia c album_flight curve
I don't understand how I can get this huge peak in week 16 without having any real count? Maybe I am doing something wrong... Do you know where this issue could come from?
Thank you very much in advance for your help!
Sarah

@RetoSchmucki
Copy link
Owner

RetoSchmucki commented Oct 11, 2023

Hi @SarahVray
The abnormally high peak is related to missing data on that week. You might have some data before or after, and the GAM try to fit a function that can go up and down quickly and, therefore, the steep increase and decrease. I suspect something around week 13, 14 or 15, probably higher than in weeks 26 - 28.

@SarahVray
Copy link
Author

Hi @RetoSchmucki,
Thank you for your reply. This is what I thought too but the counts are not so high around week 16 compared to weeks 25-28, only a few counts in weeks 14 and in 19-20, if we look in the pheno file for 2017:

<style> </style>
Row Labels Sum of COUNT Sum of FITTED
12 0 0
13 0 0
14 14 315.5967142
15 0 3779.034072
16 0 6814.130681
17 0 2993.912999
18 0 534.6665671
19 7 64.73782182
20 11 8.865034033
21 0 2.290161285
22 0 1.848683409
23 0 5.054775022
24 8 26.30491722
25 163 138.3477652
26 0 399.9537871
27 101 531.2740158
28 98 393.1229698
29 36 198.8809329
30 0 84.42085017
31 47 36.66912955
32 0 19.61616074
33 0 15.52873704
34 27 21.30448689
35 14 44.02468948
36 0 98.24799282
37 0 169.228053
38 0 160.7908898
39 25 60.23816853
40 0 0

I don't understand why the peak is so huge in week 16 compared to weeks 25-28.

@SarahVray
Copy link
Author

I don't know actually which GAM family would be the best for this kind of count data so I tested the Poisson distribution instead of the negative-binomial but this time it is week 37 in 2014 which acts weird (but not in the same proportion) so it is maybe not the solution:
P c-album_flight_curve

Although it does resolve the abnormally low collated index in 2017:
P c-album_collated_index

@SarahVray
Copy link
Author

Hi @RetoSchmucki, I resolved this issue by changing the weighting I applied to the counts (standardization to 1km and not 10km), now the flight curve looks OK so the GAM probably didn't like the too high numbers. Thanks!

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