mdgc_start_value {mdgc}R Documentation

Get Starting Value for the Covariance Matrix Using a Heuristic

Description

Uses a heuristic to get starting values for the covariance matrix. These can be passed e.g. to mdgc_fit.

Usage

mdgc_start_value(object, ...)

## S3 method for class 'mdgc'
mdgc_start_value(object, ...)

## Default S3 method:
mdgc_start_value(
  object,
  lower,
  upper,
  code,
  multinomial,
  idx_non_zero_mean,
  mea,
  n_threads = 1L,
  ...
)

Arguments

object

mdgc object from get_mdgc. Ignored by the default method.

...

used to pass arguments to S3 methods.

lower

[# variables]x[# observations] matrix with lower bounds for each variable on the normal scale.

upper

[# variables]x[# observations] matrix with upper bounds for each variable on the normal scale.

code

[# variables]x[# observations] matrix integer code for the each variable on the normal scale. Zero implies an observed value (the value in upper), one implies a missing value, and two implies an interval.

multinomial

list where each element is 3x[# multinomial variables] matrix with multinomial outcomes. The first index is the outcome as an integer code, the second index is the number of categories, and the third index is the index of each multinomial variable (this is zero-based).

idx_non_zero_mean

indices for non-zero mean variables. Indices should be sorted.

mea

vector with non-zero mean entries.

n_threads

number of threads to use.

Value

The starting value for the covariance matrix.

Examples

# 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)
  ptr <- get_mdgc_log_ml(obj)
  start_vals <- mdgc_start_value(obj)
  print(start_vals) # starting value for the covariance matrix
}


[Package mdgc version 0.1.7 Index]