### futuremice Usage Example Source: https://github.com/amices/mice/blob/master/docs/reference/futuremice.html Demonstrates the basic usage of the futuremice function. Ensure the 'mice' and 'furrr' packages are installed and loaded. ```R library(mice) library(furrr) # Example data with missing values data <- nhanes2 # Run futuremice with default settings # Set a seed for reproducibility set.seed(123) # Run futuremice # Use a specific number of cores (e.g., 4) # futuremice(data, m = 10, n.core = 4) # Use default number of cores # futuremice(data, m = 10) # Example with specific packages and globals # futuremice(data, m = 5, packages = "mice", globals = "my_impute_function") # Example with a different future plan # futuremice(data, m = 5, future.plan = "sequential") # Example with logical CPUs # futuremice(data, m = 5, use.logical = TRUE) # Example with physical CPUs # futuremice(data, m = 5, use.logical = FALSE) # Example with a specific seed for the mice algorithm # futuremice(data, m = 5, seed = 42) # Example with a seed for parallel execution # futuremice(data, m = 5, parallelseed = 12345) # Example passing additional arguments to mice # futuremice(data, m = 5, maxit = 10, printFlag = FALSE) ``` -------------------------------- ### Mi4p Devel Installation: Binary vs Source Packages Source: https://github.com/amices/mice/blob/master/revdep/failures.md This output shows that binary versions of some packages are available, but their source versions are newer and require compilation. The system will proceed with installing the binary versions. ```bash There are binary versions available but the source versions are later: binary source needs_compilation MsCoreUtils 1.21.0 1.22.1 TRUE S4Arrays 1.10.0 1.10.1 TRUE SparseArray 1.10.2 1.10.6 TRUE Binaries will be installed The downloaded binary packages are in /var/folders/5_/g85d42yj50b6lrjq4rzjzg8w0000gn/T//Rtmp8AWm9i/downloaded_packages trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/affy_1.88.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/affyio_1.80.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/AnnotationDbi_1.72.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/AnnotationFilter_1.34.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/BiocBaseUtils_1.12.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/BiocFileCache_3.0.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/biomaRt_2.66.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/Biostrings_2.78.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/DAPAR_1.42.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/impute_1.84.0.tgz' ... trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/QFeatures_1.20.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/Spectra_1.20.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/vsn_3.78.0.tgz' installing the source package ‘DAPARdata’ trying URL 'https://bioconductor.org/packages/3.22/data/experiment/src/contrib/DAPARdata_1.40.0.tar.gz' Content type 'application/x-gzip' length 30447560 bytes (29.0 MB) ================================================== downloaded 29.0 MB ``` -------------------------------- ### Install Latest Mice Package from GitHub Source: https://github.com/amices/mice/blob/master/README.md Install the most recent version of the 'mice' package directly from its GitHub repository using the 'devtools' package. ```r install.packages("devtools") devtools::install_github(repo = "amices/mice") ``` -------------------------------- ### Install mice Package Source: https://github.com/amices/mice/blob/master/docs/index.html Install the 'mice' package from CRAN or the latest version from GitHub using devtools. ```r install.packages("mice") ``` ```r install.packages("devtools") devtools::install_github(repo = "amices/mice") ``` -------------------------------- ### Install mice Package from GitHub Source: https://github.com/amices/mice/blob/master/docs/articles/overview.html Install the latest development version of the mice package directly from its GitHub repository. Requires the devtools package. ```r install.packages("devtools") devtools::install_github("amices/mice") ``` -------------------------------- ### Name formulas using dot notation Source: https://github.com/amices/mice/blob/master/docs/reference/name.formulas.html Shows how to use name.formulas with dot notation for specifying models, which is equivalent to the previous example but more concise. ```R form2 <- list(bmi ~ ., hyp ~ ., chl ~ .) form2 <- name.formulas(form2) imp2 <- mice(nhanes, formulas = form2, print = FALSE, m = 1, seed = 12199) identical(complete(imp1), complete(imp2)) ``` -------------------------------- ### Devel Package Installation Log Source: https://github.com/amices/mice/blob/master/revdep/failures.md This log details the attempt to install development versions of R packages. It shows the URLs being queried for packages like 'broman' and 'synthpop'. ```text trying URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.5/broman_0.92.tgz' trying URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.5/synthpop_1.9-2.tgz' ``` -------------------------------- ### Conventional mice workflow example Source: https://github.com/amices/mice/blob/master/docs/reference/pool.table.html Demonstrates a typical workflow using the mice package: performing imputation, fitting a model to the imputed data, pooling the results, and accessing the pooled estimates. ```r imp <- mice(nhanes2, m = 2, maxit = 2, seed = 1, print = FALSE) fit <- with(imp, lm(chl ~ age + bmi + hyp)) pld1 <- pool(fit) pld1$pooled ``` -------------------------------- ### CRAN Package Installation Log Source: https://github.com/amices/mice/blob/master/revdep/failures.md This log shows the process of downloading and installing R packages from CRAN and Bioconductor. It indicates when binary versions are available but source versions are later, and lists the URLs being tried for package downloads. ```text There are binary versions available but the source versions are later: binary source needs_compilation MsCoreUtils 1.21.0 1.22.1 TRUE S4Arrays 1.10.0 1.10.1 TRUE SparseArray 1.10.2 1.10.6 TRUE Binaries will be installed The downloaded binary packages are in /var/folders/5_/g85d42yj50b6lrjq4rzjzg8w0000gn/T//Rtmp8AWm9i/downloaded_packages trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/affy_1.88.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/affyio_1.80.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/AnnotationDbi_1.72.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/AnnotationFilter_1.34.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/BiocBaseUtils_1.12.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/BiocFileCache_3.0.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/biomaRt_2.66.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/Biostrings_2.78.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/DAPAR_1.42.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/impute_1.84.0.tgz' ... trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/QFeatures_1.20.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/Spectra_1.20.0.tgz' trying URL 'https://bioconductor.org/packages/3.22/bioc/bin/macosx/big-sur-arm64/contrib/4.5/vsn_3.78.0.tgz' installing the source package ‘DAPARdata’ trying URL 'https://bioconductor.org/packages/3.22/data/experiment/src/contrib/DAPARdata_1.40.0.tar.gz' Content type 'application/x-gzip' length 30447560 bytes (29.0 MB) ================================================== downloaded 29.0 MB ``` -------------------------------- ### version Source: https://github.com/amices/mice/blob/master/docs/reference/version.html Echoes the package version number. It takes an optional package name and returns a character vector with the package name, version number, and installed directory. ```APIDOC ## version ### Description Echoes the package version number. ### Usage ```R version(pkg = "mice") ``` ### Arguments * **pkg** (character vector) - The package name. ### Value A character vector containing the package name, version number and installed directory. ### Examples ```R version() #> [1] "mice 3.19.9 2026-06-01 /private/var/folders/7c/sgz0tntx09542ldfdgl73bbc0000gn/T/RtmpyYz78z/temp_libpath10d6b7aa3b8a5" version("base") #> [1] "base 4.5.3 /Library/Frameworks/R.framework/Resources/library" ``` ``` -------------------------------- ### Example of using jomoImpute within mice Source: https://github.com/amices/mice/blob/master/docs/reference/mice.impute.jomoImpute.html This example demonstrates how to use jomoImpute for imputation within the mice function. It shows setting up imputation blocks, specifying imputation methods, and customizing prediction matrices. Requires mitml version 0.3-5.7. ```R if (FALSE) { # \dontrun{ # Note: Requires mitml 0.3-5.7 blocks <- list(c("bmi", "chl", "hyp"), "age") method <- c("jomoImpute", "pmm") ini <- mice(nhanes, blocks = blocks, method = method, maxit = 0) pred <- ini$pred pred["B1", "hyp"] <- -2 imp <- mice(nhanes, blocks = blocks, method = method, pred = pred, maxit = 1) } # } ``` -------------------------------- ### Predict MI Example Source: https://github.com/amices/mice/blob/master/docs/reference/predict_mi.html This example demonstrates how to use the predict_mi function to pool predictions from multiply imputed datasets. It involves creating an imputation object, splitting data into training and testing sets, fitting linear models on the imputed training data, and then pooling predictions on the test data. ```R # Dataframe with missings in X # Create Imp and Lm object dat <- mice::nhanes # add indicator training and test # first 20 for training, last 5 for testing dat$set <- c(rep("train", 20), rep("test", 5)) # Make prediction matrix and ensure that set is not used as a predictor predmat <- mice::make.predictorMatrix(dat) predmat[, "set"] <- 0 # Impute missing values based on the train set imp <- mice(dat, m = 5, maxit = 5 , seed = 1, predictorMatrix = predmat, ignore = ifelse(dat$set == "test", TRUE, FALSE), print = FALSE) impdats <- complete(imp, "all") # extract the training and test data sets traindats <- lapply(impdats, function(dat) subset(dat, set == "train", select = -set)) testdats <- lapply(impdats, function(dat) subset(dat, set == "test", select = -c(set))) # Fit the prediction models, based on the imputed training data fits <- lapply(traindats, function(dat) lm(age ~ bmi + hyp + chl, data = dat)) # pool the predictions with function pool_preds <- mice::predict_mi(object = fits, newdata = testdats, pool = TRUE, interval = "prediction", level = 0.95) ``` -------------------------------- ### Generate synthetic values for mpg Source: https://github.com/amices/mice/blob/master/docs/reference/matchindex.html This example demonstrates how to use `matchindex` to borrow values from a training set to create synthetic values for a test set, simulating observed outcomes. ```R train <- mtcars[1:20, ] test <- mtcars[21:32, ] fit <- lm(mpg ~ disp + cyl, data = train) d <- fitted.values(fit) t <- predict(fit, newdata = test) # note: not using mpg idx <- matchindex(d, t) # Borrow values from train to produce 12 synthetic values for mpg in test. # Synthetic values are plausible values that could have been observed if # they had been measured. train$mpg[idx] #> [1] 22.8 16.4 15.2 14.3 14.7 30.4 22.8 22.8 14.3 21.0 17.3 24.4 ``` -------------------------------- ### Imputation using predictorMatrix Source: https://github.com/amices/mice/blob/master/docs/reference/name.formulas.html This example shows a standard imputation process using the predictorMatrix, serving as a baseline for comparison with formula-based imputation. ```R imp4 <- mice(nhanes, print = FALSE, m = 1, seed = 12199, auxiliary = TRUE) identical(complete(imp1), complete(imp4)) ``` -------------------------------- ### Interactive Program Notice Source: https://github.com/amices/mice/blob/master/docs/LICENSE.html Display this short notice when an interactive program starts to inform users about its version, copyright, warranty, and redistribution conditions. ```text Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Get Mice Package Version Source: https://github.com/amices/mice/blob/master/cran-comments.md Use this R code to check the currently installed version of the mice package. ```r packageVersion("mice") ``` -------------------------------- ### Get version for another package Source: https://github.com/amices/mice/blob/master/docs/reference/version.html Specify the package name as a character string argument to the version() function to retrieve version information for other installed R packages, such as 'base'. ```r version("base") #> [1] "base 4.5.3 /Library/Frameworks/R.framework/Resources/library" ``` -------------------------------- ### make.post() Source: https://github.com/amices/mice/blob/master/docs/llms.txt Creates a `post` argument. ```APIDOC ## make.post() ### Description Creates a `post` argument. ### Method N/A (Function Call) ### Parameters N/A (Function Call) ### Request Example N/A (Function Call) ### Response N/A (Function Call) ``` -------------------------------- ### Get all six colors using mdc Source: https://github.com/amices/mice/blob/master/docs/reference/mdc.html This example demonstrates how to retrieve all six default colors for observed, missing, and combined data using the mdc function with numerical arguments. ```r mdc(1:6) ``` -------------------------------- ### Imputation Model on Train Data Source: https://github.com/amices/mice/blob/master/docs/reference/mice.html Fits an imputation model on training data and applies it to impute test data. This example is within a conditional block and requires specific setup. ```R if (FALSE) { # \dontrun{ # example where we fit the imputation model on the train data # and apply the model to impute the test data set.seed(123) ignore <- sample(c(TRUE, FALSE), size = 25, replace = TRUE, prob = c(0.3, 0.7)) # scenario 1: train and test in the same dataset imp <- mice(nhanes2, m = 2, ignore = ignore, print = FALSE, seed = 22112) imp.test1 <- filter(imp, ignore) imp.test1$data complete(imp.test1, 1) complete(imp.test1, 2) # scenario 2: train and test in separate datasets traindata <- nhanes2[!ignore, ] testdata <- nhanes2[ignore, ] imp.train <- mice(traindata, m = 2, print = FALSE, seed = 22112) imp.test2 <- mice.mids(imp.train, newdata = testdata) complete(imp.test2, 1) complete(imp.test2, 2) } # } ``` -------------------------------- ### Get line colors for observed and missing data using mdc Source: https://github.com/amices/mice/blob/master/docs/reference/mdc.html This example shows how to specify line colors for observed and missing data by using string abbreviations for 'observed' and 'missing' and setting the 's' argument to 'lin' for lines. ```r mdc(c("obs", "mis"), "lin") ``` -------------------------------- ### make.visitSequence() Source: https://github.com/amices/mice/blob/master/docs/llms.txt Creates a `visitSequence` argument. ```APIDOC ## make.visitSequence() ### Description Creates a `visitSequence` argument. ### Method N/A (Function Call) ### Parameters N/A (Function Call) ### Request Example N/A (Function Call) ### Response N/A (Function Call) ``` -------------------------------- ### R Vignette Execution Error with 'rjags' Library Source: https://github.com/amices/mice/blob/master/revdep/problems.md This error occurs when running R code from vignettes, specifically failing to load the 'rjags' library due to an incompatible architecture or missing dependency ('libjags.4.dylib'). This indicates a problem with the installation or environment setup for 'rjags' on the system. ```R ‘IPD-meta-analysis-with-missing-data.Rmd’ using ‘UTF-8’... failed ‘IPD-meta-analysis.Rmd’ using ‘UTF-8’... failed ‘Imputing-missing-values-in-IPD.Rmd’ using ‘UTF-8’... OK Error Errors in running code in vignettes: when running code in ‘IPD-meta-analysis-with-missing-data.Rmd’ ... + X <- with(current.data, apply(current.data[, c(" ..." ... [TRUNCATED] When sourcing ‘IPD-meta-analysis-with-missing-data.R’: ... + n.iter = 5000) When sourcing ‘IPD-meta-analysis.R’: Error: .onLoad failed in loadNamespace() for 'rjags', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Users/buurensv/Dropbox/Package/mice/mice/revdep/library.noindex/bipd/rjags/libs/rjags.so': dlopen(/Users/buurensv/Dropbox/Package/mice/mice/revdep/library.noindex/bipd/rjags/libs/rjags.so, 0x000A): Library not loaded: /usr/local/lib/libjags.4.dylib Referenced from: <337070A2-BC15-3117-B643-96612554E437> /Users/buurensv/Dropbox/Package/mice/mice/revdep/library.noindex/bipd/rjags/libs/rjags.so Reason: tried: '/usr/local/lib/libjags.4.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64e.v1' or 'arm64' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libjags.4.dylib' (no such file), '/usr/local/lib/libjags.4.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64e.v1' or 'arm64' or 'arm64')), '/Library/Frameworks/R.framework/Resources/ Execution halted ``` -------------------------------- ### Dynr Installation Failure: Missing GSL Source: https://github.com/amices/mice/blob/master/revdep/failures.md This error indicates that the GSL (GNU Scientific Library) is not installed, which is required for the 'dynr' package installation. Ensure GSL is installed and accessible in your system's PATH. ```bash checking for gsl-config... no configure: error: gsl-config not found, is GSL installed? ERROR: configuration failed for package ‘dynr’ * removing ‘/Users/buurensv/Dropbox/Package/mice/mice/revdep/checks.noindex/dynr/new/dynr.Rcheck/dynr’ ``` ```bash checking for gsl-config... no configure: error: gsl-config not found, is GSL installed? ERROR: configuration failed for package ‘dynr’ * removing ‘/Users/buurensv/Dropbox/Package/mice/mice/revdep/checks.noindex/dynr/old/dynr.Rcheck/dynr’ ``` -------------------------------- ### Construct blocks from formulas and predictor matrix Source: https://github.com/amices/mice/blob/master/docs/reference/construct.blocks.html Demonstrates how to use `construct.blocks` with both `formulas` and `predictorMatrix` arguments. The output shows the identified blocks based on the provided specifications. ```R form <- list(bmi + hyp ~ chl + age, chl ~ bmi) pred <- make.predictorMatrix(nhanes[, c("age", "chl")]) construct.blocks(formulas = form, pred = pred) ``` -------------------------------- ### make.method() Source: https://github.com/amices/mice/blob/master/docs/llms.txt Creates a `method` argument. ```APIDOC ## make.method() ### Description Creates a `method` argument. ### Method N/A (Function Call) ### Parameters N/A (Function Call) ### Request Example N/A (Function Call) ### Response N/A (Function Call) ``` -------------------------------- ### rmsb Source Package Installation Error Source: https://github.com/amices/mice/blob/master/revdep/failures.md This log shows the error encountered during the installation of the 'rmsb' source package. The installation halts due to a missing dependency, 'rstantools', which is required for loading the namespace. ```text installing *source* package ‘rmsb’ ... ** this is package ‘rmsb’ version ‘1.1-2’ ** package ‘rmsb’ successfully unpacked and MD5 sums checked ** using staged installation Error in loadNamespace(x) : there is no package called ‘rstantools’ Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: configuration failed for package ‘rmsb’ * removing ‘/Users/buurensv/Dropbox/Package/mice/mice/revdep/checks.noindex/rmsb/new/rmsb.Rcheck/rmsb’ ``` -------------------------------- ### rmsb CRAN Source Package Installation Error Source: https://github.com/amices/mice/blob/master/revdep/failures.md This log details the error during the installation of the 'rmsb' CRAN source package. Similar to the development version, the installation fails because the 'rstantools' package is not found, preventing the namespace from loading. ```text installing *source* package ‘rmsb’ ... ** this is package ‘rmsb’ version ‘1.1-2’ ** package ‘rmsb’ successfully unpacked and MD5 sums checked ** using staged installation Error in loadNamespace(x) : there is no package called ‘rstantools’ Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: configuration failed for package ‘rmsb’ * removing ‘/Users/buurensv/Dropbox/Package/mice/mice/revdep/checks.noindex/rmsb/old/rmsb.Rcheck/rmsb’ ``` -------------------------------- ### Using quickpred within mice for Imputation Source: https://github.com/amices/mice/blob/master/docs/reference/quickpred.html Demonstrates how to use the output of quickpred directly as the 'pred' argument in the mice function for performing multiple imputation. This example also filters predictors based on minimum usable cases and includes 'age'. ```R imp <- mice(nhanes, pred = quickpred(nhanes, minpuc = 0.25, include = "age")) ``` -------------------------------- ### Install mice Package from CRAN Source: https://github.com/amices/mice/blob/master/docs/articles/overview.html Use this command to install the mice package from the Comprehensive R Archive Network (CRAN). ```r install.packages("mice") ``` -------------------------------- ### Get mice package version Source: https://github.com/amices/mice/blob/master/docs/reference/version.html Call the version() function without arguments to get the version information for the mice package. ```r version() #> [1] "mice 3.19.9 2026-06-01 /private/var/folders/7c/sgz0tntx09542ldfdgl73bbc0000gn/T/RtmpyYz78z/temp_libpath10d6b7aa3b8a5" ``` -------------------------------- ### Compare pooled table outputs Source: https://github.com/amices/mice/blob/master/docs/reference/pool.table.html This example checks if the output from summary(pld2, type = "all") is identical to the output directly from pool.table(tbl). It confirms that both methods yield the same results when generating all numerical outputs. ```R class(all1) <- "data.frame" identical(all1, all2) ``` -------------------------------- ### Generate Synthetic Data, Analyze, and Pool Source: https://github.com/amices/mice/blob/master/docs/reference/pool.html This example demonstrates generating fully synthetic data using `mice` with a specified `where` matrix. The synthetic data is then analyzed with a linear model and the results are pooled using `pool.syn`. ```r imp <- mice(cars, maxit = 2, m = 2, where = matrix(TRUE, nrow(cars), ncol(cars)) ) fit <- with(data = imp, exp = lm(speed ~ dist)) summary(pool.syn(fit)) ``` -------------------------------- ### Random Forest Imputation Example Source: https://github.com/amices/mice/blob/master/docs/reference/mice.impute.rf.html Demonstrates how to perform random forest imputation using the mice function with the 'rf' method. It also shows how to plot the imputation results. This example is intended to be run in an R environment. ```r if (FALSE) { imp <- mice(nhanes2, meth = "rf", ntree = 3) plot(imp) } ``` -------------------------------- ### Initialize Imputation Model Source: https://github.com/amices/mice/blob/master/docs/reference/mice.impute.2lonly.pmm.html Sets up the initial imputation object to extract predictor matrices and imputation methods. This is a preparatory step before defining the multilevel imputation strategy. ```R # empty mice imputation imp0 <- mice(as.matrix(dfr), maxit = 0) predM <- imp0$predictorMatrix impM <- imp0$method ``` -------------------------------- ### Create Sample Data Source: https://github.com/amices/mice/blob/master/docs/reference/mice.impute.quadratic.html Generates a sample dataset with quadratic relationships and missing values for imputation demonstration. ```R B1 <- .5 B2 <- .5 X <- rnorm(1000) XX <- X^2 e <- rnorm(1000, 0, 1) Y <- B1 * X + B2 * XX + e dat <- data.frame(x = X, xx = XX, y = Y) # Impose 25 percent MCAR Missingness dat[0 == rbinom(1000, 1, 1 - .25), 1:2] <- NA ``` -------------------------------- ### Standard Copyright Notice and License Disclaimer Source: https://github.com/amices/mice/blob/master/docs/LICENSE.html Include this block at the beginning of each source file to state copyright, redistribute terms, and disclaim warranty. Ensure a copy of the GNU GPL is available. ```text Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ``` -------------------------------- ### rmsb Installation Failure (In Both Devel and CRAN) Source: https://github.com/amices/mice/blob/master/revdep/failures.md This error message indicates that the 'rmsb' package failed to install. The failure occurred in both development and CRAN versions, suggesting a common underlying issue. Details can be found in the specified R check output file. ```text checking whether package ‘rmsb’ can be installed ... ERROR Installation failed. See ‘/Users/buurensv/Dropbox/Package/mice/mice/revdep/checks.noindex/rmsb/new/rmsb.Rcheck/00install.out’ for details. ``` -------------------------------- ### Generate all numerical output from a pooled table Source: https://github.com/amices/mice/blob/master/docs/reference/pool.table.html This example demonstrates how to obtain all numerical outputs, including confidence intervals, from a pooled table using the summary function with type = "all". This provides a comprehensive set of statistics for analysis. ```R all1 <- summary(pld2, type = "all", conf.int = TRUE) all1 ``` -------------------------------- ### make.blocks() Source: https://github.com/amices/mice/blob/master/docs/llms.txt Creates a `blocks` argument. ```APIDOC ## make.blocks() ### Description Creates a `blocks` argument. ### Method N/A (Function Call) ### Parameters N/A (Function Call) ### Request Example N/A (Function Call) ### Response N/A (Function Call) ``` -------------------------------- ### Get R Version Source: https://github.com/amices/mice/blob/master/cran-comments.md Use this R code to retrieve the version string of the R environment. ```r R.Version()$version.string ``` -------------------------------- ### Run revdepcheck details for a package Source: https://github.com/amices/mice/blob/master/revdep/failures.md Use this command to get more detailed information about reverse dependency checks for a specific package. ```R revdepcheck::revdep_details(, "brms") ``` -------------------------------- ### Perform Multiple Imputations in Parallel with futuremice Source: https://github.com/amices/mice/blob/master/docs/reference/futuremice.html Demonstrates how to perform multiple imputations using futuremice. It shows basic usage with default settings and an example specifying imputation methods. Requires the mice package for imputation and future package for parallelization. ```R # 150 imputations in dataset nhanes, performed by 3 cores if (FALSE) { # \dontrun{ imp1 <- futuremice(data = nhanes, m = 150, n.core = 3) # Making use of arguments in mice. imp2 <- futuremice(data = nhanes, m = 100, method = "norm.nob") imp2$method fit <- with(imp2, lm(bmi ~ hyp)) pool(fit) } # } ```