| Title: | A Decision-Making System for Multiple Imputation |
|---|---|
| Description: | A guidance system for analysis with missing data. It incorporates expert, up-to-date methodology to help researchers choose the most appropriate analysis approach when some data are missing. You provide the available data and the assumed causal structure, including the likely causes of missing data. 'midoc' will advise which analysis approaches can be used, and how best to perform them. 'midoc' follows the framework for the treatment and reporting of missing data in observational studies (TARMOS). Lee et al (2021). <doi:10.1016/j.jclinepi.2021.01.008>. |
| Authors: | Elinor Curnow [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-3109-3647>), Jon Heron [aut], Rosie Cornish [aut], Kate Tilling [aut], James Carpenter [aut], Holly Sachdeva [ctb], Imogen Joseph [ctb], Eddie Heath [ctb] |
| Maintainer: | Elinor Curnow <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0.9000 |
| Built: | 2026-10-13 19:52:40 UTC |
| Source: | https://github.com/elliecurnow/midoc |
A simulated dataset
adradr
adrA data frame with 1000 rows and 5 columns:
Child's GCSE score (at approximately age 16 years), as a percentage, calculated from the total of an individual’s top eight GCSE qualifications, ranked in terms of points
Logarithm of the family income per annum, in UK pounds, when the child is aged 5 years
Mother's educational level: post-16 years qualification or not
Child's Key Stage 2 score (at approximately age 11 years), as a percentage, calculated from the total of an individual's English, maths and science scores
Missingness indicator: complete record (case) or not
A simulated dataset
asrdsasrds
asrdsA data frame with 1000 rows and 5 columns:
Child's Adapted Self-Report Delinquency Scale (ASRDS) value at age 17 years, as a percentage of the maximum possible value of the square-root of ASRDS
Logarithm of the family income per annum, in UK pounds, when the child is aged 5 years
Mother's educational level at time of pregnancy: post-16 years qualification or not
Child's ASRDS value at age 14 years, as a percentage of the maximum possible value of the square-root of ASRDS
Missingness indicator: complete record (case) or not
A simulated dataset
bmibmi
bmi A data frame with 1000 rows and 6 columns:Child's body mass index at age 7 years
Mother's age at first pregnancy, standardised relative to a mean age of 30 years
Mother's educational level: post-16 years qualification or not
Mother's pregnancy size: singleton or twins
Child's birth weight in kilograms
Missingness indicator: complete record (case) or not
Check complete records analysis is valid under the proposed analysis model and directed acyclic graph (DAG). Validity means that the proposed approach will allow unbiased estimation of the estimand(s) of interest. In typical use this includes regression parameters, covariate associations, and causal effects.
checkCRA(y, covs = NULL, r_cra, mdag)checkCRA(y, covs = NULL, r_cra, mdag)
y |
The analysis model outcome variable(s), specified as a string (space delimited) or a list |
covs |
Optional analysis model covariate(s), specified as a string (space delimited) or a list |
r_cra |
The complete record indicator, specified as a string |
mdag |
The DAG, specified as a string using dagitty syntax, or as a dagitty graph object |
The DAG should include all observed and unobserved variables related to the analysis model variables and their missingness, as well as the complete record ("missingness") indicator.
In general, complete records analysis of the conditional relationship between the analysis model outcome and the specified covariates is valid if the outcome and complete record indicator are unrelated, given the specified covariates. This is determined using the proposed DAG by checking whether the analysis model outcome(s) and complete record indicator are 'd-separated', conditional on the covariates.
A message indicating whether complete records analysis is valid under the proposed DAG and analysis model outcome and covariate(s)
Hughes R, Heron J, Sterne J, Tilling K. 2019. Accounting for missing data in statistical analyses: multiple imputation is not always the answer. Int J Epidemiol. https://doi.org/10.1093/ije/dyz032
Bartlett JW, Harel O, Carpenter JR. 2015. Asymptotically Unbiased Estimation of Exposure Odds Ratios in Complete Records Logistic Regression. Am J Epidemiol. https://doi.org/10.1093/aje/kwv114
# Example DAG for which complete records analysis is not valid checkCRA(y="bmi7", covs="matage", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r") # For the DAG in the example above, complete records analysis is valid ## if a different set of covariates is used checkCRA(y="bmi7", covs="matage mated", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r") # Example where complete records analysis is never valid checkCRA(y="bmi7", covs="matage mated", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r bmi7 -> r")# Example DAG for which complete records analysis is not valid checkCRA(y="bmi7", covs="matage", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r") # For the DAG in the example above, complete records analysis is valid ## if a different set of covariates is used checkCRA(y="bmi7", covs="matage mated", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r") # Example where complete records analysis is never valid checkCRA(y="bmi7", covs="matage mated", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r bmi7 -> r")
Check multiple imputation is valid under the proposed imputation model(s) and directed acyclic graph (DAG). Validity means that the proposed approach will allow unbiased estimation of the estimand(s) of interest. In typical use this includes regression parameters, covariate associations, and causal effects.
checkMI(dep, preds = NULL, r_cra, mdag)checkMI(dep, preds = NULL, r_cra, mdag)
dep |
The partially observed variable(s) to be imputed, specified as a string (space delimited) or a list |
preds |
Optional fully observed imputation model predictor(s), specified as a string (space delimited) or a list |
r_cra |
The complete record indicator, specified as a string |
mdag |
The DAG, specified as a string using dagitty syntax, or as a dagitty graph object |
Imputation model(s) should include all other analysis model variables as predictors, as well as any auxiliary variables. The DAG should include all observed and unobserved variables related to the analysis model variables and their missingness, as well as the complete record ("missingness") indicator.
In principle, multiple imputation is valid if all partially observed variables are unrelated to missingness, given the (fully observed) imputation model predictors. This is determined using the proposed DAG by checking whether all the partially observed variables are 'd-separated' from the complete record indicator, conditional on the imputation model predictors. It is assumed that all the specified imputation model predictors are fully observed and will be used to impute all the specified partially observed variables.
A message indicating whether multiple imputation is valid under the proposed DAG and imputation model predictor(s)
Curnow E, Tilling K, Heron JE, Cornish RP, Carpenter JR. 2023. Multiple imputation of missing data under missing at random: including a collider as an auxiliary variable in the imputation model can induce bias. Frontiers in Epidemiology. https://doi.org/10.3389/fepid.2023.1237447
# Example DAG for which multiple imputation is valid, because collider ## variable 'bwt' is not included as a predictor checkMI(dep="bmi7", preds="matage mated pregsize", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r pregsize -> bmi7 pregsize -> bwt sep_unmeas -> bwt") # Example DAG for which multiple imputation is not valid checkMI(dep="bmi7", preds="matage", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r")# Example DAG for which multiple imputation is valid, because collider ## variable 'bwt' is not included as a predictor checkMI(dep="bmi7", preds="matage mated pregsize", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r pregsize -> bmi7 pregsize -> bwt sep_unmeas -> bwt") # Example DAG for which multiple imputation is not valid checkMI(dep="bmi7", preds="matage", r_cra="r", mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r")
Specify a parametric model (which may represent the analysis or imputation model). Optionally, if a dataset is supplied, explore whether the observed relationships in the specified dataset are consistent with the proposed parametric model.
checkModSpec( formula, family, by = NULL, data = NULL, plot = TRUE, message = TRUE )checkModSpec( formula, family, by = NULL, data = NULL, plot = TRUE, message = TRUE )
formula |
A symbolic description of the model to be fitted, with the dependent variable on the left of a ~ operator, and the covariates, separated by + operators, on the right, specified as a string |
family |
A description of the error distribution and link function to be used in the model, specified as a string; family functions that are supported are "gaussian(identity)" and "binomial(logit)" |
by |
Optional stratification variable(s), specified as a string (space delimited) or a list of factors; if specified, the parametric model will be fit for each subset of the data determined by the values of the factor(s) |
data |
Optionally, a data frame containing all the variables stated in the formula and if specified, stratification variable(s) |
plot |
If TRUE (the default), and a dataset is supplied, displays a plot which can be used to explore the form of the specified model; note that stratification variables are ignored in the plot; use plot = FALSE to disable the plot |
message |
If TRUE (the default), and a dataset is supplied, displays a message indicating whether the relationships between the dependent variable and covariates are likely to be correctly specified or not; use message = FALSE to suppress the message |
An object of type 'mimod' (a list containing the specified formula, family, and, if specified, dataset name). Optionally, if required and a dataset is supplied, a message indicating whether the relationships between the dependent variable and covariates are likely to be correctly specified or not.
Curnow E, Carpenter JR, Heron JE, et al. 2023. Multiple imputation of missing data under missing at random: compatible imputation models are not sufficient to avoid bias if they are mis-specified. J Clin Epidemiol. https://doi.org/10.1016/j.jclinepi.2023.06.011
# Example (incorrectly) assuming a linear relationship checkModSpec(formula="bmi7~matage+mated+pregsize", family="gaussian(identity)", data=bmi) ## For the example above, (correctly) assuming a quadratic relationship checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi)# Example (incorrectly) assuming a linear relationship checkModSpec(formula="bmi7~matage+mated+pregsize", family="gaussian(identity)", data=bmi) ## For the example above, (correctly) assuming a quadratic relationship checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi)
Summarises the missing data patterns in the specified dataset. Each row in the output corresponds to a missing data pattern (1=observed, 0=missing). The number and percentage of observations is also displayed for each missing data pattern. The first column indicates the number of missing data patterns. The second column refers to the analysis model outcome ('y'), with all other variables ('covs') displayed in subsequent columns. Alternatively, 'y' can indicate the primary variable of interest, e.g. 'y' could refer to an exposure or intervention, with all other variables listed in 'covs'.
descMissData(y, data, covs = NULL, by = NULL, plot = FALSE)descMissData(y, data, covs = NULL, by = NULL, plot = FALSE)
y |
The analysis model outcome variable(s), specified as a string (space delimited) or a list |
data |
A data frame containing the specified analysis model outcome, covariate(s), and if specified, stratification variable(s) |
covs |
Optional analysis model covariate(s), specified as a string (space delimited) or a list |
by |
Optional stratification variable(s), specified as a string (space delimited) or a list of factors; if specified, the data are subsetted by the values of the factor(s) and missing data patterns are displayed for each subset in turn; can only be used when the total number of variables listed in 'y' and 'covs' is greater than one |
plot |
If TRUE, displays a plot using md.pattern to visualise the missing data patterns; if stratification variable(s) are specified, a separate plot will be displayed for each subset; use plot = FALSE (the default) to disable the plot |
A summary of the missing data patterns
descMissData(y="bmi7", covs="matage mated", data=bmi) descMissData(y="bmi7", covs="matage mated bwt", by="pregsize", data=bmi)descMissData(y="bmi7", covs="matage mated", data=bmi) descMissData(y="bmi7", covs="matage mated bwt", by="pregsize", data=bmi)
Creates multiple imputations using mice, based on the options and dataset specified by a call to proposeMI. Further arguments can be passed to this function - see the help file for mice for more information. If stratification variable(s) are included in the 'miprop' object, multiple imputation will be performed for each subset of the data determined by the values of the stratification variable(s) and the resulting imputed datasets will be combined. If a substantive model is specified, the pooled estimates are calculated using pool.
doMImice(mipropobj, seed, substmod = NULL, message = TRUE, ...)doMImice(mipropobj, seed, substmod = NULL, message = TRUE, ...)
mipropobj |
An object of type 'miprop', created by a call to 'proposeMI' |
seed |
An integer that is used to set the seed of the 'mice' call |
substmod |
Optionally, a symbolic description of the substantive model to be fitted, specified as a string; if supplied, the model will be fitted to each imputed dataset and the results pooled |
message |
If TRUE (the default), displays a message summarising the analysis that has been performed; use message = FALSE to suppress the message |
... |
Further arguments passed to mice |
A 'mice' object of class 'mids' (the multiply imputed datasets). Optionally, a message summarising the analysis that has been performed.
# First specify the imputation model as a 'mimod' object ## (suppressing the message) mimod_bmi7 <- checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi, message=FALSE) # Save the proposed 'mice' options as a 'miprop' object ## (suppressing the message) miprop <- proposeMI(mimodobj=mimod_bmi7, data=bmi, message=FALSE, plot = FALSE) # Create the set of imputed datasets using the proposed 'mice' options imp <- doMImice(miprop,123) # Additionally, fit the substantive model to each imputed dataset and display ## the pooled results doMImice(miprop, 123, substmod="lm(bmi7 ~ matage + I(matage^2) + mated)")# First specify the imputation model as a 'mimod' object ## (suppressing the message) mimod_bmi7 <- checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi, message=FALSE) # Save the proposed 'mice' options as a 'miprop' object ## (suppressing the message) miprop <- proposeMI(mimodobj=mimod_bmi7, data=bmi, message=FALSE, plot = FALSE) # Create the set of imputed datasets using the proposed 'mice' options imp <- doMImice(miprop,123) # Additionally, fit the substantive model to each imputed dataset and display ## the pooled results doMImice(miprop, 123, substmod="lm(bmi7 ~ matage + I(matage^2) + mated)")
Creates multiple imputations using mice. Imputations are based on the options and dataset specified by a call to proposeMI, and additionally on the specified missing not at random (MNAR) mechanism. Further arguments can be passed to this function - see the help file for mice for more information. If stratification variable(s) are included in the 'miprop' object, multiple imputation will be performed for each subset of the data determined by the values of the stratification variable(s) and the resulting imputed datasets will be combined. If a substantive model is specified, the pooled estimates are calculated using pool.
doMNARMImice( mipropobj, mnardep, mnardelta, seed, substmod = NULL, message = TRUE, ... )doMNARMImice( mipropobj, mnardep, mnardelta, seed, substmod = NULL, message = TRUE, ... )
mipropobj |
An object of type 'miprop', created by a call to 'proposeMI' |
mnardep |
The partially observed variable to be imputed under MNAR, specified as a string |
mnardelta |
The desired sensitivity (delta) parameter as a function of other variables and values, specified as a string |
seed |
An integer that is used to set the seed of the 'mice' call |
substmod |
Optionally, a symbolic description of the substantive model to be fitted, specified as a string; if supplied, the model will be fitted to each imputed dataset and the results pooled |
message |
If TRUE (the default), displays a message summarising the analysis that has been performed; use message = FALSE to suppress the message |
... |
Further arguments passed to mice |
Imputation is performed using the NARFCS procedure (Tompsett et al, 2018) for the specified variable. See mice.impute.mnar.logreg for further details. All other partially observed variables are assumed to be missing at random (MAR) and imputed using the method(s) specified as per the 'miprop' object.
A 'mice' object of class 'mids' (the multiply imputed datasets). Optionally, a message summarising the analysis that has been performed.
Tompsett D, Leacy F, Moreno-Betancur M, Heron J, & White IR. 2018. On the use of the not-at-random fully conditional specification (NARFCS) procedure in practice. Statistics in Medicine. https://doi.org/10.1002/sim.7643
# First specify the imputation model as a 'mimod' object ## (suppressing the message) mimod_bmi7 <- checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi, message=FALSE) # Save the proposed 'mice' options as a 'miprop' object ## (suppressing the message) miprop <- proposeMI(mimodobj=mimod_bmi7, data=bmi, message=FALSE, plot = FALSE) # Create the set of imputed datasets using the proposed 'mice' options and # desired MNAR mechanism (decreasing imputed values of bmi7 by 2 units) imp <- doMNARMImice(mipropobj=miprop, mnardep="bmi7", mnardelta="-2", seed=123) # Additionally, fit the substantive model to each imputed dataset and display ## the pooled results doMNARMImice(mipropobj=miprop, mnardep="bmi7", mnardelta="-2", seed=123, substmod="lm(bmi7 ~ matage + I(matage^2) + mated)")# First specify the imputation model as a 'mimod' object ## (suppressing the message) mimod_bmi7 <- checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi, message=FALSE) # Save the proposed 'mice' options as a 'miprop' object ## (suppressing the message) miprop <- proposeMI(mimodobj=mimod_bmi7, data=bmi, message=FALSE, plot = FALSE) # Create the set of imputed datasets using the proposed 'mice' options and # desired MNAR mechanism (decreasing imputed values of bmi7 by 2 units) imp <- doMNARMImice(mipropobj=miprop, mnardep="bmi7", mnardelta="-2", seed=123) # Additionally, fit the substantive model to each imputed dataset and display ## the pooled results doMNARMImice(mipropobj=miprop, mnardep="bmi7", mnardelta="-2", seed=123, substmod="lm(bmi7 ~ matage + I(matage^2) + mated)")
Creates multiple imputations under reference-based multiple imputation using RefBasedMI. Imputations are based on the dataset and relevant options specified by a call to proposeMI. If a substantive model is specified, the pooled estimates are also calculated using pool. The dataset is assumed to be in 'wide' format, with one row per subject. It is assumed that the outcome is measured repeatedly over time, with at least one measurement at an intermediate time-point (i.e. between baseline and study end-point). Data are assumed to be multivariate normal within each category of the grouping variable (in typical use, this denotes the treatment allocation).
doRefBasedMI( mipropobj, y, groupvar, covs = NULL, idvar = NULL, method, reference, seed, substmod = NULL, message = TRUE )doRefBasedMI( mipropobj, y, groupvar, covs = NULL, idvar = NULL, method, reference, seed, substmod = NULL, message = TRUE )
mipropobj |
An object of type 'miprop', created by a call to 'proposeMI' |
y |
The analysis model outcome variables (at least two are required), specified as a string (space delimited) or a list |
groupvar |
Group variable; can be numeric or string |
covs |
Optional analysis model covariate(s), specified as a string (space delimited) or a list; a maximum of five covariates can be specified |
idvar |
Optional participant identifier variable; if not provided, an identifier variable, named 'id', will be automatically created |
method |
Reference-based imputation method; methods that are supported are "J2R", "CR", and "CIR" |
reference |
Reference group for the specified method; can be numeric or string |
seed |
An integer that is used to set the seed of the 'mice' call |
substmod |
Optionally, a symbolic description of the substantive model to be fitted, specified as a string; if supplied, the model will be fitted to each imputed dataset and the results pooled |
message |
If TRUE (the default), displays a message summarising the analysis that has been performed; use message = FALSE to suppress the message |
Reference-based multiple imputation uses observed data from one category of the grouping variable - the 'reference' group - to impute missing values in other categories. Available reference-based methods are 'jump-to-reference' (J2R), 'copy reference' (CR), and 'copy increments in reference' (CIR). J2R assumes that the distribution of outcomes for individuals who drop out 'jumps to' the distribution observed in the reference group following their last observed time point. CR assumes individuals who drop out behave as if they are in the specified reference group for the full duration of the trial. CIR assumes that the distribution of outcomes for individuals who drop out follows the mean increments observed in the reference group, following their last observed time point.
A 'mice' object of class 'mids' (the multiply imputed datasets). Optionally, a message summarising the analysis that has been performed.
# First specify the imputation model as a 'mimod'object ## (suppressing the message) mimod_qol12 <- checkModSpec(formula="qol12 ~ factor(group) + age0 + qol0 + qol3", family="gaussian(identity)", data=qol, message=FALSE) # Save the proposed 'mice' options as a 'miprop' object ## (suppressing the message) miprop_qol12 <- proposeMI(mimodobj=mimod_qol12, data=qol, message=FALSE, plot = FALSE) # Create the set of imputed datasets using the proposed mice' options and ## specified reference-based imputation method; then fit the substantive ## model to each imputed dataset and display the pooled results doRefBasedMI(mipropobj=miprop_qol12, y="qol3 qol12", groupvar="group", covs="age0 qol0", idvar="id", method="J2R", reference=1, seed=123, substmod = "lm(qol12 ~ factor(group) + age0 + qol0)")# First specify the imputation model as a 'mimod'object ## (suppressing the message) mimod_qol12 <- checkModSpec(formula="qol12 ~ factor(group) + age0 + qol0 + qol3", family="gaussian(identity)", data=qol, message=FALSE) # Save the proposed 'mice' options as a 'miprop' object ## (suppressing the message) miprop_qol12 <- proposeMI(mimodobj=mimod_qol12, data=qol, message=FALSE, plot = FALSE) # Create the set of imputed datasets using the proposed mice' options and ## specified reference-based imputation method; then fit the substantive ## model to each imputed dataset and display the pooled results doRefBasedMI(mipropobj=miprop_qol12, y="qol3 qol12", groupvar="group", covs="age0 qol0", idvar="id", method="J2R", reference=1, seed=123, substmod = "lm(qol12 ~ factor(group) + age0 + qol0)")
Explore the relationships implied by the proposed directed acyclic graph (DAG). Optionally, if a dataset is supplied, explore whether relationships between fully observed variables in the specified dataset are consistent with the proposed DAG.
exploreDAG(mdag, data = NULL, message = TRUE)exploreDAG(mdag, data = NULL, message = TRUE)
mdag |
The DAG, specified as a string using dagitty syntax, or as a dagitty graph object |
data |
Optionally, a data frame containing all the variables stated in the DAG. All ordinal variables must be integer-coded and all categorical variables must be dummy-coded. |
message |
If TRUE (the default), displays a message describing the exploratory analysis performed; use message = FALSE to suppress the message |
A message listing the pairs of variables that are implied to be independent (possibly conditional on other variables) by the proposed DAG. Optionally, if a dataset is supplied, a message indicating whether the relationships between fully observed variables in the specified dataset are consistent with the proposed DAG.
exploreDAG(mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r", data=bmi)exploreDAG(mdag="matage -> bmi7 mated -> matage mated -> bmi7 sep_unmeas -> mated sep_unmeas -> r", data=bmi)
Runs a browser-based version of the midoc package. In this version, you can explore midoc functions using exemplar datasets or apply midoc functions using your own DAG and data.
midocShinyApp()midocShinyApp()
A browser-based version of the midoc package
# Run the browser-based version of the midoc package midocShinyApp()# Run the browser-based version of the midoc package midocShinyApp()
Runs an interactive version of the midoc vignette: Multiple Imputation DOCtor (midoc). In the interactive version, you can apply midoc functions in shiny-package apps using your own DAG and data.
midocVignette()midocVignette()
A browser-based, interactive version of the midoc vignette
# Run the interactive vignette midocVignette()# Run the interactive vignette midocVignette()
Suggests the mice options to perform multiple imputation, based on the set of imputation models (one for each partially observed variable) specified by calls to checkModSpec and the proportion of complete records. Optionally, if a dataset is supplied, diagnostic plots are created based on the proposed 'mice' options.
proposeMI( mimodobj, prop_complete = NA, data = NULL, plot = TRUE, plotprompt = TRUE, message = TRUE )proposeMI( mimodobj, prop_complete = NA, data = NULL, plot = TRUE, plotprompt = TRUE, message = TRUE )
mimodobj |
An object, or list of objects, of type 'mimod', which stands for 'multiple imputation model', created by a call to checkModSpec |
prop_complete |
Optionally, the proportion of complete records, specified as a number between 0 and 1. This is only required if a dataset is not specified. If a dataset is specified, the proportion of complete records will be calculated based on all columns included in the dataset. |
data |
Optionally, a data frame containing all the variables required for imputation and the substantive analysis; if stratification variable(s) are included in the 'mimod' object(s), these will be carried over to 'midoc' functions 'doMImice' and 'doMNARMImice' and multiple imputation will be performed for each subset of the data determined by the values of the stratification variable(s) |
plot |
If TRUE (the default), and a dataset is supplied, displays diagnostic plots for the proposed 'mice' call; use plot=FALSE to disable the plots |
plotprompt |
If TRUE (the default), and a dataset is supplied, the user is prompted before each subsequent plot is displayed; use plotprompt=FALSE to remove the prompt and display all plots at the same time |
message |
If TRUE (the default), displays a message describing the proposed 'mice' options; use message=FALSE to suppress the message |
An object of type 'miprop', which can be used to run 'mice' using the proposed options, plus optionally, a message and, if a dataset is supplied, diagnostic plots describing the proposed 'mice' options
# First specify each imputation model as a 'mimod' object ## (suppressing the message) mimod_bmi7 <- checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi, message=FALSE) mimod_pregsize <- checkModSpec( formula="pregsize~bmi7+matage+I(matage^2)+mated", family="binomial(logit)", data=bmi, message=FALSE) # Display the proposed 'mice' options ## When specifying a single imputation model proposeMI(mimodobj=mimod_bmi7, data=bmi) ## When specifying more than one imputation model (suppressing the plots) proposeMI(mimodobj=list(mimod_bmi7,mimod_pregsize), data=bmi, plot=FALSE)# First specify each imputation model as a 'mimod' object ## (suppressing the message) mimod_bmi7 <- checkModSpec(formula="bmi7~matage+I(matage^2)+mated+pregsize", family="gaussian(identity)", data=bmi, message=FALSE) mimod_pregsize <- checkModSpec( formula="pregsize~bmi7+matage+I(matage^2)+mated", family="binomial(logit)", data=bmi, message=FALSE) # Display the proposed 'mice' options ## When specifying a single imputation model proposeMI(mimodobj=mimod_bmi7, data=bmi) ## When specifying more than one imputation model (suppressing the plots) proposeMI(mimodobj=list(mimod_bmi7,mimod_pregsize), data=bmi, plot=FALSE)
A simulated dataset
qolqol
qolA data frame with 1000 rows and 6 columns:
Randomisation group: 1 = Placebo, 2 = Active treatment
Participant's age at randomisation (baseline), in years
Participant's quality of life at randomisation (baseline), measured using the EuroQol Visual Analogue Scale (EQ-VAS)
Participant's quality of life at 3 months post-randomisation, measured using EQ-VAS
Participant's quality of life at 12 months post-randomisation, measured using EQ-VAS
Missingness indicator: complete record (case) or not
Produces a table of descriptive statistics for the analysis model outcome ('y') and covariate ('covs') variables, stratified by the complete record indicator ('r_cra') and optionally, by other stratification variable(s). Alternatively, 'y' can indicate the primary variable of interest, e.g. 'y' could refer to an exposure or intervention, with all other variables listed in 'covs'. The table displays the percentage of missing values for each variable, plus the mean and standard deviation of numeric variables, and frequency and percentage of categorical variables. Optional plots display box plots for numeric variables and stacked bar charts for categorical variables.
summMissData( y, r_cra, data, covs = NULL, by = NULL, plot = TRUE, plotprompt = TRUE, message = TRUE, ... )summMissData( y, r_cra, data, covs = NULL, by = NULL, plot = TRUE, plotprompt = TRUE, message = TRUE, ... )
y |
The analysis model outcome variable(s), specified as a string (space delimited) or a list |
r_cra |
The complete record indicator variable, which must be a factor |
data |
A data frame containing the specified analysis model outcome, covariate(s), and if specified, stratification variable(s) |
covs |
Optional analysis model covariate(s), specified as a string (space delimited) or a list |
by |
Optional additional stratification variable(s); if specified, the data are subsetted according to both the complete record indicator and the values of the stratification variable(s) and summary data are displayed for each subset in turn |
plot |
If TRUE (the default), summary plots are displayed; note that stratification variables are ignored in the plot; use plot = FALSE to disable the plots |
plotprompt |
If TRUE (the default), the user is prompted before each plot is displayed; use plotprompt=FALSE to remove the prompt |
message |
If TRUE (the default), displays a table of descriptive statistics comparing complete and incomplete records; use message = FALSE to suppress the message |
... |
Further arguments passed to table1 |
The summary table is created using the table1 function. Further arguments can be passed to this function - see the help file for table1 for more information. Note that the 'transpose' feature is not available. The summary table and plots can be used to compare the characteristics of complete and incomplete records. Note that there may be differences in variable distributions between complete and incomplete records if data are missing at random or missing not at random. Therefore, any observed differences cannot be used as evidence for or against the data missing at random assumption.
A summary of descriptive statistics comparing complete and incomplete records and, optionally, descriptive plots.
summMissData(y="bmi7", r_cra="r", data=bmi, covs="matage mated bwt pregsize", rowlabelhead="Complete")summMissData(y="bmi7", r_cra="r", data=bmi, covs="matage mated bwt pregsize", rowlabelhead="Complete")