--- title: "Romeb Package: An Introduction" author: - Dandan Tang - Xin Tong date: "`r Sys.Date()`" output: rmarkdown::html_vignette: toc: true toc_depth: 2 vignette: > %\VignetteIndexEntry{Romeb Package: An Introduction} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set(message = FALSE, warning = FALSE) library(Romeb) ``` ## Introduction `Romeb` implements *robust median‑based Bayesian* growth curve modeling that accommodate the three classical missing‑data mechanisms—MCAR, MAR and MNAR-and complete data, particularly beneficial when data are nonnormally distributed or include outliers. A detailed tutorial can be found in Tang & Tong (2025). ## Function usage The main interface is ```r Romeb( Missing_Type, # "MNAR", "MAR", "MCAR", or "no missing" data, # matrix / data frame time, # Numeric vector of measurement times (e.g., c(0,1,2,3)). seed, # reproducibility seed K = 0, # number of auxiliary variables chain = 1, # number of MCMC chains Niter = 6000, # iterations per chain burnIn = 3000 # burn‑in iterations ) ``` ### Arguments | Argument | Description | |----------|-------------| | `Missing_Type` | Character string specifying the assumed missing‑data mechanism. One of `"MNAR"`, `"MAR"`, `"MCAR"`, `"no missing"`. | | `data` | Matrix or data frame. If `K = 0`, **all** columns are treated as outcomes *y*; otherwise the first *K* columns are auxiliary variables and the next `Time` columns are outcomes. | | `time` | Numeric vector of measurement times (e.g., c(0,1,2,3)). | | `seed` | Integer seed ensuring reproducibility. | | `K` | Non‑negative integer (default 0) giving the number of auxiliary variables. | | `chain` | Number of parallel MCMC chains (default 1). | | `Niter` | Total iterations **per chain** (default 6000). | | `burnIn` | Iterations discarded as burn‑in (default 3000). | ## Output object Running ```r Res <- Romeb(...) print(Res) # or simply type Res ``` returns a compact table with the posterior median, Geweke *z*‑scores, the 95% equal‑tail credible interval, and the 95% highest‑posterior‑density (HPD) interval for each monitored parameter. Further elements can be accessed directly: | Element | Content | |---------|---------| | `Res$quantiles` | Posterior mean, SD, naïve and time‑series SEs, plus selected quantiles for every parameter *after* burn‑in. | | `Res$geweke` | Vector of Geweke diagnostic *z*‑scores; values within ±1.96 indicate no evidence against lack of convergence. | | `Res$credible_intervals` | 95% equal‑tail credible intervals (2.5% & 97.5% quantiles). | | `Res$hpd_intervals` | 95% HPD intervals (shortest 95% region). | | `Res$samps_full` | Complete `coda::mcmc.list` (including burn‑in). Inspect with `coda::traceplot(Res$samps_full[,'par[i]'])` for par[i] . | ## Quick examples Below we illustrate a workflow. ```{r example-complete, eval = TRUE} set.seed(123) Y <- matrix(rnorm(300*5), nrow = 300, ncol = 5) # tiny complete data set result_full <- Romeb("no missing", data = Y, time = c(0, 1, 2, 3, 4), seed = 123) print(result_full) ``` Note: par [1]: latent intercept, par [2]: latent slope: par [3]: variance of the latent intercept, par [4]: covariance between intercept and slope, par [5]: variance of the latent slope. ### MCAR example ```{r example-mcar, eval = FALSE} set.seed(456) Y <- matrix(rnorm(300 * 5), nrow = 300) miss <- runif(length(Y)) < 0.1 # 10% missing completely at random Y[miss] <- NA result_mcar <- Romeb("MCAR", data = Y, time = c(0, 1, 2, 3, 4), seed = 456) ``` ### MNAR with auxiliary variables ```{r example-mnar-aux, eval = FALSE} set.seed(789) X <- matrix(rnorm(300 * 2), 300, 2) # two auxiliaries Y <- matrix(rnorm(300 * 5), 300, 5) Data <- cbind(X, Y) result_mnar <- Romeb("MNAR", data = Data, time = c(0, 1, 2, 3, 4), K = 2, seed = 789) ``` ## Inspecting convergence visually ```{r traceplot, fig.cap = "Trace plot for the first chain (par[1])", eval = TRUE} # Uses the tiny example result_full from above coda::traceplot(result_full$samps_full[,'par[1]']) ``` ## How to cite Please cite the package as: > Tang,D.and Tong,X.(2025). *Romeb: An R Package for Robust Median-Based > Bayesian Growth Curve Modeling with Missing Data.* Bibliographic metadata can also be obtained via `citation("Romeb")`.