Skip to content

Usage of formulas within mice and output of predictorMatrix #573

Answered by stefvanbuuren
tinneuro asked this question in Q&A
Discussion options

You must be logged in to vote

Good question. Here's a way to do it.

library(mice, warn.conflicts = FALSE)
f <- make.formulas(nhanes)
f$bmi <- bmi ~ 1
imp <- mice(nhanes, formulas = f, method = "norm.predict", print = FALSE)
imp$formulas
#> $age
#> age ~ bmi + hyp + chl
#> <environment: 0x10a3c3bf8>
#> 
#> $bmi
#> bmi ~ 1
#> 
#> $hyp
#> hyp ~ age + bmi + chl
#> <environment: 0x10a3c3bf8>
#> 
#> $chl
#> chl ~ age + bmi + hyp
#> <environment: 0x10a3c3bf8>
imp$imp$bmi
#>          1       2       3       4       5
#> 1  26.5625 26.5625 26.5625 26.5625 26.5625
#> 3  26.5625 26.5625 26.5625 26.5625 26.5625
#> 4  26.5625 26.5625 26.5625 26.5625 26.5625
#> 6  26.5625 26.5625 26.5625 26.5625 26.5625
#> 10 26.5625 26.5625 26.562…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@tinneuro
Comment options

@stefvanbuuren
Comment options

@tinneuro
Comment options

Answer selected by tinneuro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants