courtiol / IsoriX

This is the GitHub repository dedicated to the development of the R package IsoriX
13 stars 6 forks source link

Revise isofit() & isomultifit() for more flexibility in predictors #154

Open courtiol opened 2 years ago

courtiol commented 2 years ago

Goal

The function isofit() need to become more flexible so as to allow for the construction of isoscapes with more predictors and isoscapes with no predictor (beyond spatial autocorrelation).

Current function

So far the function has been defined as follows:

isofit <- function(
                   data,
                   mean_model_fix = list(elev = FALSE, lat_abs = FALSE, lat_2 = FALSE, long = FALSE, long_2 = FALSE),
                   disp_model_fix = list(elev = FALSE, lat_abs = FALSE, lat_2 = FALSE, long = FALSE, long_2 = FALSE),
                   mean_model_rand = list(uncorr = TRUE, spatial = TRUE),
                   disp_model_rand = list(uncorr = TRUE, spatial = TRUE),
                   uncorr_terms = list(mean_model = "lambda", disp_model = "lambda"), ## or: "nugget"
                   spaMM_method = list(mean_model = "fitme", disp_model = "fitme"), ## or: "corrHLfit", "HLfit"
                   dist_method = "Earth", ## or: "Euclidean"
                   control_mean = list(),
                   control_disp = list(),
                   verbose = interactive()
                   ) 

Arguments

I think that mean_model_fix and disp_model_fix are unfortunately too constrained and will have to go. Instead, I propose to define:

mean_formula_fix = ~ 1
disp_formula_fix = ~ 1

These arguments should understand RHS formula of the type ~ . as the instruction to use all columns from the data as predictor (except the response variable).

All the other arguments should remain the same.

Required changes in other functions

To make this possible, other functions need to be updated to. The biggest rework will be to update prepraster() as described in issue #152.

Smaller changes need to happen to isoscape() & isomultiscape(): these functions should check that the structural raster brick contains all the required layers by matching the predictors of the isofit to the names of the layers.

Similarly, calibfit() will require that all required predictors are present in the calibration dataset so that the isotopic source value can be predicted. (Note that it will be difficult for users to fill in these columns if they don't have these data, and they may have to import them from a raster, this will be the object of another issue. We probably need a function prepcalib()).

courtiol commented 10 months ago

If you do think this issue matters to you, please add a thumb up!