The “pool” Function in R

  • Package: mice

  • Purpose: Combine results from multiple imputed datasets.

  • General class: Imputation

  • Required argument(s):

    • object: An object of class mira (multiply imputed repeated analyses) or a list with mipo (multiple imputation pooled outcomes) objects.

  • Notable optional arguments:

    • dfcom: Degrees of freedom for the complete data.

    • rule: “rubin1987” is the default used for missing data, you can also choose “reiter2003” for synthetic missing data.

  • Example:

  • # Load the required library
    library(mice)

    # Load the nhanes dataset
    data(nhanes)

    # Perform multiple imputation on the nhanes dataset
    imputed_data <- mice(nhanes, m = 5, maxit = 50, meth = 'pmm', seed = 500)

    # Fit a linear model on each of the imputed datasets
    fit <- with(imputed_data, lm(bmi ~ hyp + chl))

    # Pool the results of the linear models
    pooled_results <- pool(fit)

    # Print the summary of the pooled results
    summary(pooled_results)

  • In this example, the mice package is used to handle missing data through multiple imputation. First, the mice function creates multiple imputed datasets. Next, the with function applies a linear model to each of these datasets. Finally, the pool function combines the results from these multiple models to provide a single set of estimates and inferential statistics. The summary function is then used to display the pooled results.

Previous
Previous

The “densityplot” Function in R

Next
Next

The “md.pattern” Function in R