Compare ECDF and Chi-square suitability under non-normal data
ecdf_nonnormal_niche.RdScript to run a simulation study to compare Chi-square vs. ECDF approaches to quantify habitat suitability based on bivariate non-normal data. Bivariate data was simulated based on environmental variables (temperature and precipitation) using Gaussian copulas. Temperature followed a normal distribution while precipitation followed a Weibull distribution. The choices of the distributions were based on Haddad (2021) - Theoretical and Applied Climatology (for temperature) and on the estimation of rainfall in milimeters by Wilks (1989) - Journal of Applied Meteorology. Because the relationship between temperature and precipitation is complex across space (Rodrigo, 2022 - Theoretical and Applied Climatology), we defined five correlation values between the two variables.
temp_parameters and prec_parameters must comply to stats::qnorm or
stats::qweibull, depending on the function chosen on temp_function and
prec_function. For "qnorm", user can specify mean and sd, while
for "qweibull"
Arguments
- rho_vals
Numeric vector; correlations between variables.
- n_vals
Integer vector; sample sizes.
- n_reps
Integer; number of replicates.
- N_ref
Integer; size of reference population for "true" parameters.
- temp_function
Character; function used to model temperature values. One of: "qnorm" or "qweibull".
- temp_parameters
List; list organizing parameters to pass to
temp_function.- prec_function
Character; function used to model precipitation values. One of: "qnorm" or "qweibull".
- prec_parameters
List; list organizing parameters to pass to
temp_function.- seed
Optional integer for reproducibility.
Value
A list with:
suit_plot: ggplot of suitability vs Mahalanobis distance
cor_df: correlation results
obs_df: observation-level data