micombine.cor: Inference for Correlations and Covariances for Multiply... In alexanderrobitzsch/miceadds: Some Additional Multiple Imputation Functions, Especially for 'mice'

Description

Statistical inference for correlations and covariances for multiply imputed datasets

Usage

 ```1 2 3 4 5``` ```micombine.cor(mi.res, variables=NULL, conf.level=0.95, method="pearson", nested=FALSE, partial=NULL ) micombine.cov(mi.res, variables=NULL, conf.level=0.95, nested=FALSE ) ```

Arguments

 `mi.res` Object of class `mids` or `mids.1chain` `variables` Indices of variables for selection `conf.level` Confidence level `method` Method for calculating correlations. Must be one of `"pearson"` or `"spearman"`. The default is the calculation of the Pearson correlation. `nested` Logical indicating whether the input dataset stems from a nested multiple imputation. `partial` Formula object for computing partial correlations. The terms which should be residualized are written in the formula object `partial`.

Value

A data frame containing the coefficients (`r`, `cov`) and its corresponding standard error (`rse`, `cov_se`), fraction of missing information (`fmi`) and a t value (`t`).

The corresponding coefficients can also be obtained as matrices by requesting `attr(result,"r_matrix")`.

See `stats::cor.test` for testing correlation coefficients.
 ``` 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82``` ```## Not run: ############################################################################# # EXAMPLE 1: nhanes data | combination of correlation coefficients ############################################################################# library(mice) data(nhanes, package="mice") set.seed(9090) # nhanes data in one chain imp.mi <- miceadds::mice.1chain( nhanes, burnin=5, iter=20, Nimp=4, method=rep("norm", 4 ) ) # correlation coefficients of variables 4, 2 and 3 (indexed in nhanes data) res <- miceadds::micombine.cor(mi.res=imp.mi, variables=c(4,2,3) ) ## variable1 variable2 r rse fisher_r fisher_rse fmi t p ## 1 chl bmi 0.2458 0.2236 0.2510 0.2540 0.3246 0.9879 0.3232 ## 2 chl hyp 0.2286 0.2152 0.2327 0.2413 0.2377 0.9643 0.3349 ## 3 bmi hyp -0.0084 0.2198 -0.0084 0.2351 0.1904 -0.0358 0.9714 ## lower95 upper95 ## 1 -0.2421 0.6345 ## 2 -0.2358 0.6080 ## 3 -0.4376 0.4239 # extract matrix with correlations and its standard errors attr(res, "r_matrix") attr(res, "rse_matrix") # inference for covariance res2 <- miceadds::micombine.cov(mi.res=imp.mi, variables=c(4,2,3) ) # inference can also be conducted for non-imputed data res3 <- miceadds::micombine.cov(mi.res=nhanes, variables=c(4,2,3) ) ############################################################################# # EXAMPLE 2: nhanes data | comparing different correlation coefficients ############################################################################# library(psych) library(mitools) # imputing data imp1 <- mice::mice( nhanes, method=rep("norm", 4 ) ) summary(imp1) #*** Pearson correlation res1 <- miceadds::micombine.cor(mi.res=imp1, variables=c(4,2) ) #*** Spearman rank correlation res2 <- miceadds::micombine.cor(mi.res=imp1, variables=c(4,2), method="spearman") #*** Kendalls tau # test of computation of tau for first imputed dataset dat1 <- mice::complete(imp1, action=1) tau1 <- psych::corr.test(x=dat1[,c(4,2)], method="kendall") tau1\$r[1,2] # estimate tau1\$se # standard error # results of Kendalls tau for all imputed datasets res3 <- with( data=imp1, expr=psych::corr.test( x=cbind( chl, bmi ), method="kendall") ) # extract estimates betas <- lapply( res3\$analyses, FUN=function(ll){ ll\$r[1,2] } ) # extract variances vars <- lapply( res3\$analyses, FUN=function(ll){ (ll\$se[1,2])^2 } ) # Rubin inference tau_comb <- mitools::MIcombine( results=betas, variances=vars ) summary(tau_comb) ############################################################################# # EXAMPLE 3: Inference for correlations for nested multiply imputed datasets ############################################################################# library(BIFIEsurvey) data(data.timss4, package="BIFIEsurvey" ) datlist <- data.timss4 # object of class nested.datlist datlist <- miceadds::nested.datlist_create(datlist) # inference for correlations res2 <- miceadds::micombine.cor(mi.res=datlist, variables=c("lang", "migrant", "ASMMAT")) ## End(Not run) ```