cbind: Combine 'mimids' and 'wimids' Objects by Columns

Description Usage Arguments Value Author(s) See Also Examples

View source: R/cbind.R

Description

This function combines a mimids or wimids object columnwise with additional datasets or variables. Typically these would be variables not included in the original imputation and therefore absent in the mimids or wimids object. with() can then be used on the output to run models with the added variables.

Usage

1
2
3
4
5
6
7
cbind(..., deparse.level = 1)

## S3 method for class 'mimids'
cbind(..., deparse.level = 1)

## S3 method for class 'wimids'
cbind(..., deparse.level = 1)

Arguments

...

Objects to combine columnwise. The first should be a mimids or wimids object. Additional data.frames, matrixes, factors, or vectors can be supplied. These can be given as named arguments.

deparse.level

Ignored.

Value

An object with the same class as the first input object with the additional variables added to the components.

Author(s)

Farhad Pishgar and Noah Greifer

See Also

mice::cbind.mids, cbind

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Loading libraries
library(MatchThem)
library(survey)

#Loading the dataset
data(osteoarthritis)

#Multiply imputing the missing values
imputed.datasets <- mice::mice(osteoarthritis, m = 5)

#Weighting the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK, imputed.datasets,
                               approach = 'within')

#Adding additional variables
weighted.datasets <- cbind(weighted.datasets,
                           logAGE = log(osteoarthritis$AGE))

#Using the additional variables in an analysis
models <- with(weighted.datasets,
               svyglm(KOA ~ OSP + logAGE, family = quasibinomial))

#Pooling results obtained from analyzing the datasets
results <- pool(models)
summary(results)

MatchThem documentation built on March 31, 2021, 9:08 a.m.