ToonVanDaele / trias-test

test repository ofr trias
0 stars 0 forks source link

Use of argument newdata in derivatives() #5

Closed damianooldoni closed 4 years ago

damianooldoni commented 4 years ago

In basic GAM functions, I don't see argument newdata in derivatives():

  1. GAM for occurrences: https://github.com/ToonVanDaele/trias-test/blob/master/R/5c_method_GAM_short.R#L49-L52
  2. GAM for occupancy: https://github.com/ToonVanDaele/trias-test/blob/master/R/5c_method_GAM_short.R#L129-L132

Such argument is present in GAM functions where observations/occupancy of native species is used as covariate:

  1. GAM for occurrences: https://github.com/ToonVanDaele/trias-test/blob/master/R/5e_method_GAM_count.R#L158-L164
  2. GAM for occupancy: https://github.com/ToonVanDaele/trias-test/blob/master/R/5d_method_GAM_pa.R#L155-L161

I notice that without newdata I don't get derivatives values for last year (2017), but two values in the middle (2013). After evaluating emergency status based on 1st and 2nd derivatives, doing bind_cols, we attach the emergency status back to original data, so that the 2nd em value of 2013 is given to 2014, the em value of 2014 is assigned to 2015 etc. Using newdata this doesn't happen, but I wonder if this just "covers" an underlying issue, i.e. missing values at the end of the time series. I need your help to understand this. Thanks.

damianooldoni commented 4 years ago

Tested with taxon keys: 1031400. But even with other taxa I get similar problems.

damianooldoni commented 4 years ago

I think this issue is quite outdated. Feel free to close it, if you think the same about it.

ToonVanDaele commented 4 years ago

Indeed. The problem is fixed now. Added round(x, 0) to avoid decimals in the year