View source: R/compare_eps2theta_equations.R
compare_eps2theta_equations | R Documentation |
Compare various equations for converting epsilon to theta by creating a plot and showing R2-values. The function uses the equations included in eps2theta
. It also customizes some of them with fitted coefficients, plus some GLM variants using different link functions.
compare_eps2theta_equations(common_set, legend_args=NULL,eq_subset=NULL, plot_extern = TRUE)
common_set |
Data frame with observed data. See details. |
legend_args |
Arguments passed to |
eq_subset |
Vector of equations to be used. See |
plot_extern |
Enable to plot each plot in a separate window |
The dataframe common_set
holds measured values of epsilon and observed values of soil moisture (theta, e.g. obtained by thermo-gravimetric method).
Additionally, other explanatory variables (e.g. bulk density, clay content, etc.) can be contained (see details in eps2theta
).
The compare_eps2theta_equations
applies all equations supported by eps2theta
, where possible with the provided datsa. It also adjusts the coefficients of these equations to better match the data, yielding equations variants with suffix "_adj". Whenever some coefficients cannot be estimated (e.g. when the column of bulk density is all set to the same value), the value of the original equation is used.
The dataframe common_set
may hold a logical column training
. If present, the custom model fits (see above) are based on this subset only; the remaining data are also displayed and their R2-values ("testing") reported.
The dataframe common_set
may hold a logical column excluded
. If present, the custom model fits are based on all training data, but the function will also return an R2_training_ex
with R2-values calculated from training data WITHOUT the excluded records. This may be useful when additional (artificial) records had been added to force plausible behaviour at the extremes.
For plotting, the dataframe common_set
may hold columns col
and pch
. These are used in the plots as respective arguments.
A list with the elements r2_train, r2_train_ex, r2_test, rmse_train, rmse_train_ex, rmse_test, eps2theta_function
, each holding the computed R2- and RMSE-values of training data, training data without the excluded datasets and test data for each conversion function, and the functions themselves, respectively.
Additionally, the function generates three figures:
matrix of scatterplot illustrating the tested equations (theta_observed vs. theta_predicted) and the respective R2- and RMSE-values (*_train, *_train_ex, *_test);
a plot showing the behaviour of all equations over the range of epsilon-values (other data averaged). This plot can help to identify equations with implausible behaviour in extrapolation to low/high values of epsilon.
a plot of R2-values of training vs. test (trimmed to at least -0.1) for all equations
For tested equartions, check the docu of eps2theta
.
Till Francke
eps2theta
#create some fake data
set.seed(1)
observations = data.frame(epsilon = runif(n=100, min=5, max=30),
BD = runif(n=100, min=0.8, max=1.7),
clay_perc = runif(n=100, min=1, max=40),
om_perc = runif(n=100, min=0, max=30)
)
observations$theta = sqrt(observations$eps) * runif(n=100, min=0.8, max=1.2)
observations$theta = observations$theta / max(observations$theta)
observations$training = c(rep(TRUE, 50), rep(FALSE, 50)) #use the fisrt 50 for training, the rest for validation
res = compare_eps2theta_equations(common_set=observations, plot_extern=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.