I try to understand the difference between using different na.actions (na.omit and na.exclude) to handle missing data in a linear model using R. I used the lm function in R (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html).
The summary of my linear model prints exactly the same for na.omit and na.exclude. But if I look at the residuals, the na.exclude gives me NA' s for the cases where there was an NA and it gives me a list of residuals without NA for the na.omit.
residuals.lm(lm_1_exclude)
1 2 3 4 5 6 7 8
-0.0526 -0.0930 -0.3295 NA -0.1520 -0.3217 -0.3220 0.0722
residuals.lm(lm_1_omit)
1 2 3 5 6 7 8
-0.0526 -0.0930 -0.3295 -0.1520 -0.3217 -0.3220 0.0722
I now would like to understand, which option should be preferred in a linear model and how this affects my statistics.. unfortunately, I only could find tutorials explaining that these different options exist, but no advice on what to choose. https://stats.idre.ucla.edu/r/faq/how-does-r-handle-missing-values/
na.exclude
is that it retains the position where data was missing in the final residual vector. If that is something you want then that makesna.exclude
preferable overna.omit
. $\endgroup$