Gaussian mixture model
Gaussian mixture model
An R6 object of class gaussianMixture.
R6 class for fitting and storing a univariate Gaussian mixture model.
Applied after updating the parameters
Version 1.0.2
controlList to contain custom control parameters.
maxitInteger, maximum number of iterations.
maxrestartsInteger, maximum number of restarts.
abstolNumeric, absolute level for convergence.
componentsInteger, number of mixture components.
methodCharacter, package used for fitting.
meansNumeric vector containing the location parameter for each component.
sdNumeric vector containing the scale parameter for each component.
pNumeric vector containing the probability for each component.
coefficientsnamed list with mixture coefficients.
std.errorsnamed list with mixture parameters.
modelTibble with mixture parameters, in order means, sd, p.
logliklog-likelihood of the fitted series.
fittedfitted series
responsabilitiesresp
momentsTibble with the theoric moments and the number of observations used for fit.
tidyTibble with estimated parameters, std.errors and statistics
new()Initialize a gaussianMixture object.
gaussianMixture$new(
components = 2,
method = "mixtools",
maxit = 5000,
maxrestarts = 500,
abstol = 1e-08
)components(integer(1)), number of components.
methodCharacter, package used to fit the parameters. Can be mclust or mixtools.
maxit(integer(1)) Numeric, maximum number of iterations.
maxrestarts(integer(1)) Numeric, maximum number of restarts.
abstol(numeric(1)) Numeric, absolute level for convergence.
logLik()Compute the log-likelihood.
fit()Fit the parameters with mclust package
xvector
weightsobservations weights, if a weight is equal to zero the observation is excluded, otherwise is included with unitary weight.
mu_targetNumeric, target mean of the mixture to match.
var_targetNumeric, target variance of the mixture to match.
When missing all the available observations will be used.
update()Update the parameters inside the object.
filter()Update the responsibilities, the log-likelihood, classify again the points and recompute empiric parameters.
print()Print method for gaussianMixture class.
gm <- gaussianMixture$new(components = 2)
gm$update(
means = c(mu1 = -1, mu2 = 1),
sd = c(sd1 = 0.5, sd2 = 1),
p = c(p1 = 0.4, p2 = 0.6)
)
gm$coefficients
#> $means
#> mu1 mu2
#> -1 1
#>
#> $sd
#> sd1 sd2
#> 0.5 1.0
#>
#> $p
#> p1 p2
#> 0.4 0.6
#>
gm$moments
#> # A tibble: 1 × 12
#> m1 m2 m3 m4 mu2 mu3 mu4 mean variance skewness kurtosis
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.2 1.7 1.7 7.08 1.66 0.696 6.12 0.2 1.66 0.325 -0.780
#> # ℹ 1 more variable: nobs <int>