get_mdgc | R Documentation |
Creates a mdgc object which is needed for estimation of the covariance matrix and the mean vector and to perform imputation.
get_mdgc(dat)
dat |
|
It is important to use appropriate classes for the data.frame
columns:
Continuous variables: should be numeric
s.
Binary variables: should be logical
s.
Multinomial variables: should be factor
s.
Ordinal variables: should be ordered
.
An object of class mdgc
. It has the following elements:
lower,upper,code,multinomial,idx_non_zero_mean |
arguments to pass to
|
margs |
functions to get |
reals,bins,ords |
indices of continuous, binary, and ordinal variables, respectively. |
truth |
the numeric version of |
means |
starting values for the non-zero mean terms
(see e.g. |
get_mdgc_log_ml
, mdgc_start_value
# there is a bug on CRAN's check on Solaris which I have failed to reproduce.
# See https://github.com/r-hub/solarischeck/issues/8#issuecomment-796735501.
# Thus, this example is not run on Solaris
is_solaris <- tolower(Sys.info()[["sysname"]]) == "sunos"
if(!is_solaris){
# randomly mask data
set.seed(11)
masked_data <- iris
masked_data[matrix(runif(prod(dim(iris))) < .10, NROW(iris))] <- NA
# use the functions in the package
library(mdgc)
obj <- get_mdgc(masked_data)
print(class(obj))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.