compare_mids: Compare Two 'mids' Objects and Show Summary

View source: R/compare_mids.R

compare_midsR Documentation

Compare Two mids Objects and Show Summary

Description

compare_mids() is a combination of all.equal() and identical() for mids objects. Like all.equal(), it displays a summary of element-wise differences (it also explicitly lists elements that are equal). However, rather than outputting these differences as a character vector if found, it always returns either TRUE or FALSE. If quiet = FALSE, the return value is invisible.

Usage

compare_mids(
  x,
  y,
  show_msg = TRUE,
  show_rtn = !show_msg,
  ignore_rng = NULL,
  ignore_call = TRUE,
  ignore_version = TRUE,
  ignore_date = TRUE
)

Arguments

x, y

mids objects to compare, as created by mice::mice(), future_mice(), mice::mice.mids(), future_mids(), etc.

show_msg

Should the message displaying element-wise comparisons be shown?

show_rtn

Should the return value be visible? The default is the opposite of show_msg, so that either the message or return value is shown, but not both.

ignore_rng

Should elements or components of elements affected by the RNG state be ignored? See Details for more information. The default is to ignore when different package namespaces are detected in the mids$call, otherwise to check.

ignore_call, ignore_version, ignore_date

Should the corresponding mids element (mids$call, mids$version, mids$date, respectively) be ignored in equality comparison? These elements do not usually impact results if all other elements are identical and can thus usually be safely ignored.

Details

Proper random number generation requires different methods when performing operations in parallel; thus, is it generally not possible to exactly replicate mids objects produced sequentially when imputing chains in parallel. In particular, the imputed values will differ, as well as any functions of those values (chainMean, chainVar, loggedEvents). This function takes the stance that imputations performed by functions in the same package should be consistent, but functions from different packages may handle random number generation differently. Thus, if compare_mids() can detect that two functions came from the same package, it will compare the full RNG-related elements by default. Otherwise, it will check that attributes independent of random number generation are the same, but it will allow differences between attributes and data dependent on the RNG state. If RNG-related attributes are ignored, the RNG state itself is also ignored, so differences in seed and lastSeedValue are also allowed in this case.

Value

TRUE or FALSE

Examples

m_mids <- mice::mice(mice::nhanes, m = 1L, maxit = 1L)
f_mids <- future_mice(mice::nhanes, m = 1L, maxit = 1L)
compare_mids(m_mids, f_mids)


jesse-smith/futuremice documentation built on Nov. 24, 2023, 7:19 a.m.