Missing data preparation

1. Data gathering

The data is obtained from iHAPSS page which is an internet system for monitoring the effects of air pollution on mortality and morbidity.

## Loading required package: ggplot2
## Loading required package: AICcmodavg

2. Data visualization

  1. Date variable is converted to DATE()
  2. dow variable is converted to FACTOR()
  3. 3 of the 112 variables are selected
  4. NA values are removed

Summary of data is:

summary(table)
##       date            dow        tmean      
##  Min.   :1987-01-01   1:26   Min.   : 2.38  
##  1st Qu.:1987-02-14   2:26   1st Qu.:33.75  
##  Median :1987-03-31   3:25   Median :45.25  
##  Mean   :1987-03-31   4:25   Mean   :49.08  
##  3rd Qu.:1987-05-15   5:26   3rd Qu.:66.06  
##  Max.   :1987-06-29   6:26   Max.   :87.75  
##                       7:26

Plot of the data:

plot of chunk unnamed-chunk-3

3. Data manipulation

Some random missing is added to this data (60 values are deleted randomly in each column):

plot of chunk unnamed-chunk-4

Real mean: 49.0778

Mean after adding NA: 50.5448

4. Mean Imputation

Easiest way to impute is to replace each missing value with the mean of the observed values for that variable. Unfortunately, this strategy can severely distort the distribution for this variable, leading to complications with summary measures including, notably, underestimates of the standard deviation. Moreover, mean imputation distorts relationships between variables by “pulling” estimates of the correlation toward zero.

plot of chunk unnamed-chunk-5

Real mean: 49.0778

Mean after Mean Imputation: 50.5448

5. Last value carried forward

plot of chunk unnamed-chunk-6

Real mean: 49.0778

Mean after LVCF Imputation: 48.709

6. regression prediction

Imputed values are hidden behind the regresssion line and partially visible in the graph.

plot of chunk unnamed-chunk-7

Real mean: 49.0778

Mean after regression prediction: 49.4156

7. multiple imputation

imputation is done using AMELIA: Multiple Imputation of Incomplete Multivariate Data which Runs the bootstrap EM algorithm on incomplete data and creates imputed datasets.

5 imputations are creted and the mean of the 5 samples is taken as the target.

## Loading required package: Amelia
## Loading required package: foreign
## Loading required package: Rcpp
## Loading required package: RcppArmadillo
## ## 
## ## Amelia II: Multiple Imputation
## ## (Version 1.7.2, built: 2013-04-03)
## ## Copyright (C) 2005-2014 James Honaker, Gary King and Matthew Blackwell
## ## Refer to http://gking.harvard.edu/amelia/ for more information
## ##
## -- Imputation 1 --
## 
##   1  2  3  4
## 
## -- Imputation 2 --
## 
##   1  2  3  4
## 
## -- Imputation 3 --
## 
##   1  2  3  4
## 
## -- Imputation 4 --
## 
##   1  2  3  4
## 
## -- Imputation 5 --
## 
##   1  2  3  4
## 
## Amelia output with 5 imputed datasets.
## Return code:  1 
## Message:  Normal EM convergence. 
## 
## Chain Lengths:
## --------------
## Imputation 1:  4
## Imputation 2:  4
## Imputation 3:  4
## Imputation 4:  4
## Imputation 5:  4
## 
## Rows after Listwise Deletion:  120 
## Rows after Imputation:  180 
## Patterns of missingness in the data:  2 
## 
## Fraction Missing for original variables: 
## -----------------------------------------
## 
##       Fraction Missing
## date            0.0000
## dow             0.0000
## tmean           0.3333

plot of chunk unnamed-chunk-8 plot of chunk unnamed-chunk-8 Real mean: 49.0778

Mean after 5 imputations: 49.4885

AKAIKE information criterion

Note: The actual (Q)AIC© values are not really interesting in themselves, as they depend directly on the data, parameters estimated, and likelihood function. Furthermore, a single value does not tell much about model fit. Information criteria become relevant when compared to one another for a given data set and set of candidate models.

original: 1312.8485

mean method: 1360.1213

LVCF: 1317.6132

Regression: 1239.038

Imputation: 1254.4242