# How to perform a bivariate regression using pairwise deletion of missing values in R?

Is there any way to perform bivariate regression using pairwise deletion of missing values in R? na.action options in lm() do not offer such a possibility – the default na.action is na.omit, which is equivalent to listwise deletion. I already tried estimating the covariance matrix using pairwise deletion and then use the function mat.regress (package psych) with the pairwise covariance matrix. However, mat.regress is a function to compute multiple regression (not bivariate). Thank you.

• This question appears to be off-topic because it is about how to use r. – gung - Reinstate Monica Jun 27 '14 at 12:05
• I think this question should stay here. It is a pretty simple chore to answer this question without regard to statistical programming. – Andy W Jun 27 '14 at 12:19

When you use pair wise deletion to estimate a covariance matrix it just means that for any pair of variables you use all available observations that are not missing on either covariate.

So if you had a data matrix

#| A  B  C
-----------
1| 1  1  NA
2| 2  NA 2
3| NA 3  3
4| 4  4  4


When calculating the covariance between columns A and B you would use rows (observations) 1 and 4, and when calculating the covariance between A and C you would only use rows 2 and 4.

So in the case of bivariate regression or simple linear regression, it is equivalent to list-wise deletion.

• I think that when calculating the covariance between A and B, pairwise deletion would use rows 1, 2 and 4 to compute the mean of variable A and rows 1, 3 and 4 to calculate the mean of B. After that, pairwise deletion will use only rows 1 and 4 to calculate the covariance. However, the means used in the formula are based on three rows. What I mean is that pairwise deletion tries to use all available information in the data. In other words, when using pairwise deletion in bivariate regression, one may arrive at different results of coefficients than when they use listwise deletion. – petrivan Jun 27 '14 at 12:50
• You should not use the mean and variance calculated from all available cases. Try to see what happens in the example data set I provided when you do! – Andy W Jun 27 '14 at 12:58
• My point is that listwise and pairwise deletion methods lead to different results (based on the available literature, and also when I perform the bivariate regression in SPSS). I know that pairwise deletion has its drawbacks. However, I would just like to know if and how to perform pairwise deletion in R. – petrivan Jun 27 '14 at 13:11
• @petrivan - I'm not sure how SPSS does do it's pairwise deletion for linear regression. Here is how I thought they would do it with an R code example, but they are not the same. – Andy W Jun 27 '14 at 19:07