Two fits on different rows

Beginner

Topic: Using R · more questions on this topic

1 of 1

A linear model of ozone on temperature is fit twice. The first fit drops days on which ozone is missing. The second also drops days on which wind is missing, because wind has been added to the formula. The temperature coefficient changes.

Why is that change not, by itself, evidence that wind belongs in the mean?

The two fits do not use the same days. A formula keeps only the rows in which every variable it names is present, so adding wind throws away days that have ozone and temperature but not wind. nobs reports how many rows each fit used. A coefficient from the smaller subset is an estimate for that subset. Comparing it with the coefficient from the larger subset mixes a change of sample with a change of formula.

To ask whether wind belongs in the mean, refit both formulas on the rows where ozone, temperature, and wind are all present, and only then compare the temperature coefficients.