Can't successfully omit NAs when using lm()

I am trying to create two linear regression models and then use anova() to compare them. My second model has NAs which I cannot seem to omit correctly.

m2 <- lm(Lab19 ~ EthnicMinorities + Ages18to44 + c11Degree, data=df1, na.action=na.omit)

I tried this but when I use summary(m2) it says 59 observations deleted due to missingness.

This also means when I try to use anova(m1, m2) it says models were not all fitted to the same size of dataset presumably because of the selected observations in m2.

Can anyone help please

I have to assume that you have two models trained on the same data (df1), presumably therefore the relevant difference is that one of your choices of dependent variable have NA's but only is used in one of the two models.
Presumably this means that you are inclined to omit the rows from the common source ,df1, rather than just a single models version of df1.
Whether this is justified I cant say,.. but it sounds like a potentially bad idea, due to introducing bias into your model) but we have no context for what you are doing so advice can only be threadbare.

You need to provide command for m1 for anyone to have any idea. Ideally you need to prepare reprex for a useful input from anyone. For preparing a reprex see

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.