0
$\begingroup$

I have a dataset with 2700 obs, it is the response based on SDQ questionnaire I have a categorical variable with more than one category and missing values and have some other continuous variable with missing values too. the proportion of missingness is significant and I cannot ignore them how can I analyze the association between these categorical and continuous variables?

$\endgroup$
5
  • $\begingroup$ You may need to check different imputation techniques and choose one that will be suitable for your dataset. $\endgroup$ May 23, 2018 at 2:23
  • $\begingroup$ What analysis do you want to do? Regression? Making a plot? $\endgroup$
    – pdb
    May 23, 2018 at 4:31
  • 1
    $\begingroup$ The mice package has functions for missing data imputation. Depending on the type of analysis you're doing, for the categorical variable you could also treat the NA's as a distinct (valid) category. $\endgroup$ May 23, 2018 at 4:33
  • $\begingroup$ You might also want to check the book on imputation by Schafer. For mixed variables, the package mix in R implements the method. $\endgroup$
    – F. Tusell
    May 23, 2018 at 9:35
  • $\begingroup$ I have variables with response based on likert scale having 5 categories and a "I don't know" category. But these variables also have missing values. I have to analyse both the missingness and "don't know" values and perform suitable imputation for it. Also I have these data from an intervention program with 2 more variables sex and grade which are binary. I have to develop a suitable model to predict the possibility of a student being female/male and his grade given these likert variables and some other continuous variables with many missing values about the attitude of the student. $\endgroup$ May 23, 2018 at 15:48

1 Answer 1

3
$\begingroup$

The Amelia and mice packages are great for finding out where your missingness is coming from. I will use the boys dataset from the mice package to show you how. To plot missingness patterns, I simply enter the following code:

library(mice)
md.pattern(boys,
           rotate.names = T)

This gives me the following matrix of missingness patterns. For example, there are 223 cases of complete data and 19 cases where only the TV variable has an incomplete value:

    age reg wgt hgt bmi hc gen phb  tv     
223   1   1   1   1   1  1   1   1   1    0
19    1   1   1   1   1  1   1   1   0    1
1     1   1   1   1   1  1   1   0   1    1
1     1   1   1   1   1  1   0   1   0    2
437   1   1   1   1   1  1   0   0   0    3
43    1   1   1   1   1  0   0   0   0    4
16    1   1   1   0   0  1   0   0   0    5
1     1   1   1   0   0  0   0   0   0    6
1     1   1   0   1   0  1   0   0   0    5
1     1   1   0   0   0  1   1   1   1    3
1     1   1   0   0   0  0   1   1   1    4
1     1   1   0   0   0  0   0   0   0    7
3     1   0   1   1   1  1   0   0   0    4
      0   3   4  20  21 46 503 503 522 1622

It also provides this plot automatically: enter image description here

You can see from the red squares where patterns lie. For example, there is at least one case where 7 missing values are present between variables (shown in red boxes as well as the tabulated value. To look at precisely where this missingness is, a missingness map from the Amelia package can be more precise:

library(Amelia)
missmap(boys)

enter image description here

You can see here that most of the missingness is coming from three variables on the left.

Using this information, you can quickly trace where some categorical variables may be influencing the missingness. It can also help to plot your NA values by category. For example using the tidyverse, I can look at tabulations visually by different factors.

library(tidyverse)
ggplot(boys,
       aes(x=is.na(phb)))+
  geom_bar()+
  facet_wrap(~reg)

enter image description here

Hope this is helpful!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.