ToonVanDaele / trias-test

test repository ofr trias
0 stars 0 forks source link

backtransform first derivative values to real scale #9

Closed damianooldoni closed 4 years ago

damianooldoni commented 4 years ago

We need to backtransform the lowest confidence interval value of 1st derivative to real scale. This transformation doesn't affect ranking, but it is way better for communicating the real growth in observations/number of occupied cells.

Could you please let me know which formula should we use for the conversion? Thanks.

ToonVanDaele commented 4 years ago

For the count data (obs & ncell) it's in the log scale. For the presence/absence data it's a logit transformation. I'll add backtransformation in the spGAMxxx functions.

damianooldoni commented 4 years ago

Great, @ToonVanDaele! :+1: Thanks

ToonVanDaele commented 4 years ago

I use the model$family$linkinv function. It's used in the function 'get_lcl' and 'predict_real_scale' (added today).

damianooldoni commented 4 years ago

Thanks @ToonVanDaele! Nice. I reopen this issue just to inform you of a possible bug while using function predict_real_scale: https://github.com/ToonVanDaele/trias-test/blob/master/R/5c_method_GAM_short.R#L53

You pass df to argument df_n. You should pass df_n. In general, please be careful while using existing variable names as function arguments! It is quite dangerous and prone to errors, as R search in upper environments to search for such variables if not found.

I would rename argument df_n:

predict_real_scale <- function(df_to_convert, model) {
    ...
}