Automatically determine the best-fitting 2D-Gaussian for a data set
autofit_gaussian_2D(
data,
comparison_method = "rmse",
maxiter = 1000,
simplify = TRUE
)
A data.frame that contains the raw data (generally rectilinearly
gridded data, but this is not a strict requirement). Columns must be named
"X_values"
, "Y_values"
and "response"
.
One of "rmse", "rss", or "AIC"; what metric should be used to determine the "best-fitting" Gaussian?
Default 1000. A positive integer specifying the maximum number
of iterations allowed. See stats::nls.control()
for more details.
TRUE or FALSE. If TRUE, return only the coefficients, model,
model_error_stats, and fit_method for the best-fitting model. If FALSE, a
model comparison table is also included in the returned list as
$model_comparison
. This table is obtained via
compare_gaussian_fits()
.
If simplify = TRUE
, a list with the components:
"coefs" A data.frame of fitted model parameters.
"model" The model object, fitted by stats::nls()
.
"model_error_stats" A data.frame detailing the rss, rmse, deviance, and AIC of the fitted model.
"fit_method" A character vector that indicates which method and orientation strategy was used by this function.
If simplify = FALSE
, a model comparison table is also included
in the returned list as $model_comparison
. This table is obtained
via compare_gaussian_fits()
.
This function runs fit_gaussian_2D()
three times: once for
each of the "main" types of models: 1) elliptical, unconstrained; 2)
elliptical, log; 3) circular. In all three cases, amplitudes and
orientations are unconstrained. The function compare_gaussian_fits()
is then used to determine which of these three models is the best-fitting,
using the comparison_method
argument to make the decision.
# NOT RUN {
if (interactive()) {
}
# }
Run the code above in your browser using DataLab