fit {stepmixr} | R Documentation |
Fit a mixture using the stepmix python package.
Description
This function initializes the stepmix object in python and fit X and optionnally Y to the object.
Usage
fit(smx, X = NULL, Y = NULL, ...)
## S3 method for class 'stepmix.stepmix.StepMix'
print(x, x_names = NULL, y_names = NULL, ...)
identify_coef(coef)
Arguments
smx |
An object created with the stepmix function. |
X |
The X matrix or data.frame for the measurement part of the model |
Y |
The Y matrix or data.frame for the structural part of the model |
x |
An object fitted with the fit method |
coef |
Matrix of coefficients to be modified |
x_names |
Optional name of x variables |
y_names |
Optional name of y variables |
... |
unused but included to be inline with requirement of generic function |
Details
This methods returns a pointer to a python object of type StepMix. It can be used within reticulate but not within R. To save this type of object, you need to use the savefit function. The print method, uses the same print methods used when verbose = TRUE, it takes the last X and Y arguments used with the fit method. identify_coef find a reference configuration of the coefficients.
Value
A pointer to a python object of type StepMix.
Author(s)
Éric Lacourse, Roxane de la Sablonnière, Charles-Édouard Giguère, Sacha Morin, Robin Legault, Félix Laliberté, Zsusza Bakk
References
Bolck, A., Croon, M., and Hagenaars, J. Estimating latent structure models with categorical variables: One-step versus three-step estimators. Political analysis, 12(1): 3-27, 2004.
Vermunt, J. K. Latent class modeling with covariates: Two improved three-step approaches. Political analysis, 18 (4):450-469, 2010.
Bakk, Z., Tekle, F. B., and Vermunt, J. K. Estimating the association between latent class membership and external variables using bias-adjusted three-step approaches. Sociological Methodology, 43(1):272-311, 2013.
Bakk, Z. and Kuha, J. Two-step estimation of models between latent classes and external variables. Psychometrika, 83(4):871-892, 2018
Examples
## Not run:
if (reticulate::py_module_available("stepmix")) {
model1 <- stepmix(n_components = 3, n_steps = 2, measurement = "continuous", progress_bar = 0)
X <- iris[c(1:10, 51:60, 101:110), 1:4]
fit1 <- fit(model1, X)
}
## End(Not run)