Author: Elhakim Ibrahim

Instructor: Corey Sparks, PhD1

April 27, 2020



Objectives of the exercise

This exercise illustrates modal and multiple imputation approaches to addressing missing data issues in binary logistic regression analysis. Model estimates from model fit on the imputed data and conventional filtered data with no missing data are compared to assess the potential impact of data missingness on model fit.



Data source

The exercise is based on 2018 Nigeria Demographic and Health Survey women recode data set. The Nigeria Demographic and Health Surveys data are accessible with permission from DHS Program archive.



Set working directory and load packages



Load data, select and rename working variables



Outcome of interest and variables specification

Outcome of interest

The outcome of interest is history of abortion among fecund, nonsterilized study population age 15 to 44 years. This will be specified as a binary outcome: Never had versus Ever had. The Never had category represents those who had never had a terminated pregancy within five years to the interview date, while Ever had category represents those who have had an abortion during the same period. For the purpose of analysis, age, union status, parity, parity preference, fertility desire, educational attainment, wealth status, as well as region and place of residence would be included as indenpendent correlates.

Variables specification

Terminated

Age group

Sexual recency

Fertility desire

Educational attainment

Location of residence



Imputation procedures

Check missingness in the data

The summary results show the number of missing record (NA) for each variable: 3891 for age, 6749 for sex recency and 1187 for fertility desire.

     terminate      agegroup         sexrecency            fertdesire   
 Never had:36983   15-19:8423   Recent    :23855   Wants more   :28894  
 Ever had : 4838   20-24:6844   Not recent:11217   Undecided    : 3053  
                   25-29:7203   NA's      : 6749   Wants no more: 8687  
                   30-34:5997                      NA's         : 1187  
                   35-39:5406                                           
                   40-44:4057                                           
                   NA's :3891                                           
                education      location    
 No education        :14398   Rural:24837  
 Incomplete primary  : 1908   Urban:16984  
 Complete primary    : 4475                
 Incomplete secondary: 7246                
 Complete secondary  : 9452                
 Higher              : 4342                
                                           
Multiple imputation

Multiple imputation can be achieved using a number of packages such as mice and Amelia. First, using md.pattern() function in mice package, we can pictorially explore the patterns of missingness in the data, with each row corresponding to a particular pattern of missingness. In the diagram, the blue color respresents completeness of data between variables while the red colors indicate missingness. In the accompanying crosstable, 1 corresponds to observed/nonmissing while 0 corresponds to unobserved/missing.

      terminate education location agegroup.imp sexrecency.imp
30626         1         1        1            1              1
6618          1         1        1            1              1
3386          1         1        1            1              1
4             1         1        1            1              1
560           1         1        1            1              1
126           1         1        1            1              1
500           1         1        1            1              1
1             1         1        1            1              1
              0         0        0            0              0
      fertdesire.imp fertdesire agegroup sexrecency      
30626              1          1        1          1     0
6618               1          1        1          0     1
3386               1          1        0          1     1
4                  1          1        0          0     2
560                1          0        1          1     1
126                1          0        1          0     2
500                1          0        0          1     2
1                  1          0        0          0     3
                   0       1187     3891       6749 11827

In summary:

  • The first row shows the number of cases in the data that are complete;
  • The rows with 0 attributed to a variable in the column shows the number of cases missing only the variable;
  • Rows with multiple 0s in the columns indicate that multiple variables are missing;
  • The bottom row indicates total number of cases missing each variable, in ANY combination with other variables.

In order to see how pairs of variables are missing together, we will use the md.pairs() function.

$rr
           terminate agegroup sexrecency fertdesire education location
terminate      41821    37930      35072      40634     41821    41821
agegroup       37930    37930      31186      37244     37930    37930
sexrecency     35072    31186      35072      34012     35072    35072
fertdesire     40634    37244      34012      40634     40634    40634
education      41821    37930      35072      40634     41821    41821
location       41821    37930      35072      40634     41821    41821

$rm
           terminate agegroup sexrecency fertdesire education location
