# autofit_gaussian_2D: Automatically determine the best-fitting 2D Gaussian for a... In gaussplotR: Fit, Predict and Plot 2D Gaussians

## Description

Automatically determine the best-fitting 2D Gaussian for a data set

## Usage

 ```1 2 3 4 5 6``` ```autofit_gaussian_2D( data, comparison_method = "rmse", maxiter = 1000, simplify = TRUE ) ```

## Arguments

 `data` 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"`. `comparison_method` One of "rmse", "rss", or "AIC"; what metric should be used to determine the "best-fitting" Gaussian? `maxiter` Default 1000. A positive integer specifying the maximum number of iterations allowed. See `stats::nls.control()` for more details. `simplify` 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()`.

## Details

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.

## Value

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()`.

Vikram B. Baliga

## Examples

 ```1 2``` ```if (interactive()) { } ```

gaussplotR documentation built on Jan. 13, 2021, 3:55 p.m.