Technical Appendix: Workflow of `do_mc()`

library(DiagrammeR)

Goal

This technical appendix describes how do_mc() from the package manymome (Cheung & Cheung, 2023) works to generate Monte Carlo estimates to be used by other functions to form confidence intervals.

do_mc()

mermaid("
flowchart TD
  classDef default fill:#EEEEFF;
  classDef errornode fill:#FFDDDD;
  classDef startend fill:#DDFFDD;
  classDef mcnode fill:#FFFFDD;
  classDef bootnode fill:#DDFFFF;
  classDef lavnode fill:#FFDDFF;
  classDef lmnode fill:#FFDDDD;
  classDef subnode fill:#FFFFDD;

  ZZ([\"Start\"])
  ZZ:::startend --> Z

  Z{{\"How was the model fitted?\"}}
%%  Zla[\"Fitted by lavaan()\"]
%%  Zlm[\"Fitted by lm()\"]
%%  Z -- lm --> Zlm
%%  Z -- lavaan --> Zla
  Z -- lavaan --> A
  Z -- lm --> B:::errornode

  subgraph lm [ ]
  B([\"Raise an error. lm() not supported.\"])
  end

  subgraph lavaan [ ]
  A[\"Call gen_mc_est() to generate Monte Carlo estimates\"]
  A2[[\"Call fit2mc_out() to generate the implied statistics\"]]
  end

  A --> A2:::subnode
  C([\"Return a mc_out-class object\"])
  A2 --> C:::startend
", height = 480, width = 800)

fit2mc_out()

It retrieves stored Monte Carlo estimates

mermaid("
flowchart TD
  classDef default fill:#EEEEFF;
  classDef errornode fill:#FFDDDD;
  classDef startend fill:#DDFFDD;
  classDef mcnode fill:#FFFFDD;
  classDef bootnode fill:#DDFFFF;
  classDef lavnode fill:#FFDDFF;
  classDef lmnode fill:#FFDDDD;
  classDef subnode fill:#FFFFDD;

  ZZ([\"Start\"])
  ZZ:::startend --> A

  A[\"mc_est <- mc2est()\"]
  B[\"mc_implied <- mc2implied()\"]
  B2[\"Combine mc_est and mc_implied\"]
  C([\"Return a mc_out-class object\"])
  A --> B
  B --> B2
  B2 --> C:::startend
", height = 380)

Notes

Extracting Point Estimates and Variance-Covariance Matrix

When the point estimates or variance-covariance matrix of the point estimates are needed, they will be extracted internally using functions developed for the fit object, which can be a lavaan-class object, a list of the outputs from stats::lm(), or a lavaan.mi-class object generated by fitting a model to several datasets using multiple imputation.



Try the manymome package in your browser

Any scripts or data that you put into this service are public.

manymome documentation built on Oct. 4, 2024, 5:10 p.m.