Learn R Programming

ggpmisc (version 1.0.0)

distrmix_helper_fun: Helper function for fitting Normal mixture model

Description

Factored out code used in both stat_distrmix_line() and stat_distrmix_eq().

Usage

distrmix_helper_fun(
  data,
  aes.name = "x",
  method,
  method.name,
  se,
  method.args = list(),
  k = 2,
  free.mean = TRUE,
  free.sd = TRUE,
  n.min = 10L * k,
  fit.seed = NA,
  fm.values = TRUE,
  verbose = getOption("verbose", default = FALSE)
)

Arguments

data

A layer specific dataset, only needed if you want to override the plot defaults.

method

function or character If character, "normalmixEM" or the name of a model fit function are accepted, possibly followed by the fit function's method argument separated by a colon. The function must return a model fit object of class "mixEM".

se

logical If TRUE standard errors for the parameter estimates are returned in addition to the parameter estimates.

method.args

named list with additional arguments. Not data or weights which are always passed through aesthetic mappings.

k

integer Number of mixture components to fit.

free.mean, free.sd

logical If TRUE, allow the fitted mean and/or fitted sd to vary among the component Normal distributions.

n.min

integer Minimum number of distinct values in the variable for fitting to the attempted. The default depends on k.

fit.seed

RNG seed argument passed to set.seed(). Defaults to NA, indicating that set.seed() should not be called.

fm.values

logical Add parameter estimates and their standard errors to the returned values (`FALSE` by default.)

verbose

If FALSE, capture screen output from method and display it as a message() only in case of conversion failure.

Details

This function does the model fitting and returns a data frame with the estimates for the parameters. It is a wrapper on functions from package 'mixtools'.

See Also

Other model-fitting helper functions: quant_helper_fun()