RetoSchmucki / rbms

A home for the latest rbms R package
https://retoschmucki.github.io/rbms/
Other
4 stars 4 forks source link

single species flight curves #10

Closed cperk closed 2 years ago

cperk commented 2 years ago

Hello again,

I've been able to generate a flight curve thanks to your excellent vignette. However, I'm not sure the analysis is really suitable for my data. I have single species phenology data (flower abundances on discrete visit dates throughout the season). I simply coded all of the data as belonging to one species so that I could use your package, but now I'm struggling to understand what the relative abundance means considering there is just 1 species.

Is it still appropriate, and if so what does relative abundance really mean for my example?

Is it possible to plot flight curves for separate groups of sites (for example groups of sites belonging to different regions), where each line on the graph is a region, just as you do for different years?

cperk commented 2 years ago

Another question, is there a way to code it so that abundance rather than relative abundance is computed?

RetoSchmucki commented 2 years ago

@cperk

cperk commented 2 years ago

Thanks for your help! Concerning your second bullet point, I was already using the total flower count per site on each visit date, so for each site I just have one count per visit. So I think I am already using total number of flowers observed per visit as you suggested?

But I'm still trying to understand Multivisit; when it is set to "mean" are you saying it computes the mean count across days and sites for a given week? And if I set it to max would it just use the max count for that week at the site with the highest count, or would take the max count at each site and average the maximums across sites? I'm having a hard time understanding whether the max or mean is most appropriate.

On Fri, Nov 5, 2021 at 6:15 AM RetoSchmucki @.***> wrote:

@cperk https://github.com/cperk

  • Relative abundance is the abundance observed over the season, expressed as proportion per time step (week or day). In other words, it is the proportion of the annual total observed for a specific week or day.
  • Because you code all species as one entity, you will have multiple counts per visit for the same entity (species). In the function flight_curve() the parameter MultiVisit is set to "mean", calculating the mean per time step. The mean implied that the relative abundance is the proportion of the "mean" number of flowers observed in a week or day. You can change this parameter to "max" which does not make much sense in your case as this would only refer to the most abundant species per visit. You might be interested in using the total number of flowers observed per visit, but for this, you will need to compute it before using the flight_curve() function. This function is designed to deal with single species and sampling efforts when site visits have been repeated in a specific time period.
  • Because flight curves are computed for a group of sites, you will need to run the function on different subsets (regions) and plot the flight curves independently, but on the same graph by adding a line for each subset. This is how years are computed, we split the data into distinct years and the flight curves are then calculated year by year.
  • impute_count will give you the expected total "abundance" over a season(year) (SINDEX) and the expected weekly or daily abundance (IMPUTED_COUNT). This is the closest you get from abundance and are expressed in the same unit (e.g. count of individual).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RetoSchmucki/rbms/issues/10#issuecomment-961774191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCT4K3HJHTBWRIMJLBKE6LUKOVE5ANCNFSM5HMF52MQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

RetoSchmucki commented 2 years ago

If you compute the flight curve on a weekly basis, the function will use the mean or the max count recorded in that week, but for each site. This result in each site only having one count per TimeUnit.

The rationale for this is that if someone monitors a transect twice a week and another once a week, you need to account for the difference in the monitoring effort. Here, the mean per week and site is most sensible and I would recommend the same for your case. The result will be the expected number of flowers observed in one visit per week or day (depending on how you set TimeUnit='d' or 'w' in your compute). When choosing the max, you might end with biased estimates due to increased detectability in sites or weeks with more visits.

cperk commented 2 years ago

So let's say at site A the count for a given week is 10 flowers. The mean and max would both result in 10 for that week since there is only one value for that site in that week?

On Fri, Nov 5, 2021 at 1:58 PM RetoSchmucki @.***> wrote:

If you compute the flight curve on a weekly basis, the function will use the mean or the max count recorded in that week, but for each site. This result in each site only having one count per TimeUnit.

The rationale for this is that if someone monitors a transect twice a week and another once a week, you need to account for the difference in the monitoring effort. Here, the mean per week and site is most sensible and I would recommend the same for your case. The result will be the expected number of flowers observed in one visit per week or day (depending on how you set TimeUnit='d' or 'w' in your compute). When choosing the max, you might end with biased estimates due to increased detectability in sites or weeks with more visits.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RetoSchmucki/rbms/issues/10#issuecomment-962101418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCT4K5R4E2GDZKTGUXGQWDUKQLLBANCNFSM5HMF52MQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