terminate          0     3891       6749       1187         0        0
agegroup           0        0       6744        686         0        0
sexrecency         0     3886          0       1060         0        0
fertdesire         0     3390       6622          0         0        0
education          0     3891       6749       1187         0        0
location           0     3891       6749       1187         0        0

$mr
           terminate agegroup sexrecency fertdesire education location
terminate          0        0          0          0         0        0
agegroup        3891        0       3886       3390      3891     3891
sexrecency      6749     6744          0       6622      6749     6749
fertdesire      1187      686       1060          0      1187     1187
education          0        0          0          0         0        0
location           0        0          0          0         0        0

$mm
           terminate agegroup sexrecency fertdesire education location
terminate          0        0          0          0         0        0
agegroup           0     3891          5        501         0        0
sexrecency         0        5       6749        127         0        0
fertdesire         0      501        127       1187         0        0
education          0        0          0          0         0        0
location           0        0          0          0         0        0

As shown above, the md.pairs() function generates four patterns of missigness for a pair of variables in the data.

  • Pattern rr: Both variables are observed;
  • Pattern rm: The first variable is observed and the second variable is missing;
  • Pattern mr: The first variable is missing and the second variable is observed; and
  • Pattern mm: Both first and second variables are missing.

Next, we we use the mice package to generate multiple imputed data.


 iter imp variable
  1   1  agegroup  sexrecency  fertdesire
  1   2  agegroup  sexrecency  fertdesire
  1   3  agegroup  sexrecency  fertdesire
  1   4  agegroup  sexrecency  fertdesire
  1   5  agegroup  sexrecency  fertdesire
  2   1  agegroup  sexrecency  fertdesire
  2   2  agegroup  sexrecency  fertdesire
  2   3  agegroup  sexrecency  fertdesire
  2   4  agegroup  sexrecency  fertdesire
  2   5  agegroup  sexrecency  fertdesire
  3   1  agegroup  sexrecency  fertdesire
  3   2  agegroup  sexrecency  fertdesire
  3   3  agegroup  sexrecency  fertdesire
  3   4  agegroup  sexrecency  fertdesire
  3   5  agegroup  sexrecency  fertdesire
  4   1  agegroup  sexrecency  fertdesire
  4   2  agegroup  sexrecency  fertdesire
  4   3  agegroup  sexrecency  fertdesire
  4   4  agegroup  sexrecency  fertdesire
  4   5  agegroup  sexrecency  fertdesire
  5   1  agegroup  sexrecency  fertdesire
  5   2  agegroup  sexrecency  fertdesire
  5   3  agegroup  sexrecency  fertdesire
  5   4  agegroup  sexrecency  fertdesire
  5   5  agegroup  sexrecency  fertdesire

Below output shows that 5 multiple imputations were done. In addition, variables with missingness and the imputation method used per each variable are listed.

Class: mids
Number of multiple imputations:  5 
Imputation methods:
 terminate   agegroup sexrecency fertdesire  education   location 
        ""  "polyreg"   "logreg"  "polyreg"         ""         "" 
PredictorMatrix:
           terminate agegroup sexrecency fertdesire education location
terminate          0        1          1          1         1        1
agegroup           1        0          1          1         1        1
sexrecency         1        1          0          1         1        1
fertdesire         1        1          1          0         1        1
education          1        1          1          1         0        1
location           1        1          1          1         1        0

It is a good practice to check the plausibility of the imputed values by examining the distribution of observations by age group, sex recency and fertility desire. We proceed to run diagnosis on the imputed values for the first 5 cases across the 5 different imputations as well as the numeric and pictorial summaries of the imputed values.

     1            2            3            4            5       
 15-19: 277   15-19: 269   15-19: 289   15-19: 281   15-19: 277  
 20-24: 272   20-24: 215   20-24: 248   20-24: 258   20-24: 244  
 25-29: 405   25-29: 416   25-29: 443   25-29: 409   25-29: 422  
 30-34: 639   30-34: 682   30-34: 646   30-34: 716   30-34: 674  
 35-39:1056   35-39:1048   35-39:1009   35-39:1030   35-39:1016  
 40-44:1242   40-44:1261   40-44:1256   40-44:1197   40-44:1258  

          1                 2                 3                 4       
 Recent    :3663   Recent    :3587   Recent    :3755   Recent    :3545  
 Not recent:3086   Not recent:3162   Not recent:2994   Not recent:3204  
          5       
 Recent    :3568  
 Not recent:3181  

             1                   2                   3      
 Wants more   :706   Wants more   :704   Wants more   :718  
 Undecided    : 93   Undecided    :100   Undecided    : 87  
 Wants no more:388   Wants no more:383   Wants no more:382  
             4                   5      
 Wants more   :712   Wants more   :720  
 Undecided    :120   Undecided    :100  
 Wants no more:355   Wants no more:367  

Generally, the plots show that the imputed data plausibly correspond with the observed data. The distribution of the imputed data (red circles) align well with the observed data (blue bars) across the levels of age group, sex recency and fertility desire in different imputation runs.

Before we proceed, let’s have a cursory look at our complete imputed data and compare with the observed data. We can achieve this using the complete() function, which by default extracts the first run of the imputed data set. To get complete data set from the third run, we have to modify with the action=3 option; i.e. complete(imp, action=3).

The outputs highlight the patterns of imputation done to the original data for each of the first ten cases missing on agegroup and fertdesire variables using information from respondents with similar characteristics and complete data.

Filter approach

By this approach, we excluding all cases with any missing record from the original data, leaving only the observations with complete data for across all variables.

Compare number of cases in imputed and filter data
[1] 41821     6
[1] 30626     6

This shows that the imputed data (41821) is more complete than the filtered data (30626) with over 11000 more observations. This is the main purpose of data imputation exercise: to have more number of cases with complete information for analysis.



Models comparison

Below we fIt models on the imputed data and observed data which excludes observations with missing information. Next, we compare estimates from the models to assess whether missingness in any variable occur at random or otherwise.


Comparison of estimates from imputed and filtered data
--------------------------------------------------------
                       Imputed data      Filtered data  
--------------------------------------------------------
20-24                1.390 (0.086)***  0.526 (0.091)*** 
25-29                1.800 (0.082)***  0.844 (0.087)*** 
30-34                2.170 (0.082)***  1.150 (0.088)*** 
35-39                2.370 (0.083)***  1.360 (0.089)*** 
40-44                2.380 (0.088)***  1.380 (0.095)*** 
Not recent           -0.374 (0.036)*** -0.394 (0.040)***
Undecided            -0.302 (0.065)*** -0.296 (0.071)***
Wants no more        -0.392 (0.043)*** -0.379 (0.049)***
Incomplete primary   0.361 (0.071)***  0.392 (0.078)*** 
Complete primary       0.078 (0.053)     0.082 (0.059)  
Incomplete secondary   0.040 (0.054)    0.129 (0.058)*  
Complete secondary    -0.051 (0.045)    -0.004 (0.049)  
Higher                -0.001 (0.055)     0.075 (0.060)  
Urban                  0.015 (0.035)    0.076 (0.038)*  
Constant             -3.640 (0.079)*** -2.710 (0.082)***
N                         41,821            30,626      
--------------------------------------------------------
Notes:               *p < .05; **p < .01; ***p < .001   

Results show similar patterns of association between abortion and corresponding variables in imputed data (specifically age, sex recency and fertility desire) and filtered data. This suggests plausibility of the imputation conducted.



Acknowledgements

  1. This content was inspired by Dr. Corey Sparks’ lab session on “Multiple Imputation & Missing Data” and his other easy-to-follow instructional materials accessible at https://rpubs.com/corey_sparks.

  2. Data from Demographic and Health Surveys archive can be requested from https://www.dhsprogram.com/.

  3. Stargazer is authored by Marek Hlavac and full document can be downloaded from https://cran.r-project.org/web/packages/stargazer/stargazer.pdf