Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

relabel

Relabel the Components


Description

The components are sorted by the value of one of the parameters or according to an integer vector containing the permutation of the numbers from 1 to the number of components.

Usage

relabel(object, by, ...)
## S4 method for signature 'FLXdist,character'
relabel(object, by, which = NULL, ...)

Arguments

object

An object of class "flexmix".

by

If a character vector, it needs to be one of "prior", "model", "concomitant" indicating if the parameter should be from the component-specific or the concomitant variable model. If an integer vector it indicates how the components should be sorted. If missing, the components are sorted by component size.

which

Name (or unique substring) of a parameter if by is equal to "model" or "concomitant".

...

Currently not used.

Author(s)

Friedrich Leisch and Bettina Gruen

Examples

set.seed(123)
    beta <- matrix(1:16, ncol = 4)
    beta
    df1 <- ExLinear(beta, n = 100, sd = .5)
    f1 <- flexmix(y~., data = df1, k = 4)

    ## There was label switching, parameters are not in the same order
    ## as in beta:
    round(parameters(f1))
        
    betas <- rbind(beta, .5)
    betas

    ## This makes no sense:
    summary(abs(as.vector(betas-parameters(f1))))

    ## We relabel the components by sorting the coefficients of x1:
    r1 <- relabel(f1, by = "model", which = "x1")
    round(parameters(r1))

    ## Now we can easily compare the fit with the true parameters:
    summary(abs(as.vector(betas-parameters(r1))))

flexmix

Flexible Mixture Modeling

v2.3-17
GPL (>= 2)
Authors
Bettina Gruen [aut, cre] (<https://orcid.org/0000-0001-7265-4773>), Friedrich Leisch [aut] (<https://orcid.org/0000-0001-7278-1983>), Deepayan Sarkar [ctb] (<https://orcid.org/0000-0003-4107-1553>), Frederic Mortier [ctb], Nicolas Picard [ctb] (<https://orcid.org/0000-0001-5548-9171>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.