R/withPool.R

Defines functions withPool_NMI withPool_MI

Documented in withPool_MI withPool_NMI

## File Name: withPool.R
## File Version: 0.04


############################################################
# extraction method for multiply imputed datasets
withPool_MI <- function(x,...){
    res <- x
    if (inherits(res,"mira")){
            res <- res$analyses
                }
    NB <- length(res)
    res1 <- res[[1]]
    if (NB>1){
        for (bb in 2:NB){
            res1 <- res1 + res[[bb]]
                }
            }
    res1 <- res1 / NB
    return(res1)
}
#################################################################



############################################################
# extraction method for multiply imputed datasets
withPool_NMI <- function(x,...){
    res <- x
    if (inherits(res,"mira.nmi")){
            res <- res$analyses
                }
    NB <- length(res)
    NW <- length(res[[1]])
    res1 <- 0
    for (bb in 1:NB){
        for (ww in 1:NW){
            res1 <- res1 + res[[bb]][[ww]]
                }
            }
    res1 <- res1 / (NB*NW)
    return(res1)
}
#################################################################
alexanderrobitzsch/miceadds documentation built on Feb. 2, 2024, 10:21 a.m.