RetoSchmucki commented 2 years ago

yes

cperk commented 2 years ago

Ok thanks! I understand now. One thing I'm running into is that my sites where no flowering occurred are getting excluded, which leads to lack of convergence if there aren't enough sites within a certain region that produced any flowers. My species is prone to low flowering (the whole reason we did the study). Is there any chance you will reduce the minimum allowed value in MinOccur to 0?

cperk commented 2 years ago

Actually, I re-read the MinOccur info and it looks like 0 is already allowed; so why am I getting the message that not enough of my sites have occurrences for the model to converge?

cperk commented 2 years ago

one other issue: there seems to be a bug in the impute command; I get this error despite it all being one species:

Error in impute_count(ts_season_count_unpoll_CB, ts_flight_curve_unpoll_CB, : Species in count data must be in the flight curve data!

RetoSchmucki commented 2 years ago

my sites where no flowering occurred are getting excluded, which leads to a lack of convergence if there aren't enough sites within a specific region that produced any flowers.

You must ask yourself if it makes sense to fit a statistical model estimating the change over time when there is no event. The rbms package does not produce pheno curve when the data contain no event. Thus, if you have no resulting flight curve, the pheno of the ts_flight_curve object is likely to be empty.

Without example or data, it's difficult for me to confirm if it's a bug in rbms or an issue related to your usage.

cperk commented 2 years ago

Thanks! Here is a reprod of the problem using your tutorial data

require(rbms)
data(m_visit)
data(m_count)
ts_date <- rbms::ts_dwmy_table(InitYear = 2000, LastYear = 2003, WeekDay1 = 'monday')
ts_season <- rbms::ts_monit_season(ts_date, StartMonth = 4, EndMonth = 9, StartDay = 1, EndDay = NULL, CompltSeason = TRUE, Anchor = TRUE, AnchorLength = 2, AnchorLag = 2, TimeUnit = 'w')
ts_season_visit <- rbms::ts_monit_site(m_visit, ts_season)
ts_season_count <- rbms::ts_monit_count_site(ts_season_visit, m_count, sp = 2)
ts_flight_curve <- rbms::flight_curve(ts_season_count, NbrSample = 300, MinVisit = 5, MinOccur = 3, MinNbrSite = 5, MaxTrial = 4, GamFamily = 'nb', SpeedGam = FALSE, CompltSeason = TRUE, SelectYear = NULL, TimeUnit = 'w')

rbms::impute_count(ts_season_count, ts_flight_curve)

Screen Shot 2021-11-15 at 9 12 51 PM

RetoSchmucki commented 2 years ago

In your script is missing one line extracting the phenology from the ts_flight_curve object see vignette 2, point 4. Thank you for reporting; I will add an internal step to catch this potential issue, and clarify the slightly misleading documentation.

require(rbms)
data(m_visit)
data(m_count)
ts_date <- rbms::ts_dwmy_table(InitYear = 2000, LastYear = 2003, WeekDay1 = 'monday')
ts_season <- rbms::ts_monit_season(ts_date, StartMonth = 4, EndMonth = 9, StartDay = 1, EndDay = NULL, CompltSeason = TRUE, Anchor = TRUE, AnchorLength = 2, AnchorLag = 2, TimeUnit = 'w')
ts_season_visit <- rbms::ts_monit_site(m_visit, ts_season)
ts_season_count <- rbms::ts_monit_count_site(ts_season_visit, m_count, sp = 2)
ts_flight_curve <- rbms::flight_curve(ts_season_count, NbrSample = 300, MinVisit = 5, MinOccur = 3, MinNbrSite = 5, MaxTrial = 4, GamFamily = 'nb', SpeedGam = FALSE, CompltSeason = TRUE, SelectYear = NULL, TimeUnit = 'w')

## extract phenology data from the ts_fligh_curve list
pheno <- ts_flight_curve$pheno

impt_counts <- rbms::impute_count(ts_season_count=ts_season_count, ts_flight_curve=pheno, YearLimit= NULL, TimeUnit='w')