class statsmodels.imputation.mice.MICEData(data, perturbation_method=
Wrap a data set to allow missing data handling with MICE.
The data set, which is copied internally.
The default perturbation method
The number of nearest neighbors to use during predictive mean matching. Can also be specified in fit.
A function that is called after each complete imputation cycle. The return value is appended to history. The MICEData object is passed as the sole argument to history_callback.
Allowed perturbation methods are ‘gaussian’ (the model parameters are set to a draw from the Gaussian approximation to the posterior distribution), and ‘boot’ (the model parameters are set to the estimated values obtained when fitting a bootstrapped version of the data set).
history_callback can be implemented to have side effects such as saving the current imputed data set to disk.
Draw 20 imputations from a data set called data and save them in separate files with filename pattern dataXX.csv. The variables other than x1 are imputed using linear models fit with OLS, with mean structures containing main effects of all other variables in data. The variable named x1 has a conditional mean structure that includes an additional term for x2^2.
>>> imp = mice.MICEData(data) >>> imp.set_imputer('x1', formula='x2 + np.square(x2) + x3') >>> for j in range(20): ... imp.update_all() ... imp.data.to_csv('data%02d.csv' % j)
Return the data needed to fit a model for imputation.
Return endog and exog for imputation of a given variable.
Use predictive mean matching to impute missing values.
Returns the next imputed dataset in the imputation process.
plot_bivariate(col1_name, col2_name[, ...])
Plot observed and imputed values for two variables.
plot_fit_obs(col_name[, lowess_args, ...])
Plot fitted versus imputed or observed values as a scatterplot.
plot_imputed_hist(col_name[, ax, ...])
Display imputed values for one variable as a histogram.
plot_missing_pattern([ax, row_order, ...])
Generate an image showing the missing data pattern.
set_imputer(endog_name[, formula, ...])
Specify the imputation process for a single variable.
Impute missing values for a single variable.
Perform a specified number of MICE iterations.