Learn R Programming

stepmixr (version 0.1.2)

savefit: Save the fit of a mixture using the stepmix python package.

Description

This function saves the stepmix fitted object in python using the pickle package.

Usage

savefit(fitx, f)
loadfit(f)

Value

A pointer to a python object of type StepMix.

Arguments

fitx

An object created with the stepmix function.

f

String indicating the name of the file

Author

Éric Lacourse, Roxane de la Sablonnière, Charles-Édouard Giguère, Sacha Morin, Robin Legault, Félix Laliberté, Zsusza Bakk

Details

This methods allows to save/load the stepmix object in a binary file using the pickle package.

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

Run this code
if (FALSE) {
if (reticulate::py_module_available("stepmix")) {
  model1 <- stepmix(n_components = 2, n_steps = 3, progress_bar = 0)
  X <- data.frame(x1 = c(0,1,1,1,1,0,0,0,0,0,1,1,0),
                  x2 = c(0,1,1,0,0,1,1,0,0,0,1,0,1))
  fit1 <- fit(model1, X)
  savefit(fit1, "fit1.pickle")
  
  ### clean the directory.
  file.remove("fit1.pickle")
}
}

Run the code above in your browser using DataLab